// Ensure etcd_health is defined before using .includes()
var etcd_health = state.etcd_health; // Assuming `etcd_health` is the variable holding the output
// Check if etcd_health is defined and not null
if (etcd_health && typeof etcd_health === 'string') {
// Check if the string contains "healthy"
var status = "unhealthy"; // Default status
if (etcd_health.includes("healthy")) {
status = "healthy";
}
// Log the status for debugging
console.log("ETCD cluster status:", status);
// Optionally store the status for use in later states
state.etcd_status = status;
} else {
// Handle the case when etcd_health is undefined or null
console.log("Error: 'etcd_health' is undefined or not a string.");
state.etcd_status = "unknown"; // Set a default or error state
}





0 comments:
Post a Comment