mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-26 12:02:34 +00:00
Fix variable 'state' collides with imported package name
Signed-off-by: he.qingguo <he.qingguo@zte.com.cn>
This commit is contained in:
parent
ff4234720d
commit
8249cd611d
@ -458,9 +458,9 @@ func findContainerIDByName(status *v1.PodStatus, name string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func findContainerStatusByName(status *v1.PodStatus, name string) (*v1.ContainerStatus, error) {
|
func findContainerStatusByName(status *v1.PodStatus, name string) (*v1.ContainerStatus, error) {
|
||||||
for _, status := range append(status.InitContainerStatuses, status.ContainerStatuses...) {
|
for _, containerStatus := range append(status.InitContainerStatuses, status.ContainerStatuses...) {
|
||||||
if status.Name == name {
|
if containerStatus.Name == name {
|
||||||
return &status, nil
|
return &containerStatus, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("unable to find status for container with name %v in pod status (it may not be running)", name)
|
return nil, fmt.Errorf("unable to find status for container with name %v in pod status (it may not be running)", name)
|
||||||
|
@ -483,14 +483,14 @@ func TestCPUManagerAddWithInitContainers(t *testing.T) {
|
|||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
policy, _ := NewStaticPolicy(testCase.topo, testCase.numReservedCPUs, cpuset.NewCPUSet(), topologymanager.NewFakeManager())
|
policy, _ := NewStaticPolicy(testCase.topo, testCase.numReservedCPUs, cpuset.NewCPUSet(), topologymanager.NewFakeManager())
|
||||||
|
|
||||||
state := &mockState{
|
mockState := &mockState{
|
||||||
assignments: testCase.stAssignments,
|
assignments: testCase.stAssignments,
|
||||||
defaultCPUSet: testCase.stDefaultCPUSet,
|
defaultCPUSet: testCase.stDefaultCPUSet,
|
||||||
}
|
}
|
||||||
|
|
||||||
mgr := &manager{
|
mgr := &manager{
|
||||||
policy: policy,
|
policy: policy,
|
||||||
state: state,
|
state: mockState,
|
||||||
containerRuntime: mockRuntimeService{},
|
containerRuntime: mockRuntimeService{},
|
||||||
containerMap: containermap.NewContainerMap(),
|
containerMap: containermap.NewContainerMap(),
|
||||||
podStatusProvider: mockPodStatusProvider{},
|
podStatusProvider: mockPodStatusProvider{},
|
||||||
@ -526,10 +526,10 @@ func TestCPUManagerAddWithInitContainers(t *testing.T) {
|
|||||||
testCase.description, containerIDs[i], err)
|
testCase.description, containerIDs[i], err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cset, found := state.assignments[string(testCase.pod.UID)][containers[i].Name]
|
cset, found := mockState.assignments[string(testCase.pod.UID)][containers[i].Name]
|
||||||
if !expCSets[i].IsEmpty() && !found {
|
if !expCSets[i].IsEmpty() && !found {
|
||||||
t.Errorf("StaticPolicy AddContainer() error (%v). expected container %v to be present in assignments %v",
|
t.Errorf("StaticPolicy AddContainer() error (%v). expected container %v to be present in assignments %v",
|
||||||
testCase.description, containers[i].Name, state.assignments)
|
testCase.description, containers[i].Name, mockState.assignments)
|
||||||
}
|
}
|
||||||
|
|
||||||
if found && !cset.Equals(expCSets[i]) {
|
if found && !cset.Equals(expCSets[i]) {
|
||||||
@ -540,9 +540,9 @@ func TestCPUManagerAddWithInitContainers(t *testing.T) {
|
|||||||
cumCSet = cumCSet.Union(cset)
|
cumCSet = cumCSet.Union(cset)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !testCase.stDefaultCPUSet.Difference(cumCSet).Equals(state.defaultCPUSet) {
|
if !testCase.stDefaultCPUSet.Difference(cumCSet).Equals(mockState.defaultCPUSet) {
|
||||||
t.Errorf("StaticPolicy error (%v). expected final state for defaultCPUSet %v but got %v",
|
t.Errorf("StaticPolicy error (%v). expected final state for defaultCPUSet %v but got %v",
|
||||||
testCase.description, testCase.stDefaultCPUSet.Difference(cumCSet), state.defaultCPUSet)
|
testCase.description, testCase.stDefaultCPUSet.Difference(cumCSet), mockState.defaultCPUSet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user