Adapt fixtures and asserts in graceful-shutdown and product-config-compat tests - #765
Adapt fixtures and asserts in graceful-shutdown and product-config-compat tests#765maltesander wants to merge 5 commits into
Conversation
…t-config-compat tests
Techassi
left a comment
There was a problem hiding this comment.
The scripts are... hard to look at. I think we can make it slightly easier to look at them.
| "security.properties": "networkaddress.cache.negative.ttl=0\nnetworkaddress.cache.ttl=30\n", | ||
| "spark-env.sh": "", | ||
| "template.yaml": "metadata:\n labels:\n app.kubernetes.io/component: spark\n app.kubernetes.io/instance: pyspark-pi\n app.kubernetes.io/managed-by: spark.stackable.tech_sparkapplication\n app.kubernetes.io/name: spark-k8s\n app.kubernetes.io/version: 3.5.8-stackable0.0.0-dev\n prometheus.io/scrape: 'true'\n stackable.tech/vendor: Stackable\n name: spark\nspec:\n affinity: {}\n containers:\n - env:\n - name: CONTAINERDEBUG_LOG_DIRECTORY\n value: /stackable/log/containerdebug\n - name: _STACKABLE_PRE_HOOK\n value: containerdebug --output=/stackable/log/containerdebug-state.json --loop &\n image: oci.stackable.tech/sdp/spark-k8s:3.5.8-stackable0.0.0-dev\n imagePullPolicy: IfNotPresent\n name: spark\n resources:\n limits:\n cpu: '2'\n memory: 1Gi\n requests:\n cpu: '1'\n memory: 1Gi\n volumeMounts:\n - mountPath: /stackable/log_config\n name: log-config\n - mountPath: /stackable/log\n name: log\n enableServiceLinks: false\n securityContext:\n fsGroup: 1000\n serviceAccountName: pyspark-pi\n volumes:\n - emptyDir:\n sizeLimit: 39Mi\n name: log\n - configMap:\n name: pyspark-pi-driver-pod-template\n name: log-config\n - configMap:\n name: pyspark-pi-driver-pod-template\n name: config\n" | ||
| "template.yaml": "metadata:\n labels:\n app.kubernetes.io/component: spark\n app.kubernetes.io/instance: pyspark-pi\n app.kubernetes.io/managed-by: spark.stackable.tech_sparkapplication\n app.kubernetes.io/name: spark-k8s\n app.kubernetes.io/version: 3.5.8-stackable0.0.0-dev\n prometheus.io/scrape: 'true'\n stackable.tech/vendor: Stackable\n name: spark\nspec:\n affinity: {}\n containers:\n - env:\n - name: CONTAINERDEBUG_LOG_DIRECTORY\n value: /stackable/log/containerdebug\n - name: _STACKABLE_PRE_HOOK\n value: containerdebug --output=/stackable/log/containerdebug-state.json --loop &\n image: oci.stackable.tech/sdp/spark-k8s:3.5.8-stackable0.0.0-dev\n imagePullPolicy: IfNotPresent\n name: spark\n resources:\n limits:\n cpu: '2'\n memory: 1Gi\n requests:\n cpu: '1'\n memory: 1Gi\n volumeMounts:\n - mountPath: /stackable/log_config\n name: log-config\n - mountPath: /stackable/log\n name: log\n enableServiceLinks: false\n securityContext:\n fsGroup: 1000\n runAsNonRoot: true\n serviceAccountName: pyspark-pi\n volumes:\n - emptyDir:\n sizeLimit: 39Mi\n name: log\n - configMap:\n name: pyspark-pi-driver-pod-template\n name: log-config\n - configMap:\n name: pyspark-pi-driver-pod-template\n name: config\n" |
There was a problem hiding this comment.
I assume this change was triggered by the addition of "runAsNonRoot": true in the ...-spec.json file?
There was a problem hiding this comment.
Not really, the json wasnt refreshed properly after #744.
| executors=$(kubectl -n "$NAMESPACE" get pods -l "spark-role=executor,app.kubernetes.io/instance=$app" -o json \ | ||
| | jq -r '.items[] | ||
| | select(.metadata.deletionTimestamp == null and .status.phase == "Running") | ||
| | .metadata.name') |
There was a problem hiding this comment.
Better formatting would make this slightly less cursed.
| executors=$(kubectl -n "$NAMESPACE" get pods -l "spark-role=executor,app.kubernetes.io/instance=$app" -o json \ | |
| | jq -r '.items[] | |
| | select(.metadata.deletionTimestamp == null and .status.phase == "Running") | |
| | .metadata.name') | |
| executors=$( | |
| kubectl -n "$NAMESPACE" get pods \ | |
| -l "spark-role=executor,app.kubernetes.io/instance=$app" \ | |
| -o json | jq -r \ | |
| ' | |
| .items[] | |
| | select(.metadata.deletionTimestamp == null and .status.phase == "Running") | |
| | .metadata.name' | |
| ) |
| fi | ||
| if [ -z "$executors" ]; then | ||
| echo "FAIL: no executor Pods found for $app, so no shutdown can be propagated to any" | ||
| running=$(printf '%s\n' "$executors" | grep -c . || true) |
There was a problem hiding this comment.
Is this for counting the number of running executor? If so, this can be done better by using jq's length function.
| if [ -z "$executors" ]; then | ||
| echo "FAIL: no executor Pods found for $app, so no shutdown can be propagated to any" | ||
| running=$(printf '%s\n' "$executors" | grep -c . || true) | ||
| if [ "$running" -ne 2 ]; then |
There was a problem hiding this comment.
Also, numerical equality checks are tricky. We have to be really certain bash thinks $running is a number and not a string containing a number.
There was a problem hiding this comment.
The jq length fixed this automatically (and it is not bash: POSIX test is an arithmetic comparison).
| for pod in $(kubectl -n "$NAMESPACE" get pods -l "$selector" -o json \ | ||
| | jq -r '.items[] | ||
| | select(.metadata.deletionTimestamp == null and .status.phase == "Running") | ||
| | .metadata.name'); do |
There was a problem hiding this comment.
I feel like we should pull this out of the loop header. It is currently cumbersome to read.
| echo "FAIL: ${budget_seconds}s after the executor was stopped, $registered of 2" | ||
| echo "executors are registered and running a task, so no replacement came back" |
There was a problem hiding this comment.
Why not use a single echo -e here for newlines?
There was a problem hiding this comment.
The echo -e does not work for kuttls sh -c. Could do printf?
Co-authored-by: Techassi <git@techassi.dev>
Description
Definition of Done Checklist
Author
Reviewer
Acceptance
type/deprecationlabel & add to the deprecation scheduletype/experimentallabel & add to the experimental features tracker