Add helm charts for cluster tasks and run tasks with a job
The task:
- gets info about the drupal site
- creates the job for running the script
- monitors if the status of the job
- waits for the job to succeed or fail
- prints the final status of the job
- prints the logs of the job
Logs of the taskrun pod:
Refers to:
Edited by Dimitra Chatzichrysou
Merge request reports
Activity
- Resolved by Dimitra Chatzichrysou
added 1 commit
- fb1f0c9a - Mount job template configmap using a workspace
- Resolved by Dimitra Chatzichrysou
22 24 echo "Drupal site name: $(params.drupalSite)" 23 25 deploymentPod=$(oc get pods -n $(params.namespace) -l drupalSite=$(params.drupalSite) -l app=drupal -o custom-columns=POD:.metadata.name --no-headers) 24 26 echo "Deployment pod: $deploymentPod" 25 oc exec $deploymentPod -c php-fpm drush cr 27 export TASK=clear-cache 28 export DRUPALSITE=$(params.drupalSite) 29 export NAMESPACE=$(params.namespace) 30 envsubst < $(workspaces.job.path)/job-operations-template.yaml | oc create -n $(params.namespace) -f - 31 oc wait --for=condition=complete job/$TASK-$(params.drupalSite) & completion_pid=$! 32 oc wait --for=condition=failed job/$TASK-$(params.drupalSite) & failure_pid=$! 33 wait -n $completion_pid $failure_pid 34 jobStatus=$(oc get job/$TASK-$(params.drupalSite) -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo "Failed") 35 echo "Job status: $jobStatus" 36 jobPod=$(oc get pods -n $(params.namespace) -l job-name=$TASK-$(params.drupalSite) -o custom-columns=POD:.metadata.name --no-headers) 37 echo "Job pod: $jobPod" 38 echo "Job logs:" Hm no, I've found this when searching on how to wait for a job to succeed or fail, cause the task pod should wait for the job to finish. If the job fails, the task will also fail (and the similar for success case). I think we don't have to set the task's status.
I job fails, taskrun's status is:
... status: completionTime: 2021-04-09T14:37:07Z conditions: - lastTransitionTime: 2021-04-09T14:37:07Z message: | "step-clear-cache" exited with code 1 (image: "gitlab-registry.cern.ch/drupal/paas/drupal-operations/openshift-> reason: Failed status: "False" type: Succeeded ...
Edited by Dimitra Chatzichrysouchanged this line in version 9 of the diff
added 7 commits
-
fb1f0c9a...494acc84 - 2 commits from branch
master
- ede89475 - Fix typo and make files executable
- 16e0e833 - Add rules for batch api group
- 1e675095 - Use a job for running the clear-cache task
- 1696440e - Mount job template configmap using a workspace
- d4202fa4 - Update configmap, role and image for clear-cache task
Toggle commit list-
fb1f0c9a...494acc84 - 2 commits from branch
added 12 commits
-
d4202fa4...aece0655 - 6 commits from branch
master
- 9ee5e058 - Add rules for batch api group
- eaf39abd - Use a job for running the clear-cache task
- 5810a6db - Mount job template configmap using a workspace
- b724a44f - Update configmap, role and image for clear-cache task
- 3274491a - Delete roles
- 9de3acdd - Update script for clear-cache cluster task
Toggle commit list-
d4202fa4...aece0655 - 6 commits from branch
added 2 commits
- Resolved by Dimitra Chatzichrysou
- Resolved by Konstantinos Samaras-Tsakiris
Please register or sign in to reply