Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[25.0 backport] Only restore a configured MAC addr on restart. #47304

Merged
merged 2 commits into from Feb 2, 2024

Commits on Feb 2, 2024

  1. Only restore a configured MAC addr on restart.

    The API's EndpointConfig struct has a MacAddress field that's used for
    both the configured address, and the current address (which may be generated).
    
    A configured address must be restored when a container is restarted, but a
    generated address must not.
    
    The previous attempt to differentiate between the two, without adding a field
    to the API's EndpointConfig that would show up in 'inspect' output, was a
    field in the daemon's version of EndpointSettings, MACOperational. It did
    not work, MACOperational was set to true when a configured address was
    used. So, while it ensured addresses were regenerated, it failed to preserve
    a configured address.
    
    So, this change removes that code, and adds DesiredMacAddress to the wrapped
    version of EndpointSettings, where it is persisted but does not appear in
    'inspect' results. Its value is copied from MacAddress (the API field) when
    a container is created.
    
    Signed-off-by: Rob Murray <rob.murray@docker.com>
    (cherry picked from commit dae3303)
    Signed-off-by: Albin Kerouanton <albinker@gmail.com>
    robmry authored and akerouanton committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    5b13a38 View commit details
    Browse the repository at this point in the history
  2. No inspect 'Config.MacAddress' unless configured.

    Do not set 'Config.MacAddress' in inspect output unless the MAC address
    is configured.
    
    Also, make sure it is filled in for a configured address on the default
    network before the container is started (by translating the network name
    from 'default' to 'config' so that the address lookup works).
    
    Signed-off-by: Rob Murray <rob.murray@docker.com>
    (cherry picked from commit 8c64b85)
    Signed-off-by: Albin Kerouanton <albinker@gmail.com>
    robmry authored and akerouanton committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    bbe6f09 View commit details
    Browse the repository at this point in the history