From 386edb19918d03a2732f405a7edd28f21730b4ca Mon Sep 17 00:00:00 2001 From: Richard LT Date: Wed, 4 May 2022 11:57:00 +0200 Subject: [PATCH] feat(api): maintenance allow worker and service calls (#6163) --- engine/api/router_middleware.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/engine/api/router_middleware.go b/engine/api/router_middleware.go index bf61f17677..58a77abef8 100644 --- a/engine/api/router_middleware.go +++ b/engine/api/router_middleware.go @@ -9,8 +9,11 @@ import ( ) func (api *API) maintenanceMiddleware(ctx context.Context, w http.ResponseWriter, req *http.Request, rc *service.HandlerConfig) (context.Context, error) { - if !isMaintainer(ctx) && api.Maintenance && !rc.MaintenanceAware && rc.Method != http.MethodGet { - return ctx, sdk.WrapError(sdk.ErrServiceUnavailable, "CDS Maintenance ON") + if api.Maintenance && !rc.MaintenanceAware && rc.Method != http.MethodGet { + isAllowed := isMaintainer(ctx) || isService(ctx) || isWorker(ctx) + if !isAllowed { + return ctx, sdk.WrapError(sdk.ErrServiceUnavailable, "CDS Maintenance ON") + } } return ctx, nil }