Skip to content

Conversation

@jaer-tsun
Copy link
Contributor

@jaer-tsun jaer-tsun commented Dec 17, 2019

What this PR does / why we need it:
Adding namespace to npMgr if it doesn't exist. This fixes reboot bug where entries don't get added after failing to append non-existing namespace to all-namespaces.

When NPM reboots, namespace details do not always sync before policies and pods do. In those cases the namespace will need to be added before we proceed with add/update pod/networkpolicy workflow.

@jaer-tsun jaer-tsun changed the title Prevent Namespace Race [DO-NOT-MERGE] Prevent Namespace Race Dec 17, 2019
@jaer-tsun jaer-tsun force-pushed the npmRebootNamespaceRace branch from 7ce6d32 to 8752755 Compare December 17, 2019 21:16
@jaer-tsun jaer-tsun force-pushed the npmRebootNamespaceRace branch from ca08403 to 8752755 Compare December 17, 2019 22:22
@jaer-tsun jaer-tsun changed the title [DO-NOT-MERGE] Prevent Namespace Race Prevent Namespace Race Dec 18, 2019
…where entries don't get added after failing to append non-existing namespace to all-namespaces.
@jaer-tsun jaer-tsun force-pushed the npmRebootNamespaceRace branch from 8752755 to 63dd9d5 Compare December 18, 2019 01:17
matmerr
matmerr previously approved these changes Dec 18, 2019
return nil
}

// AddNamespaceWithLock acquires NetworkPolicyManager lock before adding namespace to ipset
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a cleaner way to do this is to unlock & lock in the caller instead of having this function.

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/Azure/azure-container-networking/pull/461/files/63dd9d5784f75c11d09d573d5274d90a773bd646#diff-88c55b4ac2573a453141838261b6b413R91

AddNamespace used to take a bool to determine that, but having every signature with a bool seemed a bit like an antipattern, but it can be changed back

Copy link
Contributor Author

@jaer-tsun jaer-tsun Dec 19, 2019

Choose a reason for hiding this comment

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

That was the pattern I had it in before. And I don't feel strongly about either to change it back and forth

@jaer-tsun jaer-tsun requested a review from saiyan86 December 19, 2019 23:34
@jaer-tsun jaer-tsun mentioned this pull request Dec 20, 2019
@jaer-tsun jaer-tsun closed this Dec 20, 2019
@jaer-tsun jaer-tsun deleted the npmRebootNamespaceRace branch December 20, 2019 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants