Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-operations
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal
paas
drupal-operations
Commits
76f96d91
Commit
76f96d91
authored
2 years ago
by
Francisco Borges Aurindo Barros
Browse files
Options
Downloads
Patches
Plain Diff
Refactored script to be readable
parent
bcc0d7cb
No related branches found
No related tags found
1 merge request
!14
Script to restore stuck updates
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/restore-stuck-updates.sh
+25
-1
25 additions, 1 deletion
scripts/restore-stuck-updates.sh
with
25 additions
and
1 deletion
scripts/restore-stuck-updates.sh
+
25
−
1
View file @
76f96d91
#!/bin/sh
oc get
-o
json drupalsite
-A
| jq
-r
'.items[] | select(.status.releaseID.current != .status.releaseID.failsafe)|"\(.metadata.name) \(.metadata.namespace) \(.status.releaseID.failsafe)"'
| xargs
-l
bash
-c
'export name=$(echo $2 | cut -d"-" -f -2); export spec=$(echo $2 |cut -d"-" -f 3"-"45); echo "[{\"op\": \"replace\",\"path\":\"/spec/version/name\",\"value\":\"${name}\"}, {\"op\":\"replace\",\"path\":\"/spec/version/releaseSpec\",\"value\":\"${spec}\"}]">patchs; oc patch drupalsite/$0 -n $1 --type json --patch-file patchs; sleep 1s'
### FILTERs
STUCK_WEBSITE_FILTER
=
'.status.releaseID.current != .status.releaseID.failsafe'
WEBSITE_LIST_OUTPUT
=
'(.metadata.name + " " + .metadata.namespace + " " + .status.releaseID.failsafe)'
# Time between patches not to overwhelm the Operator
# This can be skipped/reduced once we have this issue closed: https://gitlab.cern.ch/webservices/webframeworks-planning/-/issues/869
export
GRACE_PERIOD
=
"1s"
## NB: This will match the spec of all websites based on failStatus version
##
oc get
-o
json drupalsite
-A
|
jq
-r
".items[] | select(
${
STUCK_WEBSITE_FILTER
}
) |
${
WEBSITE_LIST_OUTPUT
}
"
|
# Retrieve Spec Name from failSafe status
xargs
-l
bash
-c
'export name=$(echo $2 | cut -d"-" -f -2);
# Retrieve spec ReleaseID from failsafe status
export spec=$(echo $2 |cut -d"-" -f 3"-"45);
# Generate Patch to be applied
cat > patch.yaml <<EOF
spec:
version:
name: ${name}
releaseSpec: ${spec}
EOF
oc patch drupalsite/$0 -n $1 --type=merge --patch-file patch.yaml;
sleep ${GRACE_PERIOD}'
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment