You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Delete old versions after deployment
This changes the order in which deletion of old versions of wpt.fyi is
deleted from the infrastructure. Prior to this change the deletion
happened at the beginning of the deployment. The deletion itself takes
many minutes per service, with prompts inbetween, so the time from start
of deplyment to the new image actually being available in the
infrastructure was longer than it needed to be. With this change, the
deployment starts right away, and once the deployment is done, we ask
whether old versions should be deleted and do those deletions w/o
prompting per service, meaning the person doing the deployment doesn't
need to sit and wait etc.
* Fix nesting of if statement.
# Confirm there are 3 versions for each service and delete the oldest version.
90
+
# Confirm there are no more than two versions for each service to make sure
91
+
# there's room for the ones we're about to push. If there are more than two
92
+
# versions available, something didn't go as planned in the previous
93
+
# deployment. If so, delete old versions manually in the cloud console.
98
94
SERVICES="default processor searchcache"
99
95
forSERVICEin$SERVICES
100
96
do
101
97
VERSIONS=$(gcloud app --project=wptdashboard versions list --filter="service=$SERVICE" --format=list | wc -l)
102
-
if[[ "${VERSIONS}"-eq"3" ]];
98
+
if((${VERSIONS}>2));
103
99
then
104
-
echo"Found 3 versions for service $SERVICE, will delete the oldest"
105
-
delete_oldest_version $SERVICE
106
-
elif [[ "${VERSIONS}"-lt"3" ]];
107
-
then
108
-
echo -e "\n$VERSIONS versions found for service $SERVICE"
109
-
else
110
-
echo -e "\n$VERSIONS versions found for service $SERVICE!"
100
+
echo -e "Found more than 2 versions ($VERSIONS) for service $SERVICE.\nPlease make sure there are no more than 2 versions of each service and try\nagain."
101
+
111
102
exit 3
112
103
fi
104
+
105
+
echo"Found $VERSIONS versions for service $SERVICE. Good to proceed."
113
106
done
114
107
115
108
# Start a docker instance.
@@ -143,3 +136,31 @@ fi
143
136
# Update and close deployment bug.
144
137
LAST_DEPLOYMENT_ISSUE=$(gh issue list --state open --label "$PROD_LABEL" --label "$RELEASE_LABEL" --limit 1 --json number --jq '.[] | .number')
145
138
gh issue close "$LAST_DEPLOYMENT_ISSUE" -c "Deployment is now complete."
139
+
140
+
# Check if there are more more than two versions of the default service left
141
+
# after we're done with this deplyment to make sure there's room for the next
142
+
# deployment. If there are, ask to delete the oldest default service version,
143
+
# and also delete the same version from the other services which will also exist
144
+
# if all went well during the deployment. This check isn't fail safe, but
145
+
# combined with the check we do before doing any deployments earlier in this
146
+
# script, this should leave us in a good state.
147
+
148
+
VERSIONS=$(gcloud app --project=wptdashboard versions list --filter="service=default" --format=list | wc -l)
149
+
150
+
if(($VERSIONS==3));then
151
+
echo -e "Please ensure the deployment was successful. If so, we can go ahead and\ndelete the oldest version of all services if necessary, leaving the one just\ndeployed and the one running before this deployment. This will ensure we leave\nroom for the next deployment.\n"
152
+
153
+
read -p "Delete oldest version of all services to leave room for the next deplyment? (y/n): " DELETE
154
+
155
+
if [[ $DELETE=="y" ]];then
156
+
echo"Found $VERSIONS for the default service, deleting the oldest version of all services."
echo -e "\nUnexpectedly found $VERSIONS versions for the default service.\nPlease delete old versions for all services manually until there are no more than two left."
0 commit comments