#include "action.h"
#include "event_processor.h"
#include "log.h"
+#include "service.h"
#define MODULE_NAME "resource_violation_decision_maker"
return faultd_event_is_of_type(ev, RESOURCE_VIOLATION_EVENT_ID);
}
+/*
+ * This handles resource violation for all types of sevices
+ * but action to be executed depends on service type:
+ * - For VIP service we reboot the machine
+ * - For all other services we just restart the service itself
+ */
static int rv_make_decision(struct faultd_event_handler *handler)
{
struct faultd_event *ev = nqueue_pop(&handler->event_queue,
nq_node);
struct resource_violation_event *rv_ev = to_resource_violation_event(ev);
struct faultd_event *new_ev;
- /* For now this is just hardcoded to restart the service */
struct dm_event_data ev_data = {
.reason = ev,
.who_made = MODULE_NAME,
};
int ret;
- ev_data.action_data = strdup(rv_ev->service.dbus_path);
- if (!ev_data.action_data) {
- log_error("Unable to duplicate service name");
- faultd_event_unref(ev);
- return -ENOMEM;
+ if (systemd_service_is_of_type(&rv_ev->service, FAULTD_SERVICE_TYPE_VIP)) {
+ ev_data.action = FAULTD_ACTION_REBOOT_ID;
+ ev_data.action_data = NULL;
+ } else {
+ ev_data.action_data = strdup(rv_ev->service.dbus_path);
+ if (!ev_data.action_data) {
+ log_error("Unable to duplicate service name");
+ faultd_event_unref(ev);
+ return -ENOMEM;
+ }
}
ret = faultd_event_create(DECISION_MADE_EVENT_ID, &ev_data, &new_ev);