Skip to content

Commit

Permalink
handler: Retry nncp status updated on error (#1269)
Browse files Browse the repository at this point in the history
At node reboot the NNCP get re-apply but nmstate-webhook may not be
ready so it fails, this change add a retry on error at nncp status
update to prevent this. Not that Reconcile cycle is not call since this
is done at a "defer" call.

Signed-off-by: Enrique Llorente <[email protected]>
  • Loading branch information
qinqon authored Oct 8, 2024
1 parent 8506e7b commit 23f88eb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/policyconditions/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import (
)

var (
log = logf.Log.WithName("policyconditions")
log = logf.Log.WithName("policyconditions")
allErrors = func(error) bool { return true }
)

type policyConditionStatus struct {
Expand Down Expand Up @@ -172,8 +173,9 @@ func update(apiWriter client.Client, apiReader client.Reader, policyReader clien
logger := log.WithValues("policy", policyKey.Name)
// On conflict we need to re-retrieve enactments since the
// conflict can denote that the calculated policy conditions
// are now not accurate.
return retry.RetryOnConflict(retry.DefaultRetry, func() error {
// are now not accurate, also at node restart we have to retry en error
// related to certificates until nmstate-webhook pod settles.
return retry.OnError(retry.DefaultRetry, allErrors, func() error {
policy := &nmstatev1.NodeNetworkConfigurationPolicy{}
if err := policyReader.Get(context.TODO(), policyKey, policy); err != nil {
return errors.Wrap(err, "getting policy failed")
Expand Down

0 comments on commit 23f88eb

Please sign in to comment.