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 6c20e16 commit 4202883
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 82 deletions.
9 changes: 3 additions & 6 deletions .github/bin/check-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,11 @@ checkOperatorYaml() {

checkDW() {
# files to check
local CHEMANAGER_CRD="deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml"
local DWROUTINGS_CRD="deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"
local CWCO_CONFIGMAP="deploy/dev-workspace/devworkspace-che-configmap.ConfigMap.yaml"
local DWCO_SERVICE="deploy/dev-workspace/devworkspace-che-controller-manager-metrics-service.Service.yaml"
local CHEMANAGER_CRD="deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml"
local DWROUTINGS_CRD="deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"

changedFiles=($(git diff --name-only))
if [[ " ${changedFiles[*]} " =~ $CHEMANAGER_CRD ]] || [[ " ${changedFiles[*]} " =~ $CWCO_CONFIGMAP ]] || \
[[ " ${changedFiles[*]} " =~ $DWCO_SERVICE ]] || [[ " ${changedFiles[*]} " =~ $DWROUTINGS_CRD ]]; then
if [[ " ${changedFiles[*]} " =~ $CHEMANAGER_CRD ]] || [[ " ${changedFiles[*]} " =~ $DWROUTINGS_CRD ]]; then
echo "[ERROR] DWCO resources are not up to date: ${BASH_REMATCH}"
echo "[ERROR] Run 'olm/update-resources.sh' to download them."
exit 1
Expand Down
26 changes: 7 additions & 19 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,31 @@ while [[ "$#" -gt 0 ]]; do
case $1 in
'--namespace'|'-n') NAMESPACE=$2; shift 1;;
'--che-operator-image') CHE_OPERATOR_IMAGE=$2; shift 1;;
'--logs') LOGS=true;
'--logs') LOGS=true;;
esac
shift 1
done

echo "[INFO] Deploying Eclipse Che in namespace: "$NAMESPACE
set +e; oc create namespace $ECLIPSE_CHE_NAMESPACE; set -e

echo "[INFO] Creating SA roles and clusterroles"

set +e; oc create namespace $NAMESPACE; set -e
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

echo "[INFO] Creating Custom Resource Difinition"

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

echo "[INFO] Creating operator deployment, image: "$CHE_OPERATOR_IMAGE

cp -f ${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

echo "[INFO] Creating Custom Resource"

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

if [[ $LOGS == true ]]; then
echo "[INFO] Start printing logs"
oc logs $(oc get pods -o json -n $NAMESPACE | jq -r '.items[] | select(.metadata.name | test("che-operator-")).metadata.name') -n $NAMESPACE --all-containers
echo "[INFO] Start printing logs..."
oc wait --for=condition=ready pod -l app.kubernetes.io/component=che-operator -n $NAMESPACE --timeout=60s
oc logs $(oc get pods -o json -n $NAMESPACE | jq -r '.items[] | select(.metadata.name | test("che-operator-")).metadata.name') -n $NAMESPACE --all-containers -f
fi

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
role-paths: [ "deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/generated/roles/role.yaml", "deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/generated/roles/cluster_role.yaml", "deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/generated/roles/proxy_cluster_role.yaml"]
operator-path: deploy/operator.yaml
crd-cr-paths: ["deploy/crds/org_v1_che_crd.yaml", "deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml", deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"]
crd-cr-paths: ["deploy/crds/org_v1_che_crd.yaml", "deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml", deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
operator-path: deploy/operator.yaml
role-paths: [ "deploy/olm-catalog/nightly/eclipse-che-preview-openshift/generated/roles/role.yaml", "deploy/olm-catalog/nightly/eclipse-che-preview-openshift/generated/roles/cluster_role.yaml", "deploy/olm-catalog/nightly/eclipse-che-preview-openshift/generated/roles/proxy_cluster_role.yaml"]
crd-cr-paths: ["deploy/crds/org_v1_che_crd.yaml", "deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml", "deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"]
crd-cr-paths: ["deploy/crds/org_v1_che_crd.yaml", "deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml", "deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"]
1 change: 0 additions & 1 deletion deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ spec:
app.kubernetes.io/name: che
app.kubernetes.io/instance: che
app.kubernetes.io/component: che-operator
control-plane: controller-manager
spec:
containers:
- name: che-operator
Expand Down
9 changes: 2 additions & 7 deletions local-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ command -v operator-sdk >/dev/null 2>&1 || { echo "operator-sdk is not installed
ECLIPSE_CHE_NAMESPACE="eclipse-che"
ECLIPSE_CHE_CR="./deploy/crds/org_v1_che_cr.yaml"
ECLIPSE_CHE_CRD="./deploy/crds/org_v1_che_crd.yaml"
ECLIPSE_CHE_MANAGER_CRD="./deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml"
ECLIPSE_CHE_DWROUTING_CRD="./deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"
ECLIPSE_CHE_MANAGER_CRD="./deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml"
ECLIPSE_CHE_DWROUTING_CRD="./deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"
DEV_WORKSPACE_CONTROLLER_VERSION="main"
DEV_WORKSPACE_CHE_OPERATOR_VERSION="main"

Expand Down Expand Up @@ -69,11 +69,6 @@ prepareTemplates() {
cp -rf /tmp/devfile-devworkspace-operator*/deploy/* /tmp/devworkspace-operator/templates

echo "[INFO] Downloading Dev Workspace operator templates completed."

# Copy Dev Workspace Che operator templates
rm -rf /tmp/devworkspace-che-operator/
mkdir -p /tmp/devworkspace-che-operator/templates
cp -rf deploy/dev-workspace/* /tmp/devworkspace-che-operator/templates
}

createNamespace() {
Expand Down
16 changes: 6 additions & 10 deletions olm/update-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ updateNighltyBundle() {
# copy CR/CRD
cp -f "${ROOT_PROJECT_DIR}/deploy/crds/org_v1_che_cr.yaml" "${generateFolder}/crds"
cp -f "${ROOT_PROJECT_DIR}/deploy/crds/org_v1_che_crd.yaml" "${generateFolder}/crds"
cp -f "${ROOT_PROJECT_DIR}/deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml" "${generateFolder}/crds"
cp -f "${ROOT_PROJECT_DIR}/deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml" "${generateFolder}/crds"
cp -f "${ROOT_PROJECT_DIR}/deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml" "${generateFolder}/crds"
cp -f "${ROOT_PROJECT_DIR}/deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml" "${generateFolder}/crds"

# generate a new CSV
"${OPERATOR_SDK_BINARY}" generate csv \
Expand All @@ -172,8 +172,8 @@ updateNighltyBundle() {


cp -f "${ROOT_PROJECT_DIR}/deploy/crds/org_v1_che_crd.yaml" "${NIGHTLY_BUNDLE_PATH}/manifests"
cp -f "${ROOT_PROJECT_DIR}/deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml" "${NIGHTLY_BUNDLE_PATH}/manifests"
cp -f "${ROOT_PROJECT_DIR}/deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml" "${NIGHTLY_BUNDLE_PATH}/manifests"
cp -f "${ROOT_PROJECT_DIR}/deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml" "${NIGHTLY_BUNDLE_PATH}/manifests"
cp -f "${ROOT_PROJECT_DIR}/deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml" "${NIGHTLY_BUNDLE_PATH}/manifests"

CRD="${NIGHTLY_BUNDLE_PATH}/manifests/org_v1_che_crd.yaml"
if [[ $platform == "openshift" ]]; then
Expand Down Expand Up @@ -243,13 +243,9 @@ updateNighltyBundle() {
updateDW() {
echo "[INFO] Downloading DevWorkspace resources"
curl -sL https://raw.githubusercontent.com/che-incubator/devworkspace-che-operator/main/deploy/deployment/openshift/objects/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml \
-o ${ROOT_PROJECT_DIR}/deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml
curl -sL https://raw.githubusercontent.com/che-incubator/devworkspace-che-operator/main/deploy/deployment/openshift/objects/devworkspace-che-configmap.ConfigMap.yaml \
-o ${ROOT_PROJECT_DIR}/deploy/dev-workspace/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/dev-workspace/devworkspace-che-controller-manager-metrics-service.Service.yaml
-o ${ROOT_PROJECT_DIR}/deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.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/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml
-o ${ROOT_PROJECT_DIR}/deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml
}

addLicenseHeader() {
Expand Down
12 changes: 8 additions & 4 deletions pkg/deploy/dev-workspace/dev_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ var (
DevWorkspaceConfigMapFile = DevWorkspaceTemplates + "/devworkspace-controller-configmap.ConfigMap.yaml"
DevWorkspaceDeploymentFile = DevWorkspaceTemplates + "/devworkspace-controller-manager.Deployment.yaml"

DevWorkspaceCheConfigMapFile = DevWorkspaceCheTemplates + "/devworkspace-che-configmap.ConfigMap.yaml"
DevWorkspaceCheMetricsServiceFile = DevWorkspaceCheTemplates + "/devworkspace-che-controller-manager-metrics-service.Service.yaml"

WebTerminalOperatorSubscriptionName = "web-terminal"
WebTerminalOperatorNamespace = "openshift-operators"
)
Expand Down Expand Up @@ -103,7 +100,6 @@ var (

syncDwCheItems = []func(*deploy.DeployContext) (bool, error){
synDwCheCR,
syncDwCheConfigMap,
syncDwCheMetricsService,
}
)
Expand Down Expand Up @@ -303,6 +299,14 @@ func synDwCheCR(deployContext *deploy.DeployContext) (bool, error) {

if obj == nil {
obj := &unstructured.Unstructured{}
if !util.IsOpenShift {
obj.SetUnstructuredContent(map[string]interface{}{
"spec": map[string]interface{}{
"gatewayHost": deployContext.CheCluster.Spec.K8s.IngressDomain,
"k8s": map[string]interface{}{},
},
})
}
obj.SetGroupVersionKind(schema.GroupVersionKind{
Group: "che.eclipse.org",
Version: "v1alpha1",
Expand Down
4 changes: 2 additions & 2 deletions pkg/deploy/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
CheServiceName = "che-host"
)

var ServiceDefaultDiffOpts = cmp.Options{
var DefaultServiceDiffOpts = cmp.Options{
cmpopts.IgnoreFields(corev1.Service{}, "TypeMeta", "ObjectMeta"),
cmp.Comparer(func(x, y corev1.ServiceSpec) bool {
return cmp.Equal(x.Ports, y.Ports, cmpopts.IgnoreFields(corev1.ServicePort{}, "TargetPort", "NodePort")) &&
Expand All @@ -45,7 +45,7 @@ func SyncServiceToCluster(
}

func SyncServiceSpecToCluster(deployContext *DeployContext, serviceSpec *corev1.Service) (bool, error) {
return Sync(deployContext, serviceSpec, ServiceDefaultDiffOpts)
return Sync(deployContext, serviceSpec, DefaultServiceDiffOpts)
}

func GetServiceSpec(
Expand Down
6 changes: 1 addition & 5 deletions pkg/deploy/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,7 @@ func CreateIfNotExists(deployContext *DeployContext, blueprint metav1.Object) (b
return false, err
}

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())
}
logrus.Infof("Creating a new object: %s, name: %s", getObjectType(blueprint), blueprint.GetName())

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

0 comments on commit 4202883

Please sign in to comment.