Print this page
7711 SMF: Finish implementing support for degraded state
@@ -1167,11 +1167,11 @@
if (info->sf_method_type == METHOD_START)
log_transition(inst, START_REQUESTED);
r = method_run(&inst, info->sf_method_type, &exit_code);
- if (r == 0 && exit_code == 0) {
+ if (r == 0 && (exit_code == 0 || exit_code == SMF_EXIT_MON_DEGRADE)) {
/* Success! */
assert(inst->ri_i.i_next_state != RESTARTER_STATE_NONE);
/*
* When a stop method succeeds, remove the primary contract of
@@ -1185,11 +1185,22 @@
if (inst->ri_i.i_next_state == RESTARTER_STATE_OFFLINE)
inst->ri_i.i_primary_ctid_stopped = 1;
else
method_remove_contract(inst, B_TRUE, B_TRUE);
}
+
/*
+ * When a start method returns with SMF_EXIT_MON_DEGRADE we
+ * transition the service into degraded.
+ */
+ if (info->sf_method_type == METHOD_START &&
+ exit_code == SMF_EXIT_MON_DEGRADE) {
+ inst->ri_i.i_next_state = RESTARTER_STATE_DEGRADED;
+ info->sf_reason = restarter_str_method_failed;
+ }
+
+ /*
* We don't care whether the handle was rebound because this is
* the last thing we do with it.
*/
(void) restarter_instance_update_states(local_handle, inst,
inst->ri_i.i_next_state, RESTARTER_STATE_NONE,