Skip to content

runconfig/errors: split ErrConflictHostNetwork #49604

@br3ndonland

Description

@br3ndonland

Description

Description

ErrConflictHostNetwork was added in #17476.

ErrConflictHostNetwork validationError = "container cannot be disconnected from host network or connected to host network"

Confusingly, the same error message is used for two different errors.

  1. When attempting to change the network mode of a running container from a different mode to host.
    if !ctr.HostConfig.NetworkMode.IsHost() && containertypes.NetworkMode(n.Type()).IsHost() {
    return runconfig.ErrConflictHostNetwork
    }
  2. When the network mode of a running container is already host and attempting to disconnect from host.
    if ctr.HostConfig.NetworkMode.IsHost() && containertypes.NetworkMode(n.Type()).IsHost() {
    return runconfig.ErrConflictHostNetwork
    }

Using the same error message for these two errors makes troubleshooting difficult.

Suggestions

Split the ErrConflictHostNetwork error into two distinct errors:

  1. ErrConflictConnectToHostNetwork when attempting to change the network mode of a running container from a different mode to host
  2. ErrConflictDisconnectFromHostNetwork when the network mode of a running container is host and attempting to disconnect from host

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureFunctionality or other elements that the project doesn't currently have. Features are new and shinystatus/0-triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions