Skip to content

Commit 59b4933

Browse files
authored
Merge pull request kubernetes#86724 from gongguan/fix-fake-CRI
fix fake remote CRI
2 parents e7c7905 + e8eb5c6 commit 59b4933

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pkg/kubelet/remote/fake/fake_runtime.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ func (f *RemoteRuntime) Start(endpoint string) error {
6161
}
6262

6363
go f.server.Serve(l)
64+
65+
// Set runtime and network conditions ready.
66+
f.RuntimeService.FakeStatus = &kubeapi.RuntimeStatus{
67+
Conditions: []*kubeapi.RuntimeCondition{
68+
{Type: kubeapi.RuntimeReady, Status: true},
69+
{Type: kubeapi.NetworkReady, Status: true},
70+
},
71+
}
72+
6473
return nil
6574
}
6675

staging/src/k8s.io/cri-api/pkg/apis/testing/fake_runtime_service.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@ func (r *FakeRuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig,
194194
Network: &runtimeapi.PodSandboxNetworkStatus{
195195
Ip: FakePodSandboxIPs[0],
196196
},
197+
// Without setting sandboxStatus's Linux.Namespaces.Options, kubeGenericRuntimeManager's podSandboxChanged will consider it as network
198+
// namespace changed and always recreate sandbox which causes pod creation failed.
199+
// Ref `sandboxStatus.GetLinux().GetNamespaces().GetOptions().GetNetwork() != networkNamespaceForPod(pod)` in podSandboxChanged function.
200+
Linux: &runtimeapi.LinuxPodSandboxStatus{
201+
Namespaces: &runtimeapi.Namespace{
202+
Options: config.GetLinux().GetSecurityContext().GetNamespaceOptions(),
203+
},
204+
},
197205
Labels: config.Labels,
198206
Annotations: config.Annotations,
199207
RuntimeHandler: runtimeHandler,

0 commit comments

Comments
 (0)