-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(operator): avoid multiple creations of the same KeptnTask (#1676)
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
- Loading branch information
Showing
11 changed files
with
162 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
test/integration/app-one-taskdefinition-not-found/00-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: lifecycle.keptn.sh/v1alpha3 | ||
kind: KeptnAppVersion | ||
metadata: | ||
name: podtato-head-1.3-6b86b273 | ||
status: | ||
currentPhase: AppPreDeployTasks | ||
postDeploymentEvaluationStatus: Pending | ||
postDeploymentStatus: Pending | ||
preDeploymentEvaluationStatus: Pending | ||
preDeploymentStatus: Unknown | ||
status: Progressing | ||
workloadOverallStatus: Pending | ||
--- | ||
apiVersion: lifecycle.keptn.sh/v1alpha3 | ||
kind: KeptnTask | ||
spec: | ||
app: podtato-head | ||
appVersion: '1.3' | ||
checkType: pre | ||
retries: 10 | ||
taskDefinition: pre-task-timeout | ||
timeout: 30s | ||
status: | ||
status: Succeeded |
53 changes: 53 additions & 0 deletions
53
test/integration/app-one-taskdefinition-not-found/00-install.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
apiVersion: lifecycle.keptn.sh/v1alpha3 | ||
kind: KeptnApp | ||
metadata: | ||
name: podtato-head | ||
spec: | ||
version: "1.3" | ||
workloads: | ||
- name: podtato-head-entry | ||
version: 0.1.0 | ||
preDeploymentTasks: | ||
- pre-task-timeout | ||
- pre-task-notfound | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: podtato-head-entry | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
matchLabels: | ||
component: podtato-head-entry | ||
template: | ||
metadata: | ||
labels: | ||
component: podtato-head-entry | ||
annotations: | ||
keptn.sh/app: podtato-head | ||
keptn.sh/workload: podtato-head-entry | ||
keptn.sh/version: 0.1.0 | ||
spec: | ||
terminationGracePeriodSeconds: 5 | ||
containers: | ||
- name: server | ||
image: ghcr.io/podtato-head/entry:latest | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 9000 | ||
env: | ||
- name: PODTATO_PORT | ||
value: "9000" | ||
--- | ||
apiVersion: lifecycle.keptn.sh/v1alpha3 | ||
kind: KeptnTaskDefinition | ||
metadata: | ||
name: pre-task-timeout | ||
spec: | ||
function: | ||
inline: | ||
code: | | ||
console.log('foo') | ||
timeout: "30s" |
4 changes: 4 additions & 0 deletions
4
test/integration/app-one-taskdefinition-not-found/00-teststep.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: kuttl.dev/v1 | ||
kind: TestStep | ||
commands: | ||
- script: kubectl annotate ns $NAMESPACE keptn.sh/lifecycle-toolkit='enabled' |
4 changes: 4 additions & 0 deletions
4
test/integration/app-one-taskdefinition-not-found/01-teststep-verify-number-of-tasks.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: kuttl.dev/v1 | ||
kind: TestStep | ||
commands: | ||
- script: ../common-scripts/verify-number-of-resources.sh "keptntask" "1" |
26 changes: 26 additions & 0 deletions
26
test/integration/common-scripts/verify-number-of-resources.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
RETRY_COUNT=3 | ||
SLEEP_TIME=5 | ||
RESOURCE_TYPE=$1 | ||
EXPECTED_NUMBER=$2 | ||
|
||
for i in $(seq 1 $RETRY_COUNT); do | ||
NR_RESOURCES=$(kubectl get ${RESOURCE_TYPE} -n ${NAMESPACE} --no-headers | wc -l) | ||
|
||
if [[ ${NR_RESOURCES} -eq ${EXPECTED_NUMBER} ]]; then | ||
echo "Found expected number of ${RESOURCE_TYPE}: ${EXPECTED_NUMBER}" | ||
exit 0 | ||
else | ||
echo "Number of ${RESOURCE_TYPE} is not equal to ${EXPECTED_NUMBER}" | ||
fi | ||
|
||
if [ "$i" -lt "$RETRY_COUNT" ]; then | ||
echo "Sleeping for ${SLEEP_TIME} seconds before retrying..." | ||
sleep ${SLEEP_TIME} | ||
fi | ||
done | ||
|
||
echo "Retried ${RETRY_COUNT} times, but expected number of ${RESOURCE_TYPE} could not be verified. Exiting..." | ||
exit 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: kuttl.dev/v1 | ||
kind: TestStep | ||
commands: | ||
- script: ./verify-tasks.sh | ||
- script: ../common-scripts/verify-number-of-resources.sh "job" "1" |
This file was deleted.
Oops, something went wrong.