Skip to content

Commit

Permalink
Changed timeout value for not yet provisioned configs and added 0-che…
Browse files Browse the repository at this point in the history
…ck for LastUpdate value

Signed-off-by: Patryk Strusiewicz-Surmacki <[email protected]>
  • Loading branch information
p-strusiewiczsurmacki-mobica committed Sep 19, 2024
1 parent 29fb032 commit aea0c3d
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions pkg/reconciler/configrevision_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
controlPlaneLabel = "node-role.kubernetes.io/control-plane"
numOfRefs = 2
configTimeout = time.Minute * 2
preconfigTimeout = time.Minute * 10

numOfDeploymentRetries = 3
)
Expand Down Expand Up @@ -157,20 +158,25 @@ func getRevisionCounters(configs []v1alpha1.NodeNetworkConfig, revision *v1alpha
invalid = 0
for i := range configs {
if configs[i].Spec.Revision == revision.Spec.Revision {
timeout := configTimeout
switch configs[i].Status.ConfigStatus {
case StatusProvisioned:
// Update ready counter
ready++
case StatusInvalid:
// Increase 'invalid' counter so we know that there the revision results in invalid configs.
// Increase 'invalid' counter so we know that the revision results in invalid configs
invalid++
case StatusProvisioning, "":
case "":
// Set longer timeout if status was not yet updated
timeout = preconfigTimeout
fallthrough
case StatusProvisioning:
// Update ongoing counter
ongoing++
if wasConfigTimeoutReached(&configs[i]) {
if wasConfigTimeoutReached(&configs[i], timeout) {
// If timout was reached revision is invalid (but still counts as ongoing).
invalid++
}
case StatusProvisioned:
// Update ready counter
ready++
}
}
}
Expand Down Expand Up @@ -203,8 +209,11 @@ func (crr *ConfigRevisionReconciler) invalidateRevision(ctx context.Context, rev
return nil
}

func wasConfigTimeoutReached(cfg *v1alpha1.NodeNetworkConfig) bool {
return time.Now().After(cfg.Status.LastUpdate.Add(configTimeout))
func wasConfigTimeoutReached(cfg *v1alpha1.NodeNetworkConfig, timeout time.Duration) bool {
if cfg.Status.LastUpdate.IsZero() {
return false
}
return time.Now().After(cfg.Status.LastUpdate.Add(timeout))
}

func getOutdatedNodes(nodes map[string]*corev1.Node, configs []v1alpha1.NodeNetworkConfig, revision *v1alpha1.NetworkConfigRevision) []*corev1.Node {
Expand Down

0 comments on commit aea0c3d

Please sign in to comment.