From 57f3fd9176c380e64ad6b5ba832e663a8a398999 Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Wed, 6 Mar 2024 12:26:41 +0100 Subject: [PATCH] Small fixes --- pkg/controllers/bucketController.go | 7 +++++-- pkg/controllers/deploymentController.go | 10 +++++++--- pkg/controllers/eventController.go | 4 +++- pkg/controllers/gitrepositoryController.go | 7 +++++-- pkg/controllers/helmreleaseController.go | 7 +++++-- pkg/controllers/ingressController.go | 10 +++++++--- pkg/controllers/kustomizationController.go | 7 +++++-- pkg/controllers/ocirepositoryController.go | 7 +++++-- pkg/controllers/podController.go | 10 +++++++--- pkg/controllers/serviceController.go | 10 +++++++--- web/src/Service.jsx | 1 + web/src/redux.js | 3 +++ 12 files changed, 60 insertions(+), 23 deletions(-) diff --git a/pkg/controllers/bucketController.go b/pkg/controllers/bucketController.go index b77afd6..183361d 100644 --- a/pkg/controllers/bucketController.go +++ b/pkg/controllers/bucketController.go @@ -5,6 +5,7 @@ import ( "github.com/gimlet-io/capacitor/pkg/flux" "github.com/gimlet-io/capacitor/pkg/streaming" + "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" @@ -35,14 +36,16 @@ func BucketController( case "delete": fluxState, err := flux.State(client, dynamicClient) if err != nil { - panic(err.Error()) + logrus.Warnf("could not get flux state: %s", err) + return nil } fluxStateBytes, err := json.Marshal(streaming.Envelope{ Type: streaming.FLUX_STATE_RECEIVED, Payload: fluxState, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- fluxStateBytes } diff --git a/pkg/controllers/deploymentController.go b/pkg/controllers/deploymentController.go index 2ae2259..fea40c4 100644 --- a/pkg/controllers/deploymentController.go +++ b/pkg/controllers/deploymentController.go @@ -4,6 +4,7 @@ import ( "encoding/json" "github.com/gimlet-io/capacitor/pkg/streaming" + "github.com/sirupsen/logrus" apps_v1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -32,7 +33,8 @@ func DeploymentController( Payload: createdDeployment, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- deploymentBytes case "update": @@ -42,7 +44,8 @@ func DeploymentController( Payload: deployment, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- deploymentBytes case "delete": @@ -51,7 +54,8 @@ func DeploymentController( Payload: informerEvent.key, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- deploymentBytes } diff --git a/pkg/controllers/eventController.go b/pkg/controllers/eventController.go index 6ca1b65..940ad6b 100644 --- a/pkg/controllers/eventController.go +++ b/pkg/controllers/eventController.go @@ -5,6 +5,7 @@ import ( "github.com/gimlet-io/capacitor/pkg/flux" "github.com/gimlet-io/capacitor/pkg/streaming" + "github.com/sirupsen/logrus" v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" @@ -42,7 +43,8 @@ func EventController( Payload: events, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- eventBytes return nil diff --git a/pkg/controllers/gitrepositoryController.go b/pkg/controllers/gitrepositoryController.go index 2f46c13..422794e 100644 --- a/pkg/controllers/gitrepositoryController.go +++ b/pkg/controllers/gitrepositoryController.go @@ -5,6 +5,7 @@ import ( "github.com/gimlet-io/capacitor/pkg/flux" "github.com/gimlet-io/capacitor/pkg/streaming" + "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" @@ -35,14 +36,16 @@ func GitRepositoryController( case "delete": fluxState, err := flux.State(client, dynamicClient) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } fluxStateBytes, err := json.Marshal(streaming.Envelope{ Type: streaming.FLUX_STATE_RECEIVED, Payload: fluxState, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- fluxStateBytes } diff --git a/pkg/controllers/helmreleaseController.go b/pkg/controllers/helmreleaseController.go index ee80b0e..ed49450 100644 --- a/pkg/controllers/helmreleaseController.go +++ b/pkg/controllers/helmreleaseController.go @@ -5,6 +5,7 @@ import ( "github.com/gimlet-io/capacitor/pkg/flux" "github.com/gimlet-io/capacitor/pkg/streaming" + "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" @@ -35,14 +36,16 @@ func HelmReleaseController( case "delete": fluxState, err := flux.State(client, dynamicClient) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } fluxStateBytes, err := json.Marshal(streaming.Envelope{ Type: streaming.FLUX_STATE_RECEIVED, Payload: fluxState, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- fluxStateBytes } diff --git a/pkg/controllers/ingressController.go b/pkg/controllers/ingressController.go index 60fc527..8acb4d8 100644 --- a/pkg/controllers/ingressController.go +++ b/pkg/controllers/ingressController.go @@ -4,6 +4,7 @@ import ( "encoding/json" "github.com/gimlet-io/capacitor/pkg/streaming" + "github.com/sirupsen/logrus" v1 "k8s.io/api/core/v1" networking_v1 "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -32,7 +33,8 @@ func IngressController( Payload: createdIngress, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- ingressBytes case "update": @@ -42,7 +44,8 @@ func IngressController( Payload: ingress, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- ingressBytes case "delete": @@ -51,7 +54,8 @@ func IngressController( Payload: informerEvent.key, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- ingressBytes } diff --git a/pkg/controllers/kustomizationController.go b/pkg/controllers/kustomizationController.go index 8f41bf0..621fa5a 100644 --- a/pkg/controllers/kustomizationController.go +++ b/pkg/controllers/kustomizationController.go @@ -5,6 +5,7 @@ import ( "github.com/gimlet-io/capacitor/pkg/flux" "github.com/gimlet-io/capacitor/pkg/streaming" + "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" @@ -35,14 +36,16 @@ func KustomizeController( case "delete": fluxState, err := flux.State(client, dynamicClient) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } fluxStateBytes, err := json.Marshal(streaming.Envelope{ Type: streaming.FLUX_STATE_RECEIVED, Payload: fluxState, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- fluxStateBytes } diff --git a/pkg/controllers/ocirepositoryController.go b/pkg/controllers/ocirepositoryController.go index 7fc4eb3..ce6e6a6 100644 --- a/pkg/controllers/ocirepositoryController.go +++ b/pkg/controllers/ocirepositoryController.go @@ -5,6 +5,7 @@ import ( "github.com/gimlet-io/capacitor/pkg/flux" "github.com/gimlet-io/capacitor/pkg/streaming" + "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" @@ -35,14 +36,16 @@ func OciRepositoryController( case "delete": fluxState, err := flux.State(client, dynamicClient) if err != nil { - panic(err.Error()) + logrus.Warnf("could not get flux state: %s", err) + return nil } fluxStateBytes, err := json.Marshal(streaming.Envelope{ Type: streaming.FLUX_STATE_RECEIVED, Payload: fluxState, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- fluxStateBytes } diff --git a/pkg/controllers/podController.go b/pkg/controllers/podController.go index fde4f55..0c0b177 100644 --- a/pkg/controllers/podController.go +++ b/pkg/controllers/podController.go @@ -4,6 +4,7 @@ import ( "encoding/json" "github.com/gimlet-io/capacitor/pkg/streaming" + "github.com/sirupsen/logrus" v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" @@ -31,7 +32,8 @@ func PodController( Payload: createdPod, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- podBytes case "update": @@ -41,7 +43,8 @@ func PodController( Payload: pod, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- podBytes case "delete": @@ -50,7 +53,8 @@ func PodController( Payload: informerEvent.key, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- podBytes } diff --git a/pkg/controllers/serviceController.go b/pkg/controllers/serviceController.go index 1a61cf7..6fc28a9 100644 --- a/pkg/controllers/serviceController.go +++ b/pkg/controllers/serviceController.go @@ -4,6 +4,7 @@ import ( "encoding/json" "github.com/gimlet-io/capacitor/pkg/streaming" + "github.com/sirupsen/logrus" v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" @@ -31,7 +32,8 @@ func ServiceController( Payload: createdService, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- serviceBytes case "update": @@ -41,7 +43,8 @@ func ServiceController( Payload: service, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- serviceBytes case "delete": @@ -50,7 +53,8 @@ func ServiceController( Payload: informerEvent.key, }) if err != nil { - panic(err.Error()) + logrus.Warnf("could not marshal event: %s", err) + return nil } clientHub.Broadcast <- serviceBytes } diff --git a/web/src/Service.jsx b/web/src/Service.jsx index bbc1f17..c7e592f 100644 --- a/web/src/Service.jsx +++ b/web/src/Service.jsx @@ -280,6 +280,7 @@ export function Pod(props) { color = 'bg-blue-300'; pulsar = 'animate-pulse'; break; + case 'Succeeded': case 'Terminating': color = 'bg-neutral-500'; pulsar = 'animate-pulse'; diff --git a/web/src/redux.js b/web/src/redux.js index 49f43e3..c5c7891 100644 --- a/web/src/redux.js +++ b/web/src/redux.js @@ -74,6 +74,9 @@ export function rootReducer(state = initialState, action) { case ACTION_SERVICE_DELETED: return serviceEventHandlers.serviceDeleted(state, action.payload) default: + if (action.type && action.type.startsWith('@@redux/INIT')) { // Ignoring Redux ActionTypes.INIT action + return state + } console.log('Could not process redux event: ' + JSON.stringify(action)); return state; }