diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 717df15c03..1b8a576800 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -345,9 +345,10 @@ deployDevWorkspaceController() { waitDevWorkspaceControllerStarted() { n=0 - while [ $n -le 24 ] # 2 minutes + while [ $n -le 120 ] do webhooks=$(oc get mutatingWebhookConfiguration --all-namespaces) + echo "[INFO] Webhooks: ${webhooks}" if [[ $webhooks =~ .*controller.devfile.io.* ]]; then echo "[INFO] Dev Workspace controller has been deployed" return @@ -367,9 +368,10 @@ createWorksaceDevWorkspaceController () { waitWorkspaceStartedDevWorkspaceController() { n=0 - while [ $n -le 24 ] # 2 minutes + while [ $n -le 120 ] do pods=$(oc get pods -n default) + echo "[INFO] Pod status: ${pods}" if [[ $pods =~ .*Running.* ]]; then echo "[INFO] Wokrspace started succesfully" return diff --git a/pkg/deploy/dev-workspace/dev_workspace.go b/pkg/deploy/dev-workspace/dev_workspace.go index 7e7a879065..0ef6a84855 100644 --- a/pkg/deploy/dev-workspace/dev_workspace.go +++ b/pkg/deploy/dev-workspace/dev_workspace.go @@ -60,7 +60,7 @@ var ( // cachedObjects cachedObj = make(map[string]metav1.Object) syncItems = []func(*deploy.DeployContext) (bool, error){ - syncNamespace, + createNamespace, syncServiceAccount, syncClusterRole, syncProxyClusterRole, @@ -134,8 +134,19 @@ func checkWebTerminalSubscription(deployContext *deploy.DeployContext) error { return errors.New("A non matching version of the Dev Workspace operator is already installed") } -func syncNamespace(deployContext *deploy.DeployContext) (bool, error) { - return deploy.CreateNamespace(deployContext, DevWorkspaceNamespace) +func createNamespace(deployContext *deploy.DeployContext) (bool, error) { + namespace := &corev1.Namespace{ + TypeMeta: metav1.TypeMeta{ + Kind: "Namespace", + APIVersion: corev1.SchemeGroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: DevWorkspaceNamespace, + }, + Spec: corev1.NamespaceSpec{}, + } + + return deploy.CreateIfNotExists(deployContext, namespace) } func syncServiceAccount(deployContext *deploy.DeployContext) (bool, error) { diff --git a/pkg/deploy/namespace.go b/pkg/deploy/namespace.go deleted file mode 100644 index c3305a295a..0000000000 --- a/pkg/deploy/namespace.go +++ /dev/null @@ -1,72 +0,0 @@ -// -// Copyright (c) 2021 Red Hat, Inc. -// This program and the accompanying materials are made -// available under the terms of the Eclipse Public License 2.0 -// which is available at https://www.eclipse.org/legal/epl-2.0/ -// -// SPDX-License-Identifier: EPL-2.0 -// -// Contributors: -// Red Hat, Inc. - initial API and implementation -// -package deploy - -import ( - "context" - - "github.com/sirupsen/logrus" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" -) - -func CreateNamespace(deployContext *DeployContext, name string) (bool, error) { - namespace, err := GetNamespace(deployContext, name) - if err != nil { - return false, err - } - - if namespace == nil { - namespaceSpec := GetNamespaceSpec(deployContext, name) - logrus.Infof("Creating a new object: %s, name %s", namespaceSpec.Kind, namespaceSpec.Name) - err = deployContext.ClusterAPI.NonCachedClient.Create(context.TODO(), namespaceSpec) - if !errors.IsAlreadyExists(err) { - return false, err - } - return false, nil - } - - return true, nil -} - -func GetNamespace(deployContext *DeployContext, name string) (*corev1.Namespace, error) { - namespace := &corev1.Namespace{} - namespacedName := types.NamespacedName{ - Name: name, - } - - err := deployContext.ClusterAPI.NonCachedClient.Get(context.TODO(), namespacedName, namespace) - if err != nil { - if errors.IsNotFound(err) { - return nil, nil - } - return nil, err - } - return namespace, nil -} - -func GetNamespaceSpec(deployContext *DeployContext, name string) *corev1.Namespace { - namespace := &corev1.Namespace{ - TypeMeta: metav1.TypeMeta{ - Kind: "Namespace", - APIVersion: corev1.SchemeGroupVersion.String(), - }, - ObjectMeta: metav1.ObjectMeta{ - Name: name, - }, - Spec: corev1.NamespaceSpec{}, - } - - return namespace -}