diff --git a/pkg/eventhandler/eventhandlers.go b/pkg/eventhandler/eventhandlers.go index 683bc445..91577dc2 100644 --- a/pkg/eventhandler/eventhandlers.go +++ b/pkg/eventhandler/eventhandlers.go @@ -57,7 +57,6 @@ type K8s interface { jobName string, maxPollDuration time.Duration, pollIntervalInSeconds time.Duration, namespace string, ) error GetLogsOfPod(jobName string, namespace string) (string, error) - ExistsServiceAccount(saName string, namespace string) bool } // EventHandler contains all information needed to process an event @@ -159,15 +158,9 @@ func (eh *EventHandler) startK8sJob(action *config.Action, jsonEventData interfa start: time.Now(), } - // To execute all tasks atomically, we check all images before we start executing a single task of a job - // Additionally we want to check if the job configuration is sound (like validating the specified serviceAccounts) + // To execute all tasks atomically, we check all images + // before we start executing a single task of a job for _, task := range action.Tasks { - - namespace := eh.JobSettings.JobNamespace - if len(task.Namespace) > 0 { - namespace = task.Namespace - } - if !eh.ImageFilter.IsImageAllowed(task.Image) { errorText := fmt.Sprintf("Forbidden: Image %s does not match configured image allowlist.\n", task.Image) @@ -178,17 +171,6 @@ func (eh *EventHandler) startK8sJob(action *config.Action, jsonEventData interfa return } - - if task.ServiceAccount != nil && !eh.K8s.ExistsServiceAccount(*task.ServiceAccount, namespace) { - errorText := fmt.Sprintf("Error: service account %s does not exist!\n", *task.ServiceAccount) - - log.Printf(errorText) - if !action.Silent { - sendTaskFailedEvent(eh.Keptn, task.Name, eh.ServiceName, errors.New(errorText), "") - } - - return - } } for index, task := range action.Tasks { diff --git a/pkg/k8sutils/job.go b/pkg/k8sutils/job.go index 4e712c00..6a69af6a 100644 --- a/pkg/k8sutils/job.go +++ b/pkg/k8sutils/job.go @@ -442,13 +442,3 @@ func (k8s *K8sImpl) generateEnvFromSecret(env config.Env, namespace string) ([]v return generatedEnv, nil } - -// ExistsServiceAccount returns true of the given service account exists in the namespace -func (k8s *K8sImpl) ExistsServiceAccount(saName string, namespace string) bool { - _, err := k8s.clientset.CoreV1().ServiceAccounts(namespace).Get(context.TODO(), saName, metav1.GetOptions{}) - if err != nil { - return false - } - - return true -}