2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-10-21 23:28:19 +00:00

refactor(genesis): share status publication across services

Preserve component labels, failure messages and exit policy at each caller. Give the runtime library its own package so discovery does not depend on the init package that already depends on discovery.
This commit is contained in:
Vinícius Ferrão
2026-10-12 19:10:41 -03:00
parent 2a201ab62c
commit 8f1ece8da7
9 changed files with 35 additions and 15 deletions
@@ -0,0 +1,17 @@
SUMMARY = "xCAT Genesis runtime functions"
LICENSE = "EPL-1.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/EPL-1.0;md5=57f8d5e2b3e98ac6e088986c12bf94e6"
FILESEXTRAPATHS:prepend := "${THISDIR}/../xcat-genesis-init/files:"
SRC_URI = "file://genesis-functions"
S = "${UNPACKDIR}"
RDEPENDS:${PN} = "bash util-linux-logger"
do_install() {
install -d ${D}${libexecdir}/xcat
install -m 0644 ${UNPACKDIR}/genesis-functions \
${D}${libexecdir}/xcat/genesis-functions
}
FILES:${PN} = "${libexecdir}/xcat/genesis-functions"
@@ -43,6 +43,7 @@ publish_status() {
[[ -z $last_verified_seconds ]] \
|| fields+=("VERIFIED_SECONDS=$last_verified_seconds")
genesis_publish_status "$status_command" action xcat-genesis-action \
'unable to publish action status' \
"$state" "$detail" "${fields[@]}" "$@"
}
@@ -1,9 +1,9 @@
genesis_publish_status() {
local status_command=$1 component=$2 log_tag=$3
shift 3
local status_command=$1 component=$2 log_tag=$3 log_message=$4
shift 4
"$status_command" "$component" "$@" \
|| logger -t "$log_tag" -- "unable to publish $component status"
|| logger -t "$log_tag" -- "$log_message"
}
genesis_uptime_seconds() {
@@ -16,7 +16,7 @@ failure_recovery='Check the management network and boot parameters'
publish_status() {
genesis_publish_status "$status_command" network \
xcat-genesis-network-state "$@"
xcat-genesis-network-state 'unable to publish network status' "$@"
}
finish_status() {
@@ -27,7 +27,7 @@ declare -a cmdline_arguments
publish_status() {
genesis_publish_status "$status_command" registration \
xcat-genesis-register "$@"
xcat-genesis-register 'unable to publish registration status' "$@"
}
finish_status() {
@@ -3,7 +3,6 @@ LICENSE = "EPL-1.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/EPL-1.0;md5=57f8d5e2b3e98ac6e088986c12bf94e6"
SRC_URI = "file://00-xcat-genesis.preset \
file://genesis-functions \
file://genesis-maintenance-shell \
file://genesis-action \
file://genesis-metrics \
@@ -21,7 +20,7 @@ S = "${UNPACKDIR}"
inherit systemd
RDEPENDS:${PN} = "bash coreutils ipmitool iproute2 networkmanager-nmcli util-linux-logger xcat-genesis-discovery xcat-genesis-protocol"
RDEPENDS:${PN} = "bash coreutils ipmitool iproute2 networkmanager-nmcli util-linux-logger xcat-genesis-common xcat-genesis-discovery xcat-genesis-protocol"
SYSTEMD_SERVICE:${PN} = "xcat-genesis-action.service \
xcat-genesis-metrics.service \
@@ -32,8 +31,6 @@ SYSTEMD_AUTO_ENABLE = "enable"
do_install() {
install -d ${D}${libexecdir}/xcat
install -m 0644 ${UNPACKDIR}/genesis-functions \
${D}${libexecdir}/xcat/genesis-functions
install -m 0755 ${UNPACKDIR}/genesis-maintenance-shell \
${D}${libexecdir}/xcat/genesis-maintenance-shell
install -m 0755 ${UNPACKDIR}/genesis-action \
@@ -67,7 +64,6 @@ do_install() {
}
FILES:${PN} = "${libexecdir}/xcat/genesis-maintenance-shell \
${libexecdir}/xcat/genesis-functions \
${libexecdir}/xcat/genesis-action \
${libexecdir}/xcat/genesis-metrics \
${libexecdir}/xcat/genesis-network-refresh \
@@ -1,6 +1,9 @@
#!/bin/bash
set -euo pipefail
functions_file=${XCAT_GENESIS_FUNCTIONS:-/usr/libexec/xcat/genesis-functions}
source "$functions_file"
state_dir=${XCAT_STATE_DIR:-/run/xcat}
status_command=${XCAT_STATUS_COMMAND:-/usr/libexec/xcat/genesis-status}
network_file=${XCAT_NETWORK_FILE:-$state_dir/genesis.env}
@@ -22,8 +25,8 @@ temporary_dir=
[[ "$retry_seconds" =~ ^[0-9]+$ ]] || retry_seconds=5
publish_status() {
"$status_command" discovery "$@" \
|| logger -t xcat-genesis-discover -- 'unable to publish discovery status'
genesis_publish_status "$status_command" discovery \
xcat-genesis-discover 'unable to publish discovery status' "$@"
}
# shellcheck disable=SC2317,SC2329
@@ -1,6 +1,9 @@
#!/bin/bash
set -euo pipefail
functions_file=${XCAT_GENESIS_FUNCTIONS:-/usr/libexec/xcat/genesis-functions}
source "$functions_file"
state_dir=${XCAT_STATE_DIR:-/run/xcat}
status_command=${XCAT_STATUS_COMMAND:-/usr/libexec/xcat/genesis-status}
network_file=${XCAT_NETWORK_FILE:-$state_dir/genesis.env}
@@ -15,8 +18,8 @@ temporary_dir=
[[ "$request_timeout" =~ ^[1-9][0-9]*$ ]] || request_timeout=20
publish_status() {
"$status_command" credentials "$@" \
|| logger -t xcat-genesis-getcert -- 'unable to publish credential status'
genesis_publish_status "$status_command" credentials \
xcat-genesis-getcert 'unable to publish credential status' "$@"
}
# shellcheck disable=SC2329
@@ -22,7 +22,7 @@ do_compile() {
-o genesis-udp-send
}
RDEPENDS:${PN} = "bash coreutils gzip iproute2 openssl-bin util-linux-logger util-linux-lsblk"
RDEPENDS:${PN} = "bash coreutils gzip iproute2 openssl-bin util-linux-logger util-linux-lsblk xcat-genesis-common"
SYSTEMD_SERVICE:${PN} = "xcat-genesis-discovery.socket \
xcat-genesis-credential.socket \