sonic-net / sonic-mgmt

Configuration management examples for SONiC
Other
200 stars 732 forks source link

[setup-container] Add container length check #15758

Closed matthew-soulsby closed 4 days ago

matthew-soulsby commented 4 days ago

Description of PR

Summary: Adds a check to enhance clarity of error thrown when a container created with a name that is of a length greater than 64 characters will fail to start after creation:

docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: sethostname: invalid argument: unknown.

This is due to the internal hostname of the container being set to the container's name, which has an additional 64 character limit, causing the container to fail to start consistently.

Type of change

Back port request

Approach

What is the motivation for this PR?

To enhance error messaging for this particular edge case, as it was previously difficult to discern why the container would be created successfully, but then consistently fail to start.

How did you do it?

Adds a check to prevent containers from being created with name lengths greater than 64 characters, as these containers will not be able to start.

How did you verify/test it?

Ran the setup script, with both a valid name and an invalid name (valid is on the left, invalid is on the right):

image

Any platform specific information?

N/A

Supported testbed topology if it's a new test case?

N/A

Documentation

N/A

mssonicbld commented 4 days ago

@matthew-soulsby PR conflicts with 202405 branch