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

Add liveness and readiness probes #610

Merged
merged 12 commits into from
Jan 8, 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ source "${OPERATOR_REPO}"/.github/bin/common.sh
trap "catchFinish" EXIT SIGINT

prepareTemplates() {
disableOpenShiftOAuth ${TEMPLATES}
disableUpdateAdminPassword ${TEMPLATES}
setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE}
setServerExposureStrategy ${TEMPLATES} "single-host"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ source "${OPERATOR_REPO}"/.github/bin/common.sh
trap "catchFinish" EXIT SIGINT

prepareTemplates() {
disableOpenShiftOAuth ${TEMPLATES}
disableUpdateAdminPassword ${TEMPLATES}
setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE}
setServerExposureStrategy ${TEMPLATES} "single-host"
Expand Down
46 changes: 46 additions & 0 deletions .github/bin/minikube/test-operator-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
#
# Copyright (c) 2020 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

set -e
set -x

# Get absolute path for root repo directory from github actions context: https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions
export OPERATOR_REPO="${GITHUB_WORKSPACE}"
source "${OPERATOR_REPO}"/.github/bin/common.sh

# Stop execution on any error
trap "catchFinish" EXIT SIGINT

prepareTemplates() {
disableUpdateAdminPassword ${LAST_OPERATOR_TEMPLATE}
setIngressDomain ${LAST_OPERATOR_TEMPLATE} "$(minikube ip).nip.io"
setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE}
}

runTest() {
deployEclipseChe "operator" "minikube" "quay.io/eclipse/che-operator:${LAST_PACKAGE_VERSION}" ${LAST_OPERATOR_TEMPLATE}
createWorkspace

updateEclipseChe ${OPERATOR_IMAGE} ${TEMPLATES}
waitEclipseCheDeployed "nightly"

startExistedWorkspace
waitWorkspaceStart
}

init
initLatestTemplates
initStableTemplates "kubernetes" "stable"
prepareTemplates
buildCheOperatorImage
copyCheOperatorImageToMinikube
runTest
46 changes: 46 additions & 0 deletions .github/bin/minishift/test-operator-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
#
# Copyright (c) 2020 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

set -e
set -x

# Get absolute path for root repo directory from github actions context: https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions
export OPERATOR_REPO="${GITHUB_WORKSPACE}"
source "${OPERATOR_REPO}"/.github/bin/common.sh

# Stop execution on any error
trap "catchFinish" EXIT SIGINT

prepareTemplates() {
disableOpenShiftOAuth ${LAST_OPERATOR_TEMPLATE}
disableUpdateAdminPassword ${LAST_OPERATOR_TEMPLATE}
setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE}
}

runTest() {
deployEclipseChe "operator" "minishift" "quay.io/eclipse/che-operator:${LAST_PACKAGE_VERSION}" ${LAST_OPERATOR_TEMPLATE}
createWorkspace

updateEclipseChe ${OPERATOR_IMAGE} ${TEMPLATES}
waitEclipseCheDeployed "nightly"

startExistedWorkspace
waitWorkspaceStart
}

init
installYq
initLatestTemplates
initStableTemplates "openshift" "stable"
prepareTemplates
copyCheOperatorImageToMinishift
runTest
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install jq
run: sudo pip install yq
- name: Run tests
run: /bin/bash .github/bin/minikube/test-latest-olm.sh
run: /bin/bash .github/bin/minikube/test-olm.sh
# Run this step even the previous step fail
- uses: actions/upload-artifact@v2
if: ${{ always() }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install jq
run: sudo pip install yq
- name: Run tests
run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-gateway.sh
run: /bin/bash .github/bin/minikube/test-operator-singlehost-gateway.sh
# Run this step even the previous step fail to upload artifacts to GH
- uses: actions/upload-artifact@v2
if: ${{ always() }}
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Install jq
run: sudo pip install yq
- name: Run tests
run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-native.sh
run: /bin/bash .github/bin/minikube/test-operator-singlehost-native.sh
# Run this step even the previous step fail to upload artifacts to GH
- uses: actions/upload-artifact@v2
if: ${{ always() }}
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/minikube-operator-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Copyright (c) 2012-2020 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
#

name: Minikube
on:
pull_request:
branches:
- master
jobs:
minikube:
name: Test Eclipse Che update from stable to nightly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Provision Minikube cluster
run: /bin/bash .github/bin/minikube/provision-cluster.sh
- name: Install chectl
run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=stable
- name: Install jq
run: sudo pip install yq
- name: Tests
run: /bin/bash .github/bin/minikube/test-operator-update.sh
# Run this step even the previous step fail
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: minikube-updates-artifacts
path: /tmp/artifacts-che
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install jq
run: sudo pip install yq
- name: Run tests
run: /bin/bash .github/bin/minikube/test-update-olm.sh
run: /bin/bash .github/bin/minikube/test-stable-olm-update.sh
# Run this step even the previous step fail
- uses: actions/upload-artifact@v2
if: ${{ always() }}
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/minishift-operator-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
# Copyright (c) 2012-2020 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
#

name: Minishift
on:
pull_request:
branches:
- master
jobs:
minishift:
name: Test Eclipse Che update from stable to nightly
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: Build Che operator image
run: |
export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test
# coreutils provides a readlink that supports `-f`

brew install coreutils docker docker-machine

mkdir -p ~/.docker/machine/cache/
sudo curl -Lo ~/.docker/machine/cache/boot2docker.iso https://github.com/boot2docker/boot2docker/releases/download/v19.03.12/boot2docker.iso

docker-machine --github-api-token="${{ secrets.GITHUB_TOKEN }}" create --driver virtualbox default
eval "$(docker-machine env default)"
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . && docker save "${OPERATOR_IMAGE}" > operator.tar

docker-machine stop
- name: Provision Minishift cluster
run: |
brew cask install minishift
export MINISHIFT_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }}
minishift start --memory=5500 --vm-driver=virtualbox
- name: Install chectl
run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=stable
- name: Install jq
run: sudo pip install yq
- name: Replace Minishift default certificates
run: /bin/bash .github/bin/minishift/certs.sh
- name: Tests
run: |
eval $(minishift oc-env)
/bin/bash .github/bin/minishift/test-operator-update.sh
# Run this step even the previous step fail
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: minishift-updates-artifacts
path: /tmp/artifacts-che
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Run tests
run: |
eval $(minishift oc-env)
/bin/bash .github/bin/minishift/test-latest-operator.sh
/bin/bash .github/bin/minishift/test-operator.sh
# Run this step even the previous step fail
- uses: actions/upload-artifact@v2
if: ${{ always() }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Update minishift deprecated certificates and run e2e
run: |
eval $(minishift oc-env)
/bin/bash .github/bin/minishift/test-update-operator.sh
/bin/bash .github/bin/minishift/test-stable-operator-update.sh
# Run this step even the previous step fail
- uses: actions/upload-artifact@v2
if: ${{ always() }}
Expand Down
17 changes: 13 additions & 4 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
sdkVersion "github.com/operator-framework/operator-sdk/version"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
)
Expand Down Expand Up @@ -103,9 +104,6 @@ func main() {
os.Exit(1)
}

// Become the leader before proceeding
leader.Become(context.TODO(), "che-operator-lock")

r := ready.NewFileReady()
err = r.Set()
if err != nil {
Expand All @@ -114,10 +112,15 @@ func main() {
}
defer r.Unset()

// Become the leader before proceeding
leader.Become(context.TODO(), "che-operator-lock")

// Create a new Cmd to provide shared dependencies and start components
options := manager.Options{
Namespace: namespace,
Namespace: namespace,
HealthProbeBindAddress: ":6789",
}

mgr, err := manager.New(cfg, options)
if err != nil {
log.Error(err, "")
Expand Down Expand Up @@ -158,6 +161,12 @@ func main() {
os.Exit(1)
}

// Setup health checks
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
log.Error(err, "Unable to set up health check")
os.Exit(1)
}

logrus.Info("Starting the Cmd")

// Start the Cmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ metadata:
categories: Developer Tools
certified: "false"
containerImage: quay.io/eclipse/che-operator:nightly
createdAt: "2021-01-08T12:41:34Z"
createdAt: "2021-01-08T14:09:35Z"
description: A Kube-native development solution that delivers portable and collaborative
developer workspaces.
operatorframework.io/suggested-namespace: eclipse-che
repository: https://github.com/eclipse/che-operator
support: Eclipse Foundation
name: eclipse-che-preview-kubernetes.v7.24.0-64.nightly
name: eclipse-che-preview-kubernetes.v7.25.0-66.nightly
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -291,7 +291,8 @@ spec:
selector:
matchLabels:
app: che-operator
strategy: {}
strategy:
type: RollingUpdate
template:
metadata:
labels:
Expand Down Expand Up @@ -357,10 +358,29 @@ spec:
value: ca-certs
image: quay.io/eclipse/che-operator:nightly
imagePullPolicy: Always
livenessProbe:
failureThreshold: 10
httpGet:
path: /healthz
port: 6789
initialDelaySeconds: 15
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
name: che-operator
ports:
- containerPort: 60000
name: metrics
readinessProbe:
exec:
command:
- stat
- /tmp/operator-sdk-ready
failureThreshold: 10
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
resources: {}
restartPolicy: Always
serviceAccountName: che-operator
Expand Down Expand Up @@ -494,4 +514,4 @@ spec:
maturity: stable
provider:
name: Eclipse Foundation
version: 7.24.0-64.nightly
version: 7.25.0-66.nightly
Loading