Merge pull request #1010 from teawater/fix_crash
Fix the issue that pod or container config file without metadata will…
This commit is contained in:
commit
1fbd06479e
@ -92,7 +92,11 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
|||||||
// Reserve the container name to avoid concurrent `CreateContainer` request creating
|
// Reserve the container name to avoid concurrent `CreateContainer` request creating
|
||||||
// the same container.
|
// the same container.
|
||||||
id := util.GenerateID()
|
id := util.GenerateID()
|
||||||
name := makeContainerName(config.GetMetadata(), sandboxConfig.GetMetadata())
|
metadata := config.GetMetadata()
|
||||||
|
if metadata == nil {
|
||||||
|
return nil, errors.New("container config must include metadata")
|
||||||
|
}
|
||||||
|
name := makeContainerName(metadata, sandboxConfig.GetMetadata())
|
||||||
logrus.Debugf("Generated id %q for container %q", id, name)
|
logrus.Debugf("Generated id %q for container %q", id, name)
|
||||||
if err = c.containerNameIndex.Reserve(name, id); err != nil {
|
if err = c.containerNameIndex.Reserve(name, id); err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to reserve container name %q", name)
|
return nil, errors.Wrapf(err, "failed to reserve container name %q", name)
|
||||||
|
@ -58,7 +58,11 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
|||||||
|
|
||||||
// Generate unique id and name for the sandbox and reserve the name.
|
// Generate unique id and name for the sandbox and reserve the name.
|
||||||
id := util.GenerateID()
|
id := util.GenerateID()
|
||||||
name := makeSandboxName(config.GetMetadata())
|
metadata := config.GetMetadata()
|
||||||
|
if metadata == nil {
|
||||||
|
return nil, errors.New("sandbox config must include metadata")
|
||||||
|
}
|
||||||
|
name := makeSandboxName(metadata)
|
||||||
logrus.Debugf("Generated id %q for sandbox %q", id, name)
|
logrus.Debugf("Generated id %q for sandbox %q", id, name)
|
||||||
// Reserve the sandbox name to avoid concurrent `RunPodSandbox` request starting the
|
// Reserve the sandbox name to avoid concurrent `RunPodSandbox` request starting the
|
||||||
// same sandbox.
|
// same sandbox.
|
||||||
|
Loading…
Reference in New Issue
Block a user