Repository navigation
KVM: make storage heartbeat fence action configurable (graceful-reboot / restart-agent / log-only) #13090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jmsperu
wants to merge
5
commits into
apache:main
Choose a base branch
from
jmsperu:feature/configurable-heartbeat-fence
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
KVM: make storage heartbeat fence action configurable (graceful-reboot / restart-agent / log-only) #13090
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d91891e
KVM: make storage heartbeat fence action configurable
jmsperu 6c5938b
kvm-heartbeat: extract shared fence helper; add 'custom' action; rena…
jmsperu c040980
kvmsmpheartbeat.sh: honour kvm.heartbeat.fence.action
jmsperu 8fdf607
address review (#13090): drop the 'reboot' alias, simplify the agent.…
jmsperu 32818fb
address review (#13090): log-only only writes to syslog, drop the cus…
jmsperu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/bin/bash | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| # | ||
| # Shared fence-action helper for kvmheartbeat.sh, kvmspheartbeat.sh and kvmsmpheartbeat.sh. | ||
| # Sourced by those scripts; do not invoke directly. | ||
| # | ||
| # kvm.heartbeat.fence.action in agent.properties selects the action: | ||
| # hard-reboot (default), graceful-reboot, restart-agent, or log-only (only writes to | ||
| # syslog and takes no action). Any other value falls back to hard-reboot. | ||
| # | ||
| # Usage from caller: | ||
| # source "$(dirname "$0")/kvmha-fence.sh" | ||
| # fence_action "kvmheartbeat.sh" # script name passed for log tagging | ||
|
|
||
| AGENT_PROPS="${AGENT_PROPS:-/etc/cloudstack/agent/agent.properties}" | ||
|
|
||
| fence_action() { | ||
| local source_script="${1:-kvmha}" | ||
| local FENCE_ACTION="hard-reboot" | ||
|
|
||
| if [ -r "$AGENT_PROPS" ]; then | ||
| local val | ||
| val=$(grep "^kvm.heartbeat.fence.action=" "$AGENT_PROPS" | tail -n 1 | cut -d= -f2- | tr -d '[:space:]') | ||
| [ -n "$val" ] && FENCE_ACTION="$val" | ||
| fi | ||
|
|
||
| case "$FENCE_ACTION" in | ||
| log-only) | ||
| # Only writes to syslog; no reboot, no agent restart and no management server alert. | ||
| /usr/bin/logger -t heartbeat "${source_script}: heartbeat write to storage failed; fence action 'log-only' selected, taking no action. Operator must investigate." | ||
| exit 0 | ||
| ;; | ||
| restart-agent) | ||
| /usr/bin/logger -t heartbeat "${source_script}: heartbeat write to storage failed; fence action 'restart-agent', restarting cloudstack-agent (running VMs preserved)." | ||
| sync & | ||
| sleep 2 | ||
| systemctl restart cloudstack-agent | ||
| exit $? | ||
| ;; | ||
| graceful-reboot) | ||
| /usr/bin/logger -t heartbeat "${source_script}: heartbeat write to storage failed; fence action 'graceful-reboot', rebooting via systemctl (allows running VMs to stop cleanly)." | ||
| sync & | ||
| sleep 5 | ||
| systemctl reboot | ||
| exit $? | ||
| ;; | ||
| hard-reboot|*) | ||
| # Default, and the fallback for any unrecognised value: identical to the pre-existing behaviour. | ||
| /usr/bin/logger -t heartbeat "${source_script} will reboot system because it was unable to write the heartbeat to the storage." | ||
| sync & | ||
| sleep 5 | ||
| echo b > /proc/sysrq-trigger | ||
| exit $? | ||
| ;; | ||
| esac | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with log-only or restart-agent the vms keep running, so what happens if the management server decides this host is down and starts the same vms on another host? looks like two copies could end up writing to the same disk