From 7155b2e1c25078330d2d43c255a97f446b231167 Mon Sep 17 00:00:00 2001 From: Patryk Strusiewicz-Surmacki Date: Thu, 19 Sep 2024 15:48:59 +0200 Subject: [PATCH] Changed timeout value for not yet provisioned configs and added 0-check for LastUpdate value Signed-off-by: Patryk Strusiewicz-Surmacki --- pkg/reconciler/configrevision_reconciler.go | 25 ++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/pkg/reconciler/configrevision_reconciler.go b/pkg/reconciler/configrevision_reconciler.go index a5b66fb..875267b 100644 --- a/pkg/reconciler/configrevision_reconciler.go +++ b/pkg/reconciler/configrevision_reconciler.go @@ -31,6 +31,7 @@ const ( controlPlaneLabel = "node-role.kubernetes.io/control-plane" numOfRefs = 2 configTimeout = time.Minute * 2 + preconfigTimeout = time.Minute * 10 numOfDeploymentRetries = 3 ) @@ -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++ } } } @@ -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 {