Skip to content

Windows: Re-create custom NAT networks after restart if missing from HNS#43836

Merged
thaJeztah merged 1 commit intomoby:masterfrom
olljanat:restore-custom-nat-networks
Jul 21, 2022
Merged

Windows: Re-create custom NAT networks after restart if missing from HNS#43836
thaJeztah merged 1 commit intomoby:masterfrom
olljanat:restore-custom-nat-networks

Conversation

@olljanat
Copy link
Contributor

- What I did
Revisited on logic added by #20478 to correctly handle non-default NAT networks on Windows after server restart.
Closes #43408

- How I did it
Added logic which will re-create those networks with same settings after deleting orphan.

- How to verify it

  1. Create custom network and start container to it:
docker network create --driver nat test
docker run --net test --restart always --name test -d mcr.microsoft.com/windows/servercore:ltsc2022 ping -t 127.0.0.1
  1. Restart server and check that test container is running.

Test binary can be found from https://filebin.net/t5nyuqjjx7un8lpd/dockerd.exe
However note that only networks which are not already missing/broken before switching to new binary version will works correctly because current behavior is that those networks get totally removed from Docker.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@evol262 perhaps you want to have a look as well?

name := v.Name()
id := v.ID()

err = v.Delete()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure; would the ingress network also be in this list? If so, do we need to pass NetworkDeleteOptionRemoveLB as option?

func NetworkDeleteOptionRemoveLB(p *networkDeleteParams) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I guess the ingress network wouldn't be v.Type() == "nat" ? If that's so, ignore my comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ingress is v.Type() == "overlay" so this does not affect those.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Yes, I realised that after writing my first comment; thanks for confirming 👍

@thaJeztah thaJeztah added this to the v-next milestone Jul 21, 2022
@thaJeztah
Copy link
Member

alright, let's get this in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows containers does not restart after Windows Server 2019 restart.

4 participants