mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 21:53:52 +00:00
Merge pull request #97748 from heqg/collides-state
Fix variable 'state' collides with imported package name
This commit is contained in:
@@ -441,9 +441,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)
|
||||||
|
@@ -476,14 +476,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{},
|
||||||
@@ -521,10 +521,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]) {
|
||||||
@@ -535,9 +535,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user