From 7a4a7ccd6b409da22688ff9669772952d5e574f8 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Tue, 3 May 2022 09:33:25 +1000 Subject: [PATCH] chore: remove openshift 3.11 support --- apis/lagoon/v1beta1/lagoonbuild_types.go | 2 - controllers/v1beta1/lagoonbuild_controller.go | 9 - controllers/v1beta1/lagoonbuild_helpers.go | 241 ++++-------------- controllers/v1beta1/lagoontask_controller.go | 158 +----------- main.go | 11 - 5 files changed, 59 insertions(+), 362 deletions(-) diff --git a/apis/lagoon/v1beta1/lagoonbuild_types.go b/apis/lagoon/v1beta1/lagoonbuild_types.go index 3691ce35..5afb5d59 100644 --- a/apis/lagoon/v1beta1/lagoonbuild_types.go +++ b/apis/lagoon/v1beta1/lagoonbuild_types.go @@ -53,8 +53,6 @@ type LagoonBuildSpec struct { Pullrequest Pullrequest `json:"pullrequest,omitempty"` Promote Promote `json:"promote,omitempty"` GitReference string `json:"gitReference"` - // @TODO: Openshift should be deprecated as the controller will define if it is openshift or not - // Openshift bool `json:"openshift"` } // LagoonBuildStatus defines the observed state of LagoonBuild diff --git a/controllers/v1beta1/lagoonbuild_controller.go b/controllers/v1beta1/lagoonbuild_controller.go index 339416c7..332cd1c4 100644 --- a/controllers/v1beta1/lagoonbuild_controller.go +++ b/controllers/v1beta1/lagoonbuild_controller.go @@ -31,7 +31,6 @@ import ( lagoonv1beta1 "github.com/uselagoon/remote-controller/apis/lagoon/v1beta1" "github.com/uselagoon/remote-controller/handlers" "github.com/uselagoon/remote-controller/internal/helpers" - // Openshift ) // LagoonBuildReconciler reconciles a LagoonBuild object @@ -42,7 +41,6 @@ type LagoonBuildReconciler struct { EnableMQ bool Messaging *handlers.Messaging BuildImage string - IsOpenshift bool NamespacePrefix string RandomNamespacePrefix bool ControllerNamespace string @@ -228,13 +226,6 @@ func (r *LagoonBuildReconciler) createNamespaceBuild(ctx context.Context, if err != nil { return ctrl.Result{}, err } - // create the service account role binding for openshift to allow promotions in the openshift 3.11 clusters - if r.IsOpenshift && lagoonBuild.Spec.Build.Type == "promote" { - err := r.getOrCreatePromoteSARoleBinding(ctx, lagoonBuild.Spec.Promote.SourceProject, namespace.ObjectMeta.Name) - if err != nil { - return ctrl.Result{}, err - } - } // copy the build resource into a new resource and set the status to pending // create the new resource and the controller will handle it via queue diff --git a/controllers/v1beta1/lagoonbuild_helpers.go b/controllers/v1beta1/lagoonbuild_helpers.go index 8b6e64c3..490f36aa 100644 --- a/controllers/v1beta1/lagoonbuild_helpers.go +++ b/controllers/v1beta1/lagoonbuild_helpers.go @@ -11,7 +11,6 @@ import ( "strings" "time" - "gopkg.in/matryer/try.v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -21,9 +20,6 @@ import ( "github.com/go-logr/logr" lagoonv1beta1 "github.com/uselagoon/remote-controller/apis/lagoon/v1beta1" "github.com/uselagoon/remote-controller/internal/helpers" - - // Openshift - projectv1 "github.com/openshift/api/project/v1" ) var ( @@ -104,7 +100,6 @@ func (r *LagoonBuildReconciler) getOrCreateSARoleBinding(ctx context.Context, sa // getOrCreateNamespace will create the namespace if it doesn't exist. func (r *LagoonBuildReconciler) getOrCreateNamespace(ctx context.Context, namespace *corev1.Namespace, lagoonBuild lagoonv1beta1.LagoonBuild, opLog logr.Logger) error { // parse the project/env through the project pattern, or use the default - var err error ns := helpers.GenerateNamespaceName( lagoonBuild.Spec.Project.NamespacePattern, // the namespace pattern or `openshiftProjectPattern` from Lagoon is never received by the controller lagoonBuild.Spec.Project.Environment, @@ -132,7 +127,6 @@ func (r *LagoonBuildReconciler) getOrCreateNamespace(ctx context.Context, namesp if lagoonBuild.Spec.Project.ProjectIdling != nil { nsLabels["lagoon.sh/projectAutoIdle"] = fmt.Sprintf("%d", *lagoonBuild.Spec.Project.ProjectIdling) } - // if it isn't an openshift build, then just create a normal namespace // add the required lagoon labels to the namespace when creating namespace.ObjectMeta = metav1.ObjectMeta{ Name: ns, @@ -167,37 +161,11 @@ func (r *LagoonBuildReconciler) getOrCreateNamespace(ctx context.Context, namesp } } - // this is an openshift build, then we need to create a projectrequest - // we use projectrequest so that we ensure any openshift specific things can happen. - if r.IsOpenshift { - projectRequest := &projectv1.ProjectRequest{} - projectRequest.ObjectMeta.Name = ns - projectRequest.DisplayName = fmt.Sprintf(`[%s] %s`, lagoonBuild.Spec.Project.Name, lagoonBuild.Spec.Project.Environment) - if err := r.Get(ctx, types.NamespacedName{Name: ns}, namespace); err != nil { - if err := r.Create(ctx, projectRequest); err != nil { - return err - } - } - // once the projectrequest is created, we should wait for the namespace to get created - // this should happen pretty quickly, but if it hasn't happened in a minute it probably failed - // this namespace check will also run to patch existing namespaces with labels when they are re-deployed - err = try.Do(func(attempt int) (bool, error) { - var err error - if err := r.Get(ctx, types.NamespacedName{Name: ns}, namespace); err != nil { - time.Sleep(10 * time.Second) // wait 10 seconds - } - return attempt < 6, err - }) - if err != nil { + // if kubernetes, just create it if it doesn't exist + if err := r.Get(ctx, types.NamespacedName{Name: ns}, namespace); err != nil { + if err := r.Create(ctx, namespace); err != nil { return err } - } else { - // if kubernetes, just create it if it doesn't exist - if err := r.Get(ctx, types.NamespacedName{Name: ns}, namespace); err != nil { - if err := r.Create(ctx, namespace); err != nil { - return err - } - } } // once the namespace exists, then we can patch it with our labels @@ -215,8 +183,8 @@ func (r *LagoonBuildReconciler) getOrCreateNamespace(ctx context.Context, namesp return err } - // if local/regional harbor is enabled, and this is not an openshift 3 cluster - if r.LFFHarborEnabled && !r.IsOpenshift { + // if local/regional harbor is enabled + if r.LFFHarborEnabled { // create the harbor client lagoonHarbor, err := NewHarbor(r.Harbor) if err != nil { @@ -309,6 +277,7 @@ func (r *LagoonBuildReconciler) getCreateOrUpdateSSHKeySecret(ctx context.Contex } // getOrCreatePromoteSARoleBinding will create the rolebinding for openshift promotions to be used by the lagoon-deployer service account. +// @TODO: this role binding can be used as a basis for active/standby tasks allowing one ns to work in another ns func (r *LagoonBuildReconciler) getOrCreatePromoteSARoleBinding(ctx context.Context, sourcens string, ns string) error { viewRoleBinding := &rbacv1.RoleBinding{} viewRoleBinding.ObjectMeta = metav1.ObjectMeta{ @@ -419,13 +388,6 @@ func (r *LagoonBuildReconciler) processBuild(ctx context.Context, opLog logr.Log return err } - if r.IsOpenshift && lagoonBuild.Spec.Build.Type == "promote" { - err := r.getOrCreatePromoteSARoleBinding(ctx, lagoonBuild.Spec.Promote.SourceProject, lagoonBuild.ObjectMeta.Namespace) - if err != nil { - return err - } - } - opLog.Info(fmt.Sprintf("Checking `lagoon-deployer` Token exists: %s", lagoonBuild.ObjectMeta.Name)) var serviceaccountTokenSecret string for _, secret := range serviceAccount.Secrets { @@ -439,31 +401,6 @@ func (r *LagoonBuildReconciler) processBuild(ctx context.Context, opLog logr.Log return fmt.Errorf("Could not find token secret for ServiceAccount lagoon-deployer") } - // openshift uses a builder service account to be able to push images to the openshift registry - // lets load this in exactly the same way an openshift build would - var builderServiceaccountTokenSecret string - if r.IsOpenshift { - builderAccount := &corev1.ServiceAccount{} - err := r.Get(ctx, types.NamespacedName{ - Namespace: lagoonBuild.ObjectMeta.Namespace, - Name: "builder", - }, builderAccount) - if err != nil { - return fmt.Errorf("Could not find ServiceAccount builder") - } - opLog.Info(fmt.Sprintf("Checking `builder` Token exists: %s", lagoonBuild.ObjectMeta.Name)) - for _, secret := range builderAccount.Secrets { - match, _ := regexp.MatchString("^builder-token", secret.Name) - if match { - builderServiceaccountTokenSecret = secret.Name - break - } - } - if builderServiceaccountTokenSecret == "" { - return fmt.Errorf("Could not find token secret for ServiceAccount builder") - } - } - // create the Pod that will do the work podEnvs := []corev1.EnvVar{ { @@ -582,99 +519,58 @@ func (r *LagoonBuildReconciler) processBuild(ctx context.Context, opLog logr.Log Value: r.ProxyConfig.NoProxy, }) } - if r.IsOpenshift { - // openshift builds have different names for some things, and also additional values to add - podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "TYPE", - Value: lagoonBuild.Spec.Build.Type, - }) - podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "SAFE_BRANCH", - Value: lagoonBuild.Spec.Project.Environment, - }) - podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "SAFE_PROJECT", - Value: helpers.MakeSafe(lagoonBuild.Spec.Project.Name), - }) + podEnvs = append(podEnvs, corev1.EnvVar{ + Name: "BUILD_TYPE", + Value: lagoonBuild.Spec.Build.Type, + }) + podEnvs = append(podEnvs, corev1.EnvVar{ + Name: "ENVIRONMENT", + Value: lagoonBuild.Spec.Project.Environment, + }) + podEnvs = append(podEnvs, corev1.EnvVar{ + Name: "KUBERNETES", + Value: lagoonBuild.Spec.Project.DeployTarget, + }) + podEnvs = append(podEnvs, corev1.EnvVar{ + Name: "REGISTRY", + Value: lagoonBuild.Spec.Project.Registry, + }) + // this is enabled by default for now + // eventually will be disabled by default because support for the generation/modification of this will + // be handled by lagoon or the builds themselves + if r.LFFRouterURL { podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "OPENSHIFT_NAME", - Value: lagoonBuild.Spec.Project.DeployTarget, - }) - // this is enabled by default for now - // eventually will be disabled by default because support for the generation/modification of this will - // be handled by lagoon or the builds themselves - if r.LFFRouterURL { - podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "ROUTER_URL", - Value: strings.ToLower( + Name: "ROUTER_URL", + Value: strings.ToLower( + strings.Replace( strings.Replace( - strings.Replace( - lagoonBuild.Spec.Project.RouterPattern, - "${branch}", - lagoonBuild.Spec.Project.Environment, - -1, - ), - "${project}", - lagoonBuild.Spec.Project.Name, + lagoonBuild.Spec.Project.RouterPattern, + "${environment}", + lagoonBuild.Spec.Project.Environment, -1, ), + "${project}", + lagoonBuild.Spec.Project.Name, + -1, ), - }) - } - } else { - podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "BUILD_TYPE", - Value: lagoonBuild.Spec.Build.Type, - }) - podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "ENVIRONMENT", - Value: lagoonBuild.Spec.Project.Environment, - }) - podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "KUBERNETES", - Value: lagoonBuild.Spec.Project.DeployTarget, + ), }) podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "REGISTRY", - Value: lagoonBuild.Spec.Project.Registry, - }) - // this is enabled by default for now - // eventually will be disabled by default because support for the generation/modification of this will - // be handled by lagoon or the builds themselves - if r.LFFRouterURL { - podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "ROUTER_URL", - Value: strings.ToLower( - strings.Replace( - strings.Replace( - lagoonBuild.Spec.Project.RouterPattern, - "${environment}", - lagoonBuild.Spec.Project.Environment, - -1, - ), - "${project}", - lagoonBuild.Spec.Project.Name, - -1, - ), - ), - }) - podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "SHORT_ROUTER_URL", - Value: strings.ToLower( + Name: "SHORT_ROUTER_URL", + Value: strings.ToLower( + strings.Replace( strings.Replace( - strings.Replace( - lagoonBuild.Spec.Project.RouterPattern, - "${environment}", - helpers.ShortName(lagoonBuild.Spec.Project.Environment), - -1, - ), - "${project}", - helpers.ShortName(lagoonBuild.Spec.Project.Name), + lagoonBuild.Spec.Project.RouterPattern, + "${environment}", + helpers.ShortName(lagoonBuild.Spec.Project.Environment), -1, ), + "${project}", + helpers.ShortName(lagoonBuild.Spec.Project.Name), + -1, ), - }) - } + ), + }) } if lagoonBuild.Spec.Build.CI != "" { podEnvs = append(podEnvs, corev1.EnvVar{ @@ -703,29 +599,19 @@ func (r *LagoonBuildReconciler) processBuild(ctx context.Context, opLog logr.Log Name: "PR_TITLE", Value: lagoonBuild.Spec.Pullrequest.Title, }) - if !r.IsOpenshift { - // we don't use PR_NUMBER in openshift builds - podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "PR_NUMBER", - Value: string(lagoonBuild.Spec.Pullrequest.Number), - }) - } + podEnvs = append(podEnvs, corev1.EnvVar{ + Name: "PR_NUMBER", + Value: string(lagoonBuild.Spec.Pullrequest.Number), + }) } if lagoonBuild.Spec.Build.Type == "promote" { podEnvs = append(podEnvs, corev1.EnvVar{ Name: "PROMOTION_SOURCE_ENVIRONMENT", Value: lagoonBuild.Spec.Promote.SourceEnvironment, }) - if r.IsOpenshift { - // openshift does promotions differently - podEnvs = append(podEnvs, corev1.EnvVar{ - Name: "PROMOTION_SOURCE_OPENSHIFT_PROJECT", - Value: lagoonBuild.Spec.Promote.SourceProject, - }) - } } - // if local/regional harbor is enabled, and this is not an openshift 3 cluster - if r.LFFHarborEnabled && !r.IsOpenshift { + // if local/regional harbor is enabled + if r.LFFHarborEnabled { // unmarshal the project variables lagoonProjectVariables := &[]helpers.LagoonEnvironmentVariable{} lagoonEnvironmentVariables := &[]helpers.LagoonEnvironmentVariable{} @@ -959,27 +845,6 @@ func (r *LagoonBuildReconciler) processBuild(ctx context.Context, opLog logr.Log } } - // openshift uses a builder service account to be able to push images to the openshift registry - // load that into the podspec here - if r.IsOpenshift { - newPod.Spec.ServiceAccountName = "builder" - builderToken := corev1.VolumeMount{ - Name: builderServiceaccountTokenSecret, - ReadOnly: true, - MountPath: "/var/run/secrets/kubernetes.io/serviceaccount", - } - builderVolume := corev1.Volume{ - Name: builderServiceaccountTokenSecret, - VolumeSource: corev1.VolumeSource{ - Secret: &corev1.SecretVolumeSource{ - SecretName: builderServiceaccountTokenSecret, - DefaultMode: helpers.IntPtr(420), - }, - }, - } - newPod.Spec.Volumes = append(newPod.Spec.Volumes, builderVolume) - newPod.Spec.Containers[0].VolumeMounts = append(newPod.Spec.Containers[0].VolumeMounts, builderToken) - } opLog.Info(fmt.Sprintf("Checking build pod for: %s", lagoonBuild.ObjectMeta.Name)) // once the pod spec has been defined, check if it isn't already created err = r.Get(ctx, types.NamespacedName{ diff --git a/controllers/v1beta1/lagoontask_controller.go b/controllers/v1beta1/lagoontask_controller.go index 699fafe6..e6de789b 100644 --- a/controllers/v1beta1/lagoontask_controller.go +++ b/controllers/v1beta1/lagoontask_controller.go @@ -33,9 +33,6 @@ import ( lagoonv1beta1 "github.com/uselagoon/remote-controller/apis/lagoon/v1beta1" "github.com/uselagoon/remote-controller/internal/helpers" - - // openshift - oappsv1 "github.com/openshift/api/apps/v1" ) // LagoonTaskReconciler reconciles a LagoonTask object @@ -43,7 +40,6 @@ type LagoonTaskReconciler struct { client.Client Log logr.Logger Scheme *runtime.Scheme - IsOpenshift bool ControllerNamespace string NamespacePrefix string RandomNamespacePrefix bool @@ -129,139 +125,6 @@ func (r *LagoonTaskReconciler) deleteExternalResources(lagoonTask *lagoonv1beta1 return nil } -// get the task pod information for openshift -func (r *LagoonTaskReconciler) getTaskPodDeploymentConfig(ctx context.Context, lagoonTask *lagoonv1beta1.LagoonTask) (*corev1.Pod, error) { - deployments := &oappsv1.DeploymentConfigList{} - listOption := (&client.ListOptions{}).ApplyOptions([]client.ListOption{ - client.InNamespace(lagoonTask.ObjectMeta.Namespace), - }) - err := r.List(ctx, deployments, listOption) - if err != nil { - return nil, fmt.Errorf( - "Unable to get deployments for project %s, environment %s: %v", - lagoonTask.Spec.Project.Name, - lagoonTask.Spec.Environment.Name, - err, - ) - } - if len(deployments.Items) > 0 { - hasService := false - for _, dep := range deployments.Items { - // grab the deployment that contains the task service we want to use - if dep.ObjectMeta.Name == lagoonTask.Spec.Task.Service { - hasService = true - // grab the container - for idx, depCon := range dep.Spec.Template.Spec.Containers { - dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{ - Name: "TASK_API_HOST", - Value: r.getTaskValue(lagoonTask, "TASK_API_HOST"), - }) - dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{ - Name: "TASK_SSH_HOST", - Value: r.getTaskValue(lagoonTask, "TASK_SSH_HOST"), - }) - dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{ - Name: "TASK_SSH_PORT", - Value: r.getTaskValue(lagoonTask, "TASK_SSH_PORT"), - }) - dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{ - Name: "TASK_DATA_ID", - Value: lagoonTask.Spec.Task.ID, - }) - // add proxy variables to builds if they are defined - if r.ProxyConfig.HTTPProxy != "" { - dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{ - Name: "HTTP_PROXY", - Value: r.ProxyConfig.HTTPProxy, - }) - dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{ - Name: "http_proxy", - Value: r.ProxyConfig.HTTPProxy, - }) - } - if r.ProxyConfig.HTTPSProxy != "" { - dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{ - Name: "HTTPS_PROXY", - Value: r.ProxyConfig.HTTPSProxy, - }) - dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{ - Name: "https_proxy", - Value: r.ProxyConfig.HTTPSProxy, - }) - } - if r.ProxyConfig.NoProxy != "" { - dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{ - Name: "NO_PROXY", - Value: r.ProxyConfig.NoProxy, - }) - dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{ - Name: "no_proxy", - Value: r.ProxyConfig.NoProxy, - }) - } - for idx2, env := range depCon.Env { - // remove any cronjobs from the envvars - if env.Name == "CRONJOBS" { - // Shift left one index. - copy(dep.Spec.Template.Spec.Containers[idx].Env[idx2:], dep.Spec.Template.Spec.Containers[idx].Env[idx2+1:]) - // Erase last element (write zero value). - dep.Spec.Template.Spec.Containers[idx].Env[len(dep.Spec.Template.Spec.Containers[idx].Env)-1] = corev1.EnvVar{} - dep.Spec.Template.Spec.Containers[idx].Env = dep.Spec.Template.Spec.Containers[idx].Env[:len(dep.Spec.Template.Spec.Containers[idx].Env)-1] - } - } - dep.Spec.Template.Spec.Containers[idx].Command = []string{"/sbin/tini", - "--", - "/lagoon/entrypoints.sh", - "/bin/sh", - "-c", - lagoonTask.Spec.Task.Command, - } - dep.Spec.Template.Spec.RestartPolicy = "Never" - taskPod := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: lagoonTask.ObjectMeta.Name, - Namespace: lagoonTask.ObjectMeta.Namespace, - Labels: map[string]string{ - "lagoon.sh/jobType": "task", - "lagoon.sh/taskName": lagoonTask.ObjectMeta.Name, - "lagoon.sh/crdVersion": crdVersion, - "lagoon.sh/controller": r.ControllerNamespace, - }, - OwnerReferences: []metav1.OwnerReference{ - { - APIVersion: fmt.Sprintf("%v", lagoonv1beta1.GroupVersion), - Kind: "LagoonTask", - Name: lagoonTask.ObjectMeta.Name, - UID: lagoonTask.UID, - }, - }, - }, - Spec: dep.Spec.Template.Spec, - } - return taskPod, nil - } - } - } - if !hasService { - return nil, fmt.Errorf( - "No matching service %s for project %s, environment %s: %v", - lagoonTask.Spec.Task.Service, - lagoonTask.Spec.Project.Name, - lagoonTask.Spec.Environment.Name, - err, - ) - } - } - // no deployments found return error - return nil, fmt.Errorf( - "No deployments %s for project %s, environment %s: %v", - lagoonTask.ObjectMeta.Namespace, - lagoonTask.Spec.Project.Name, - lagoonTask.Spec.Environment.Name, - err, - ) -} - // get the task pod information for kubernetes func (r *LagoonTaskReconciler) getTaskPodDeployment(ctx context.Context, lagoonTask *lagoonv1beta1.LagoonTask) (*corev1.Pod, error) { deployments := &appsv1.DeploymentList{} @@ -398,21 +261,12 @@ func (r *LagoonTaskReconciler) getTaskPodDeployment(ctx context.Context, lagoonT func (r *LagoonTaskReconciler) createStandardTask(ctx context.Context, lagoonTask *lagoonv1beta1.LagoonTask, opLog logr.Logger) error { newTaskPod := &corev1.Pod{} var err error - // get the podspec from openshift or kubernetes, then get or create a new pod to run the task in - if r.IsOpenshift { - newTaskPod, err = r.getTaskPodDeploymentConfig(ctx, lagoonTask) - if err != nil { - opLog.Info(fmt.Sprintf("%v", err)) - //@TODO: send msg back and update task to failed? - return nil - } - } else { - newTaskPod, err = r.getTaskPodDeployment(ctx, lagoonTask) - if err != nil { - opLog.Info(fmt.Sprintf("%v", err)) - //@TODO: send msg back and update task to failed? - return nil - } + + newTaskPod, err = r.getTaskPodDeployment(ctx, lagoonTask) + if err != nil { + opLog.Info(fmt.Sprintf("%v", err)) + //@TODO: send msg back and update task to failed? + return nil } opLog.Info(fmt.Sprintf("Checking task pod for: %s", lagoonTask.ObjectMeta.Name)) // once the pod spec has been defined, check if it isn't already created diff --git a/main.go b/main.go index 60d69b8d..2d570f1b 100644 --- a/main.go +++ b/main.go @@ -35,10 +35,6 @@ import ( "github.com/uselagoon/remote-controller/handlers" - // Openshift - oappsv1 "github.com/openshift/api/apps/v1" - projectv1 "github.com/openshift/api/project/v1" - "gopkg.in/robfig/cron.v2" lagoonv1beta1 "github.com/uselagoon/remote-controller/apis/lagoon/v1beta1" @@ -64,8 +60,6 @@ func init() { _ = lagoonv1beta1.AddToScheme(scheme) // +kubebuilder:scaffold:scheme - _ = projectv1.AddToScheme(scheme) - _ = oappsv1.AddToScheme(scheme) } func main() { @@ -81,7 +75,6 @@ func main() { var overrideBuildDeployImage string var namespacePrefix string var randomPrefix bool - var isOpenshift bool var controllerNamespace string var enableDebug bool var fastlyServiceID string @@ -184,8 +177,6 @@ func main() { "Enable message queue to provide updates back to Lagoon.") flag.StringVar(&overrideBuildDeployImage, "override-builddeploy-image", "uselagoon/kubectl-build-deploy-dind:latest", "The build and deploy image that should be used by builds started by the controller.") - flag.BoolVar(&isOpenshift, "is-openshift", false, - "Flag to determine if the controller is running in an openshift.") flag.StringVar(&namespacePrefix, "namespace-prefix", "", "The prefix that will be added to all namespaces that are generated, maximum 8 characters. (only used if random-prefix is set false)") flag.BoolVar(&randomPrefix, "random-prefix", false, @@ -657,7 +648,6 @@ func main() { EnableMQ: enableMQ, BuildImage: overrideBuildDeployImage, Messaging: messaging, - IsOpenshift: isOpenshift, NamespacePrefix: namespacePrefix, RandomNamespacePrefix: randomPrefix, ControllerNamespace: controllerNamespace, @@ -723,7 +713,6 @@ func main() { Client: mgr.GetClient(), Log: ctrl.Log.WithName("v1beta1").WithName("LagoonTask"), Scheme: mgr.GetScheme(), - IsOpenshift: isOpenshift, ControllerNamespace: controllerNamespace, NamespacePrefix: namespacePrefix, RandomNamespacePrefix: randomPrefix,