From f224f81995396ce3d13e635ca1014ec1e29b8600 Mon Sep 17 00:00:00 2001 From: Blaize M Kaye Date: Thu, 20 Jul 2023 05:36:46 +1200 Subject: [PATCH 1/3] Changes error logic --- controllers/namespace_controller.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/namespace_controller.go b/controllers/namespace_controller.go index 522e09d..f2cbfe6 100644 --- a/controllers/namespace_controller.go +++ b/controllers/namespace_controller.go @@ -92,15 +92,15 @@ func (r *NamespaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( // let's verify this to make sure it looks good if val, ok := v.Data["INSIGHTS_TOKEN"]; ok { namespaceDetails, err := tokens.ValidateAndExtractNamespaceDetailsFromToken(r.InsightsJWTSecret, string(val)) - if err != nil { - log.Error(err, "Unable to decode token") - return ctrl.Result{}, err + // If we can't validate this secret, we should really just recreate it + deleteSecretMessage = fmt.Sprintf("Token is invalid - namespaces '%v'!='%v'.", ns.GetName(), namespaceDetails.Namespace) } - if namespaceDetails.Namespace != ns.GetName() { + if deleteSecretMessage != "" && namespaceDetails.Namespace != ns.GetName() { deleteSecretMessage = fmt.Sprintf("Token is invalid - namespaces '%v'!='%v'.", ns.GetName(), namespaceDetails.Namespace) + } else { + foundItem = true } - foundItem = true } else { //we delete this secret straight deleteSecretMessage = "key INSIGHTS_TOKEN does not exist. Secret is invalid." From 09321885c7d867e16495f18724002f6063cbe266 Mon Sep 17 00:00:00 2001 From: Blaize M Kaye Date: Thu, 20 Jul 2023 13:39:02 +1200 Subject: [PATCH 2/3] Some debugging info --- internal/service/service.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/service/service.go b/internal/service/service.go index dc000eb..1bad7c0 100644 --- a/internal/service/service.go +++ b/internal/service/service.go @@ -62,6 +62,8 @@ func (r *routerInstance) writeFacts(c *gin.Context) { return } + fmt.Println(details) + //let's force our facts to get pushed to the right place lid, err := strconv.ParseInt(namespace.EnvironmentId, 10, 32) if err != nil { From adeb29b4c2eab11ebe2cb6fc18e44094469ab328 Mon Sep 17 00:00:00 2001 From: Blaize M Kaye Date: Fri, 18 Aug 2023 11:37:04 +1200 Subject: [PATCH 3/3] Removes print --- internal/service/service.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/service/service.go b/internal/service/service.go index 1bad7c0..dc000eb 100644 --- a/internal/service/service.go +++ b/internal/service/service.go @@ -62,8 +62,6 @@ func (r *routerInstance) writeFacts(c *gin.Context) { return } - fmt.Println(details) - //let's force our facts to get pushed to the right place lid, err := strconv.ParseInt(namespace.EnvironmentId, 10, 32) if err != nil {