fix fake remote CRI

This commit is contained in:
louisgong 2019-12-30 21:35:16 +08:00 committed by gongguanjun
parent d758fc3edb
commit e8eb5c656b
2 changed files with 17 additions and 0 deletions

View File

@ -61,6 +61,15 @@ func (f *RemoteRuntime) Start(endpoint string) error {
} }
go f.server.Serve(l) go f.server.Serve(l)
// Set runtime and network conditions ready.
f.RuntimeService.FakeStatus = &kubeapi.RuntimeStatus{
Conditions: []*kubeapi.RuntimeCondition{
{Type: kubeapi.RuntimeReady, Status: true},
{Type: kubeapi.NetworkReady, Status: true},
},
}
return nil return nil
} }

View File

@ -194,6 +194,14 @@ func (r *FakeRuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig,
Network: &runtimeapi.PodSandboxNetworkStatus{ Network: &runtimeapi.PodSandboxNetworkStatus{
Ip: FakePodSandboxIPs[0], Ip: FakePodSandboxIPs[0],
}, },
// Without setting sandboxStatus's Linux.Namespaces.Options, kubeGenericRuntimeManager's podSandboxChanged will consider it as network
// namespace changed and always recreate sandbox which causes pod creation failed.
// Ref `sandboxStatus.GetLinux().GetNamespaces().GetOptions().GetNetwork() != networkNamespaceForPod(pod)` in podSandboxChanged function.
Linux: &runtimeapi.LinuxPodSandboxStatus{
Namespaces: &runtimeapi.Namespace{
Options: config.GetLinux().GetSecurityContext().GetNamespaceOptions(),
},
},
Labels: config.Labels, Labels: config.Labels,
Annotations: config.Annotations, Annotations: config.Annotations,
RuntimeHandler: runtimeHandler, RuntimeHandler: runtimeHandler,