Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/jobs/helm_aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@ steps:
for RELEASE in $RELEASES ; do
DEPLOYMENTS=$(helm get manifest -n $NAMESPACE $RELEASE | yq eval -o json | jq -r '. | select(.kind == "Deployment") | .metadata.name' | sort -r)
for DEPLOYMENT in $DEPLOYMENTS ; do
echo "Targeting deployment '$DEPLOYMENT' (release '$RELEASE', namespace '$NAMESPACE')..."
if [ << parameters.scale_environment_down >> = true ]; then
REPLICA_COUNT=0
else
REPLICA_COUNT=$(helm get manifest -n $NAMESPACE $RELEASE | yq eval -o json | jq -r ". | select( (.kind == \"Deployment\") and (.metadata.name ==\"$DEPLOYMENT\") ) | .spec.replicas" )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Suggestion: The helm get manifest command is called repeatedly inside the loop. To improve performance and robustness, consider fetching the manifest once per release and storing it in a variable. Additionally, you should verify that REPLICA_COUNT is a valid integer before executing the kubectl scale command to prevent runtime errors (e.g., syntax errors if the variable is empty).

fi
echo "Scaling deployment '$DEPLOYMENT' to $REPLICA_COUNT replica(s)..."
kubectl scale --replicas=$REPLICA_COUNT deployment/$DEPLOYMENT -n $NAMESPACE
if [[ << parameters.wait_for_pods_ready >> = true ]]; then
kubectl rollout status deployment/$DEPLOYMENT -n $NAMESPACE --timeout << parameters.wait_for_pods_ready_timeout >> || error_deployments+=("$DEPLOYMENT")
Expand Down