From f2892208c124891c66bc0bfbf1f0e8920359c4cf Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 6 Mar 2024 17:50:52 -0500 Subject: [PATCH] fix: handle case where keda isn't installed properly If keda is not installed, warn the user that it isn't installed and ignore the rest. Ignoring the error here is fine as it gives the user context but doesn't block a deploy. --- plugins/scheduler-k3s/functions.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/scheduler-k3s/functions.go b/plugins/scheduler-k3s/functions.go index df3decc37..ac30f5626 100644 --- a/plugins/scheduler-k3s/functions.go +++ b/plugins/scheduler-k3s/functions.go @@ -19,10 +19,12 @@ import ( "github.com/dokku/dokku/plugins/common" nginxvhosts "github.com/dokku/dokku/plugins/nginx-vhosts" resty "github.com/go-resty/resty/v2" + kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1" "golang.org/x/sync/errgroup" "gopkg.in/yaml.v3" corev1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" + k8serrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" @@ -686,7 +688,14 @@ func getKedaValues(ctx context.Context, clientset KubernetesClient, appName stri items, err := clientset.ListClusterTriggerAuthentications(ctx, ListClusterTriggerAuthenticationsInput{}) if err != nil { - return GlobalKedaValues{}, fmt.Errorf("Error listing cluster trigger authentications: %w", err) + if !k8serrors.IsNotFound(err) { + return GlobalKedaValues{}, fmt.Errorf("Error listing cluster trigger authentications: %w", err) + } + + common.LogWarn(fmt.Sprintf("Error listing cluster trigger authentications: %v", err)) + common.LogWarn("Continuing with no cluster trigger authentications") + common.LogWarn("This may be due to the keda helm chart not being installed") + items = []kedav1alpha1.ClusterTriggerAuthentication{} } globalAuths := map[string]KedaAuthentication{}