mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #44931 from chuckbutler/worker-pause-action
Automatic merge from submit-queue (batch tested with PRs 44931, 44808) Closes #44392 **What this PR does / why we need it**: Fix the pause action with regard to the new behavior where --delete-local-data=false by default. Historically --force was all that was required, this flag has changed to be more descriptive of the actions it's taking. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #44392 **Release note**: ```release-note Added support to the pause action in the kubernetes-worker charm for new flag --delete-local-data ```
This commit is contained in:
commit
4fdee60b36
@ -1,6 +1,17 @@
|
|||||||
pause:
|
pause:
|
||||||
description: |
|
description: |
|
||||||
Cordon the unit, draining all active workloads.
|
Cordon the unit, draining all active workloads.
|
||||||
|
params:
|
||||||
|
delete-local-data:
|
||||||
|
type: boolean
|
||||||
|
description: Force deletion of local storage to enable a drain
|
||||||
|
default: False
|
||||||
|
force:
|
||||||
|
type: boolean
|
||||||
|
description: |
|
||||||
|
Continue even if there are pods not managed by a RC, RS, Job, DS or SS
|
||||||
|
default: False
|
||||||
|
|
||||||
resume:
|
resume:
|
||||||
description: |
|
description: |
|
||||||
UnCordon the unit, enabling workload scheduling.
|
UnCordon the unit, enabling workload scheduling.
|
||||||
|
@ -4,6 +4,25 @@ set -ex
|
|||||||
|
|
||||||
export PATH=$PATH:/snap/bin
|
export PATH=$PATH:/snap/bin
|
||||||
|
|
||||||
|
DELETE_LOCAL_DATA=$(action-get delete-local-data)
|
||||||
|
FORCE=$(action-get force)
|
||||||
|
|
||||||
|
# placeholder for additional flags to the command
|
||||||
|
export EXTRA_FLAGS=""
|
||||||
|
|
||||||
|
# Determine if we have extra flags
|
||||||
|
if [[ "${DELETE_LOCAL_DATA}" == "True" || "${DELETE_LOCAL_DATA}" == "true" ]]; then
|
||||||
|
EXTRA_FLAGS="${EXTRA_FLAGS} --delete-local-data=true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${FORCE}" == "True" || "${FORCE}" == "true" ]]; then
|
||||||
|
EXTRA_FLAGS="${EXTRA_FLAGS} --force"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Cordon and drain the unit
|
||||||
kubectl --kubeconfig=/root/cdk/kubeconfig cordon $(hostname)
|
kubectl --kubeconfig=/root/cdk/kubeconfig cordon $(hostname)
|
||||||
kubectl --kubeconfig=/root/cdk/kubeconfig drain $(hostname) --force
|
kubectl --kubeconfig=/root/cdk/kubeconfig drain $(hostname) ${EXTRA_FLAGS}
|
||||||
|
|
||||||
|
# Set status to indicate the unit is paused and under maintenance.
|
||||||
status-set 'waiting' 'Kubernetes unit paused'
|
status-set 'waiting' 'Kubernetes unit paused'
|
||||||
|
Loading…
Reference in New Issue
Block a user