Skip to content

Commit

Permalink
cluster: better scripts and no downscaling
Browse files Browse the repository at this point in the history
  • Loading branch information
JanSkalny committed Oct 29, 2024
1 parent 83769f8 commit 1ad9995
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
File renamed without changes.
28 changes: 28 additions & 0 deletions cluster/files/cluster-list-vms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

warn() {
echo "$*" 1>&2
}

fail() {
echo "$*" 1>&2
exit 1
}

# attempt to name every running vm on this node
for VM in $( virsh list | grep running | awk '{print $2}'); do
# get VM name from config xml
UUID=$(virsh dumpxml "$VM" | xmllint --xpath 'string(/domain/uuid/text())' -)
[ -z "$UUID" ] && fail "$VM does not have uuid?"
XML_FILE=$(grep -l "<name>$VM</name>" /var/lib/virtual/conf/*.xml)
[ -f "$XML_FILE" ] || fail "$VM does not have XML file"
NAME=$(cat "$XML_FILE" | xmllint --xpath '/domain/metadata/fqdn/text()' - 2>/dev/null)
[ -z "$NAME" ] && fail "$VM does not have a fqdn defined in its metadata!"

# check if VM is defined in corosync
crm conf show | grep "${VM}_vm" > /dev/null
[ $? -ne 0 ] && warn "$NAME ($VM) is not defined in corosync!" && continue

# print vm name
echo "$NAME ($VM)"
done
Empty file added cluster/files/cluster-unmove.sh
Empty file.
16 changes: 14 additions & 2 deletions cluster/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,23 @@
- libvirt-guests
ignore_errors: yes

- name: remove old cluster maintenance scripts
file:
path: "/usr/local/bin/{{ item }}"
state: absent
with_items:
- cluster-drain-node.sh
tags: install

- name: deploy cluster maintenance scripts
copy:
src: cluster-drain-node.sh
dest: /usr/local/bin/cluster-drain-node.sh
src: "{{ item }}"
dest: "/usr/local/bin/{{ item }}"
mode: 0700
with_items:
- cluster-drain.sh
- cluster-unmove.sh
- cluster-list-vms.sh
tags: install

# TODO:
Expand Down
3 changes: 0 additions & 3 deletions cluster/templates/corosync.conf
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,5 @@ quorum {
last_man_standing: 1
last_man_standing_window: {{ cluster_last_man_standing_window }}
{% endif %}
{% if cluster.members|length > 3 %}
allow_downscale: 1
{% endif %}
{% endif %}
}

0 comments on commit 1ad9995

Please sign in to comment.