mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
runconfig/errors: split ErrConflictHostNetwork
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` This commit clarifies error messaging by differentiating between the two errors, making it clearer which operation failed and how to fix it. Signed-off-by: Brendon Smith <bws@bws.bio>
This commit is contained in:
@@ -173,7 +173,7 @@ func (daemon *Daemon) updateNetworkSettings(ctr *container.Container, n *libnetw
|
||||
}
|
||||
|
||||
if !ctr.HostConfig.NetworkMode.IsHost() && containertypes.NetworkMode(n.Type()).IsHost() {
|
||||
return runconfig.ErrConflictHostNetwork
|
||||
return runconfig.ErrConflictConnectToHostNetwork
|
||||
}
|
||||
|
||||
for s, v := range ctr.NetworkSettings.Networks {
|
||||
@@ -1053,7 +1053,7 @@ func (daemon *Daemon) DisconnectFromNetwork(ctx context.Context, ctr *container.
|
||||
delete(ctr.NetworkSettings.Networks, networkName)
|
||||
} else if err == nil {
|
||||
if ctr.HostConfig.NetworkMode.IsHost() && containertypes.NetworkMode(n.Type()).IsHost() {
|
||||
return runconfig.ErrConflictHostNetwork
|
||||
return runconfig.ErrConflictDisconnectFromHostNetwork
|
||||
}
|
||||
|
||||
if err := daemon.disconnectFromNetwork(ctx, ctr, n, false); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user