Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Handle iptables cleanup on uninstall #211

Merged
merged 6 commits into from
May 15, 2019
Merged

Conversation

aramase
Copy link
Member

@aramase aramase commented May 6, 2019

resolves #113

This will handle graceful shutdown of the pod, cleanup the ip table chain and rules that were inserted by NMI.

@aramase aramase mentioned this pull request May 6, 2019
@kkmsft
Copy link
Contributor

kkmsft commented May 10, 2019

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

pkg/nmi/server/server.go Show resolved Hide resolved
pkg/nmi/server/server.go Show resolved Hide resolved
pkg/nmi/iptables/iptables.go Outdated Show resolved Hide resolved
@kkmsft
Copy link
Contributor

kkmsft commented May 10, 2019

@aramase - Thank you for the PR. Have added some comments. Please take a look at them.

An additional request is - could you also add the comments you made on manual deletion in #154 to documentation for cases where a manual delete might be required (for signals which are not actionable)

@aramase
Copy link
Member Author

aramase commented May 15, 2019

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 211 in repo Azure/aad-pod-identity

_, err := cmd.CombinedOutput()
Expect(err).NotTo(HaveOccurred())

time.Sleep(90 * time.Second)
Copy link
Member Author

Choose a reason for hiding this comment

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

Added 90s wait time because it's possible nmi pods are just being created. It takes 60s after the pod startup before the iptables entries are added since the ticker is configured with 60s update duration. We might need to change this to create the ticker with instant first tick to prevent any race conditions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add a check to ensure that the rules have been indeed added instead of the sleep to make it more deterministic. Perhaps in a future PR, but could make our tests more deterministic ?

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense. I'll open an issue to track that change.

hostNetwork: true
containers:
- name: busybox
image: alpine:3.8
Copy link
Contributor

Choose a reason for hiding this comment

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

just wanted to confirm that its the newest version ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The latest version is alpine:3.9.4. I kept it at 3.8 because that is the version we are using to build other images.

image: alpine:3.8
stdin: true
securityContext:
privileged: true
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need privileged for this ? Isn't hostNetwork: true enough to check the iptables existence ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, without privileged the iptables table won't initialize.