Search in sources :

Example 1 with StuffHolder

use of com.redhat.cloud.policies.app.StuffHolder in project policies-ui-backend by RedHatInsights.

the class AdminService method setAdminDown.

/**
 * Signal health to outside world. Allowed values for state
 * * 'ok': all ok
 * * 'degraded': signal instance as degraded on status endpoint
 * * 'admin-down': signal health-checks as down. Signals k8s to kill the pod
 */
@Path("/status")
@POST
public Response setAdminDown(@QueryParam("status") Optional<String> status) {
    Response.ResponseBuilder builder;
    StuffHolder th = StuffHolder.getInstance();
    switch(status.orElse("ok")) {
        case "ok":
            th.setDegraded(false);
            th.setAdminDown(false);
            builder = Response.ok().entity(new Msg("Reset state to ok"));
            break;
        case "degraded":
            th.setDegraded(true);
            builder = Response.ok().entity(new Msg("Set degraded state"));
            break;
        case "admin-down":
            th.setAdminDown(true);
            builder = Response.ok().entity(new Msg("Set admin down state"));
            break;
        default:
            builder = Response.status(Response.Status.BAD_REQUEST).entity(new Msg("Unknown status passed"));
    }
    statusProducer.update();
    return builder.build();
}
Also used : Response(javax.ws.rs.core.Response) Msg(com.redhat.cloud.policies.app.model.Msg) StuffHolder(com.redhat.cloud.policies.app.StuffHolder) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

StuffHolder (com.redhat.cloud.policies.app.StuffHolder)1 Msg (com.redhat.cloud.policies.app.model.Msg)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Response (javax.ws.rs.core.Response)1