Skip to content

Commit 9daa1cb

Browse files
feat: add prepare downscale handler
1 parent f10962a commit 9daa1cb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pkg/dataobj/consumer/http.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ import (
1010
"github.com/grafana/loki/v3/pkg/util"
1111
)
1212

13+
// PrepareDownscaleHandler is a special handler called by the rollout operator
14+
// immediately before the pod is downscaled. It can stop a downscale by
15+
// responding with a non 2xx status code.
16+
func (s *Service) PrepareDownscaleHandler(_ http.ResponseWriter, _ *http.Request) {
17+
s.partitionInstanceLifecycler.SetRemoveOwnerOnShutdown(true)
18+
}
19+
1320
// PrepareDelayedDownscaleHandler is a special handler called by the rollout
1421
// operator to prepare for a delayed downscale. This allows the service to
1522
// perform any number of actions in preparation of being scaled down at the

pkg/loki/modules.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2404,7 +2404,11 @@ func (t *Loki) initDataObjConsumer() (services.Service, error) {
24042404
serverutil.RecoveryHTTPMiddleware,
24052405
)
24062406
t.Server.HTTP.
2407-
Methods(http.MethodGet, http.MethodPost, http.MethoDelete).
2407+
Methods(http.MethodGet, http.MethodPost, http.MethodDelete).
2408+
Path("/dataobj-consumer/prepare-downscale").
2409+
Handler(httpMiddleware.Wrap(http.HandlerFunc(t.dataObjConsumer.PrepareDownscaleHandler)))
2410+
t.Server.HTTP.
2411+
Methods(http.MethodGet, http.MethodPost, http.MethodDelete).
24082412
Path("/dataobj-consumer/prepare-delayed-downscale").
24092413
Handler(httpMiddleware.Wrap(http.HandlerFunc(t.dataObjConsumer.PrepareDelayedDownscaleHandler)))
24102414

0 commit comments

Comments
 (0)