Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha committed Jun 11, 2021
1 parent e21b4c3 commit ae7d93b
Show file tree
Hide file tree
Showing 7 changed files with 3,720 additions and 9 deletions.
1 change: 1 addition & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func main() {
// Create a new Cmd to provide shared dependencies and start components
options := manager.Options{
Namespace: namespace,
MetricsBindAddress: ":8081",
HealthProbeBindAddress: ":6789",
}

Expand Down
24 changes: 21 additions & 3 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,36 @@ set -x

BASE_DIR=$(cd "$(dirname "$0")"; pwd)

NAMESPACE=$1
NAMESPACE="eclipse-che"
CHE_OPERATOR_IMAGE="quay.io/eclipse/che-operator:nightly"

while [[ "$#" -gt 0 ]]; do
case $1 in
'--namespace'|'-n') NAMESPACE=$2; shift 1;;
'--che-operator-image') CHE_OPERATOR_IMAGE=$2; shift 1;;
esac
shift 1
done

oc apply -f ${BASE_DIR}/deploy/service_account.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/role.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/role_binding.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/cluster_role.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/cluster_role_binding.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/proxy_cluster_role.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/proxy_cluster_role_binding.yaml -n $NAMESPACE

oc apply -f ${BASE_DIR}/deploy/crds/org_v1_che_crd.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/dwco/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/dwco/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml -n $NAMESPACE

# sometimes the operator cannot get CRD right away
sleep 2
sleep 5

# patch and apply operator.yaml
cp ${BASE_DIR}/deploy/operator.yaml /tmp/operator.yaml
yq -riyY "( .spec.template.spec.containers[] | select(.name == \"che-operator\") | .image ) = \"${CHE_OPERATOR_IMAGE}\"" /tmp/operator.yaml
oc apply -f /tmp/operator.yaml -n $NAMESPACE

oc apply -f ${BASE_DIR}/deploy/operator.yaml -n $NAMESPACE
# create CR
oc apply -f ${BASE_DIR}/deploy/crds/org_v1_che_cr.yaml -n $NAMESPACE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions olm/update-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ updateDWCO() {
-o ${ROOT_PROJECT_DIR}/deploy/dwco/devworkspace-che-configmap.ConfigMap.yaml
curl -sL https://raw.githubusercontent.com/che-incubator/devworkspace-che-operator/main/deploy/deployment/openshift/objects/devworkspace-che-controller-manager-metrics-service.Service.yaml \
-o ${ROOT_PROJECT_DIR}/deploy/dwco/devworkspace-che-controller-manager-metrics-service.Service.yaml
curl -sL https://raw.githubusercontent.com/devfile/devworkspace-operator/main/deploy/deployment/openshift/objects/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml
-o ${ROOT_PROJECT_DIR}/deploy/dwco/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml
}

addLicenseHeader() {
Expand Down
6 changes: 2 additions & 4 deletions pkg/deploy/dev-workspace/dev_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (

var (
DevWorkspaceNamespace = "devworkspace-controller"
DevWorkspaceCheNamespace = "devworkspace-che"
DevWorkspaceWebhookName = "controller.devfile.io"
DevWorkspaceServiceAccount = "devworkspace-controller-serviceaccount"
DevWorkspaceDeploymentName = "devworkspace-controller-manager"
Expand Down Expand Up @@ -104,7 +103,6 @@ var (
}

syncDwCheItems = []func(*deploy.DeployContext) (bool, error){
syncDwCheCRD,
synDwCheCR,
syncDwCheConfigMap,
syncDwCheMetricsService,
Expand Down Expand Up @@ -295,7 +293,7 @@ func synDwCheCR(deployContext *deploy.DeployContext) (bool, error) {

obj := &unstructured.Unstructured{}
obj.SetGroupVersionKind(schema.GroupVersionKind{Group: "che.eclipse.org", Version: "v1alpha1", Kind: "CheManager"})
err := deployContext.ClusterAPI.Client.Get(context.TODO(), client.ObjectKey{Name: "devworkspace-che", Namespace: DevWorkspaceCheNamespace}, obj)
err := deployContext.ClusterAPI.Client.Get(context.TODO(), client.ObjectKey{Name: "devworkspace-che", Namespace: deployContext.CheCluster.Namespace}, obj)
if err != nil {
if apierrors.IsNotFound(err) {
obj = nil
Expand All @@ -312,7 +310,7 @@ func synDwCheCR(deployContext *deploy.DeployContext) (bool, error) {
Kind: "CheManager",
})
obj.SetName("devworkspace-che")
obj.SetNamespace(DevWorkspaceCheNamespace)
obj.SetNamespace(deployContext.CheCluster.Namespace)

err = deployContext.ClusterAPI.Client.Create(context.TODO(), obj)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/dev-workspace/dev_workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestReconcileDevWorkspace(t *testing.T) {
t.Run("defaultCheManagerDeployed", func(t *testing.T) {
obj := &unstructured.Unstructured{}
obj.SetGroupVersionKind(schema.GroupVersionKind{Group: "che.eclipse.org", Version: "v1alpha1", Kind: "CheManager"})
err := deployContext.ClusterAPI.Client.Get(context.TODO(), client.ObjectKey{Name: "devworkspace-che", Namespace: DevWorkspaceCheNamespace}, obj)
err := cli.Get(context.TODO(), client.ObjectKey{Name: "devworkspace-che", Namespace: deployContext.CheCluster.Namespace}, obj)
if err != nil {
t.Fatalf("Should have found a CheManager with default config but got an error: %s", err)
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/deploy/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ func CreateIfNotExists(deployContext *DeployContext, blueprint metav1.Object) (b
return false, err
}

logrus.Infof("Creating a new object: %s, name: %s", getObjectType(blueprint), blueprint.GetName())
if blueprint.GetNamespace() == "" {
logrus.Infof("Creating a new object: %s, name: %s", getObjectType(blueprint), blueprint.GetName())
} else {
logrus.Infof("Creating a new object: %s, name: %s, namespace: %s", getObjectType(blueprint), blueprint.GetName(), blueprint.GetNamespace())
}

err = setOwnerReferenceIfNeeded(deployContext, blueprint)
if err != nil {
Expand Down

0 comments on commit ae7d93b

Please sign in to comment.