Merge pull request #7845 from dcantah/fix-noip-onrestart
Fixes https://github.com/containerd/containerd/issues/7843
This commit is contained in:
commit
3233d5d6f5
@ -179,6 +179,21 @@ func TestContainerdRestart(t *testing.T) {
|
|||||||
if s.id == loaded.Id {
|
if s.id == loaded.Id {
|
||||||
t.Logf("Checking sandbox state for '%s'", s.name)
|
t.Logf("Checking sandbox state for '%s'", s.name)
|
||||||
assert.Equal(t, s.state, loaded.State)
|
assert.Equal(t, s.state, loaded.State)
|
||||||
|
|
||||||
|
// See https://github.com/containerd/containerd/issues/7843 for details.
|
||||||
|
// Test that CNI result and sandbox IPs are still present after restart.
|
||||||
|
if loaded.State == runtime.PodSandboxState_SANDBOX_READY {
|
||||||
|
status, info, err := SandboxInfo(loaded.Id)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Check that the NetNS didn't close on us, that we still have
|
||||||
|
// the CNI result, and that we still have the IP we were given
|
||||||
|
// for this pod.
|
||||||
|
require.False(t, info.NetNSClosed)
|
||||||
|
require.NotNil(t, info.CNIResult)
|
||||||
|
require.NotNil(t, status.Network)
|
||||||
|
require.NotEmpty(t, status.Network.Ip)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,7 +280,8 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
|||||||
// Update spec of the container
|
// Update spec of the container
|
||||||
containerd.UpdateContainerOpts(containerd.WithSpec(spec)),
|
containerd.UpdateContainerOpts(containerd.WithSpec(spec)),
|
||||||
// Update sandbox metadata to include NetNS info
|
// Update sandbox metadata to include NetNS info
|
||||||
containerd.UpdateContainerOpts(containerd.WithContainerExtension(sandboxMetadataExtension, &sandbox.Metadata))); err != nil {
|
containerd.UpdateContainerOpts(containerd.WithContainerExtension(sandboxMetadataExtension, &sandbox.Metadata)),
|
||||||
|
); err != nil {
|
||||||
return nil, fmt.Errorf("failed to update the network namespace for the sandbox container %q: %w", id, err)
|
return nil, fmt.Errorf("failed to update the network namespace for the sandbox container %q: %w", id, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,6 +311,14 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
|||||||
return nil, fmt.Errorf("failed to setup network for sandbox %q: %w", id, err)
|
return nil, fmt.Errorf("failed to setup network for sandbox %q: %w", id, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update metadata here to save CNI result and pod IPs to disk.
|
||||||
|
if err := container.Update(ctx,
|
||||||
|
// Update sandbox metadata to include NetNS info
|
||||||
|
containerd.UpdateContainerOpts(containerd.WithContainerExtension(sandboxMetadataExtension, &sandbox.Metadata)),
|
||||||
|
); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to update the network namespace for the sandbox container %q: %w", id, err)
|
||||||
|
}
|
||||||
|
|
||||||
sandboxCreateNetworkTimer.UpdateSince(netStart)
|
sandboxCreateNetworkTimer.UpdateSince(netStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user