Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Run DWCO and CO in a same pod but different containers #745

Merged
merged 7 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 42 additions & 23 deletions .github/bin/check-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# Checks if repository resources are up to date:
# - CRDs
# - nightly olm bundle
# - Dockerfile & operator.yaml
# - DW resources

set -e

Expand All @@ -27,24 +29,25 @@ installOperatorSDK() {
if [[ ! -x "${OPERATOR_SDK_BINARY}" ]]; then
OPERATOR_SDK_TEMP_DIR="$(mktemp -q -d -t "OPERATOR_SDK_XXXXXX" 2>/dev/null || mktemp -q -d)"
pushd "${OPERATOR_SDK_TEMP_DIR}" || exit

echo "[INFO] Downloading 'operator-sdk' cli tool..."

OPERATOR_SDK=$(yq -r ".\"operator-sdk\"" "${ROOT_PROJECT_DIR}/REQUIREMENTS")
curl -sLo operator-sdk $(curl -sL https://api.github.com/repos/operator-framework/operator-sdk/releases/tags/${OPERATOR_SDK} | jq -r "[.assets[] | select(.name == \"operator-sdk-${OPERATOR_SDK}-x86_64-linux-gnu\")] | first | .browser_download_url")
export OPERATOR_SDK_BINARY="${OPERATOR_SDK_TEMP_DIR}/operator-sdk"
chmod +x "${OPERATOR_SDK_BINARY}"

echo "[INFO] Downloading completed!"
echo "[INFO] $(${OPERATOR_SDK_BINARY} version)"

popd || exit
fi
}

updateResources() {
export NO_DATE_UPDATE="true"
export NO_INCREMENT="true"

pushd "${ROOT_PROJECT_DIR}" || true
source "${ROOT_PROJECT_DIR}/olm/update-resources.sh"
popd || true
. "${ROOT_PROJECT_DIR}/olm/update-resources.sh"
}

# check_che_types function check first if pkg/apis/org/v1/che_types.go file suffer modifications and
Expand All @@ -63,10 +66,9 @@ checkCRDs() {
local checlusterbackup_CRD_V1BETA1="deploy/crds/org.eclipse.che_checlusterbackups_crd-v1beta1.yaml"
local checlusterrestore_CRD_V1BETA1="deploy/crds/org.eclipse.che_checlusterrestores_crd-v1beta1.yaml"

pushd "${ROOT_PROJECT_DIR}"
source "${ROOT_PROJECT_DIR}/olm/update-resources.sh"

changedFiles=($(git diff --name-only))
changedFiles=(
$(git diff --name-only)
)

# Check if there are any difference in the crds. If yes, then fail check.
if [[ " ${changedFiles[*]} " =~ $checluster_CRD_V1 ]] || [[ " ${changedFiles[*]} " =~ $checluster_CRD_V1BETA1 ]] || \
Expand All @@ -80,7 +82,6 @@ checkCRDs() {
else
echo "[INFO] CRDs files are up to date."
fi
popd
}

checkNightlyOlmBundle() {
Expand All @@ -90,9 +91,9 @@ checkNightlyOlmBundle() {
local CRD_FILE_KUBERNETES="deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/manifests/org_v1_che_crd.yaml"
local CRD_FILE_OPENSHIFT="deploy/olm-catalog/nightly/eclipse-che-preview-openshift/manifests/org_v1_che_crd.yaml"

pushd "${ROOT_PROJECT_DIR}" || true

changedFiles=($(git diff --name-only))
changedFiles=(
$(git diff --name-only)
)
if [[ " ${changedFiles[*]} " =~ $CSV_FILE_OPENSHIFT ]] || [[ " ${changedFiles[*]} " =~ $CSV_FILE_OPENSHIFT ]] || \
[[ " ${changedFiles[*]} " =~ $CRD_FILE_KUBERNETES ]] || [[ " ${changedFiles[*]} " =~ $CRD_FILE_OPENSHIFT ]]; then
echo "[ERROR] Nighlty bundle is not up to date: ${BASH_REMATCH}"
Expand All @@ -101,51 +102,69 @@ checkNightlyOlmBundle() {
else
echo "[INFO] Nightly bundles are up to date."
fi

popd || true
}

checkDockerfile() {
# files to check
local Dockerfile="Dockerfile"

pushd "${ROOT_PROJECT_DIR}" || true

changedFiles=($(git diff --name-only))
changedFiles=(
$(git diff --name-only)
)
if [[ " ${changedFiles[*]} " =~ $Dockerfile ]]; then
echo "[ERROR] Dockerfile is not up to date"
echo "[ERROR] Run 'olm/update-resources.sh' to update Dockerfile"
exit 1
else
echo "[INFO] Dockerfile is up to date."
fi

popd || true
}

checkOperatorYaml() {
# files to check
local OperatorYaml="deploy/operator.yaml"

pushd "${ROOT_PROJECT_DIR}" || true

changedFiles=($(git diff --name-only))
changedFiles=(
$(git diff --name-only)
)
if [[ " ${changedFiles[*]} " =~ $OperatorYaml ]]; then
echo "[ERROR] $OperatorYaml is not up to date"
echo "[ERROR] Run 'olm/update-resources.sh' to update $OperatorYaml"
exit 1
else
echo "[INFO] $OperatorYaml is up to date."
fi
}

popd || true
checkRoles() {
# files to check
local RoleYaml="deploy/role.yaml"
local ClusterRoleYaml="deploy/cluster_role.yaml"
local ProxyClusterRoleYaml="deploy/proxy_cluster_role.yaml"

changedFiles=(
$(git diff --name-only)
)
if [[ " ${changedFiles[*]} " =~ $RoleYaml ]] || [[ " ${changedFiles[*]} " =~ $ClusterRoleYaml ]] || [[ " ${changedFiles[*]} " =~ $ProxyClusterRoleYaml ]]; then
echo "[ERROR] Roles are not up to date: ${BASH_REMATCH}"
echo "[ERROR] Run 'olm/update-resources.sh' to update them."
exit 1
else
echo "[INFO] Roles are up to date."
fi
}

installOperatorSDK

pushd "${ROOT_PROJECT_DIR}" || true

updateResources
checkCRDs
checkRoles
checkNightlyOlmBundle
checkDockerfile
checkOperatorYaml

popd || true

echo "[INFO] Done."
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ COPY --from=builder /che-operator/templates/keycloak-update.sh /tmp/keycloak-upd
COPY --from=builder /che-operator/templates/oauth-provision.sh /tmp/oauth-provision.sh
COPY --from=builder /che-operator/templates/delete-identity-provider.sh /tmp/delete-identity-provider.sh
COPY --from=builder /che-operator/templates/create-github-identity-provider.sh /tmp/create-github-identity-provider.sh

COPY --from=builder /tmp/devworkspace-operator/templates/deploy /tmp/devworkspace-operator/templates
COPY --from=builder /tmp/devworkspace-che-operator/templates/deploy /tmp/devworkspace-che-operator/templates
COPY --from=builder /tmp/restic/restic /usr/local/bin/restic
Expand Down
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
23 changes: 19 additions & 4 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,39 @@
# Red Hat, Inc. - initial API and implementation

set -e
set -x

BASE_DIR=$(cd "$(dirname "$0")"; pwd)
NAMESPACE="eclipse-che"
CHE_OPERATOR_IMAGE="quay.io/eclipse/che-operator:nightly"

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

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
oc apply -f ${BASE_DIR}/deploy/crds/org_v1_che_crd.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/crds/org.eclipse.che_chebackupserverconfigurations_crd.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/crds/org.eclipse.che_checlusterbackups_crd.yaml -n $NAMESPACE
oc apply -f ${BASE_DIR}/deploy/crds/org.eclipse.che_checlusterrestores_crd.yaml -n $NAMESPACE
# sometimes the operator cannot get CRD right away
sleep 2

oc apply -f ${BASE_DIR}/deploy/operator.yaml -n $NAMESPACE
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
oc apply -f ${BASE_DIR}/deploy/crds/org_v1_che_cr.yaml -n $NAMESPACE

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
Loading