Skip to content

Conversation

@rbtr
Copy link
Collaborator

@rbtr rbtr commented Apr 12, 2022

Signed-off-by: Evan Baker rbtr@users.noreply.github.com

Reason for Change:

After init, the PoolMonitor writes the Spec, so it has the target state locally and should not let the NNC updates it receives overwrite that local state.

Issue Fixed:

Requirements:

Notes:

@rbtr rbtr added cns Related to CNS. swift Related to SWIFT networking. fix Fixes something. labels Apr 12, 2022
@rbtr rbtr self-assigned this Apr 12, 2022
@rbtr rbtr requested a review from a team as a code owner April 12, 2022 21:30
@rbtr rbtr requested review from neaggarwMS and rsagasthya and removed request for a team April 12, 2022 21:30
@neaggarwMS
Copy link
Member

neaggarwMS commented Apr 12, 2022

  	pm.spec = nnc.Spec

WE need to put this under ReadLock too?


Refers to: cns/ipampool/monitor.go:98 in efa059e. [](commit_id = efa059e, deletion_comment = False)

Copy link
Member

@neaggarwMS neaggarwMS left a comment

Choose a reason for hiding this comment

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

🕐

@neaggarwMS neaggarwMS dismissed their stale review April 12, 2022 21:38

revoking review

Copy link
Member

@neaggarwMS neaggarwMS left a comment

Choose a reason for hiding this comment

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

🕐

@neaggarwMS
Copy link
Member

pm.clampScaler(&nnc.Status.Scaler)

We need pm.mu.Lock here too as you are updating scaler


Refers to: cns/ipampool/monitor.go:375 in efa059e. [](commit_id = efa059e, deletion_comment = False)

@rbtr rbtr force-pushed the fix/lock-monitor branch from efa059e to 219462e Compare April 13, 2022 00:34
@rbtr rbtr changed the title add mutex to pool monitor to prevent scaling races Don't overwrite Spec in IPAM PoolMonitor from NNC again after initialization Apr 13, 2022
@rbtr rbtr force-pushed the fix/lock-monitor branch from 219462e to 9767e0a Compare April 13, 2022 16:25
}

func (pm *Monitor) reconcile(ctx context.Context) error {
pm.mu.Lock() // lock the monitor to prevent scaling races
Copy link
Member

Choose a reason for hiding this comment

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

Move this to the caller before you read pm.Spec

pm.metastate.minFreeCount, pm.metastate.maxFreeCount = CalculateMinFreeIPs(scaler), CalculateMaxFreeIPs(scaler)
pm.once.Do(func() { close(pm.started) }) // close the init channel the first time we receive a NodeNetworkConfig.
pm.once.Do(func() {
pm.spec = nnc.Spec // set the spec from the NNC initially (afterwards we write the Spec so we know target state).
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a log line here

Copy link
Member

Choose a reason for hiding this comment

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

Also add a log line in func (pm *Monitor) Update(nnc *v1alpha.NodeNetworkConfig) error { function.

@rbtr rbtr force-pushed the fix/lock-monitor branch from 9767e0a to bff17b7 Compare April 13, 2022 22:12
neaggarwMS
neaggarwMS previously approved these changes Apr 13, 2022
@rbtr rbtr enabled auto-merge (squash) April 13, 2022 23:47
… NNC

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
@rbtr rbtr merged commit 31a3b27 into Azure:master Apr 14, 2022
@rbtr rbtr deleted the fix/lock-monitor branch April 14, 2022 15:57
matmerr pushed a commit to matmerr/azure-container-networking that referenced this pull request Jun 29, 2022
… NNC (Azure#1328)

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cns Related to CNS. fix Fixes something. swift Related to SWIFT networking.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants