Skip to content

Conversation

@JungukCho
Copy link
Contributor

@JungukCho JungukCho commented Nov 4, 2021

Reason for Change:
PodController in NPM removes ipset information as soon as Pod's status becomes “Terminating”.
So, even though terminated Pod has some activities (e.g., sending traffic to other pods to notify something) during "Terminating" status, NPM does not allow this connection from the Pod.
Thus, NPM needs to delay cleanup process until Pod completes graceful shutdown.

Plus : started trying parallel UTs.

Issue Fixed:

Fixes #1066

Requirements:

Notes:
Only updated podController in v1 now.

@JungukCho JungukCho changed the title [NPM] Support graceful shutdown in pod feat: [NPM] Support graceful shutdown in pod Nov 5, 2021
@vakalapa
Copy link
Contributor

vakalapa commented Nov 8, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

vakalapa
vakalapa previously approved these changes Nov 8, 2021
Copy link
Contributor

@huntergregory huntergregory left a comment

Choose a reason for hiding this comment

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

lgtm

rv string
podIP string
labels map[string]string
isHostNewtwork bool
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick typo: extra "w" in name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch

var defaultGracePeriod int64 = 30

type podState struct {
Phase corev1.PodPhase
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: doesn't matter, but is it Go convention to lowercase local struct fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure, but I think it is good to have lowercase.

Copy link
Collaborator

@rbtr rbtr Nov 9, 2021

Choose a reason for hiding this comment

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

it's not "convention", the casing of struct fields has the same syntactic meaning as public/private keywords in other languages.
this is a field in a private type, it should be private (lowercase).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I addressed it in a right way!

nPod.Name == podObj.ObjectMeta.Name &&
nPod.Phase == podObj.Status.Phase &&
nPod.PodIP == podObj.Status.PodIP &&
reflect.DeepEqual(nPod.Labels, podObj.ObjectMeta.Labels) &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't import reflect outside of tests unless you're doing meta-programming. It's expensive to use, and the result of DeepEqual specifically is sometimes (at the worst times) not what you would expect.
NPM can't spare this performance 🥲

Copy link
Contributor Author

@JungukCho JungukCho Nov 9, 2021

Choose a reason for hiding this comment

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

@rbtr Good catch. We also recently found performance issues using reflect. I think this is good staring point to replace reflect from this PR. I will revise them.

@JungukCho
Copy link
Contributor Author

Will replace IsSameLabels with Equals from official K8s in a next PR

@huntergregory huntergregory reopened this Nov 10, 2021
@JungukCho JungukCho merged commit cc68c34 into Azure:master Nov 10, 2021
matmerr pushed a commit to matmerr/azure-container-networking that referenced this pull request Nov 11, 2021
* Support graceful shutdown in pod

* Update detailed comments and cleaning up codes

* Add Unit tests

* Address lint errors

* Address comments

* Addressed comment and add UTs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement npm Related to NPM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPM blocks graceful shutdown connections for pods in Terminating state

4 participants