Skip to content

node drainer added#228

Merged
cirisked merged 2 commits intomainfrom
kube-1735-7
Feb 13, 2026
Merged

node drainer added#228
cirisked merged 2 commits intomainfrom
kube-1735-7

Conversation

@cirisked
Copy link
Contributor

@cirisked cirisked commented Feb 12, 2026

node drainer added, will be used to evict/drain node in future drain node action handler

@cirisked cirisked marked this pull request as ready for review February 12, 2026 10:41
@cirisked cirisked requested a review from a team as a code owner February 12, 2026 10:41
@cirisked cirisked enabled auto-merge (squash) February 12, 2026 10:48
return m
}

func (d *drainer) Drain(ctx context.Context, data DrainRequest) ([]*core.Pod, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the only difference between Drain and Evict is the tryDrain/tryEvict(and log lines).
Do you think is does make sense to remove this duplication? Maybe some wrapper function with would take the tryDrain/tryEvict as parameters and call them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they have different parameters (tryDrain(ctx context.Context, toEvict []*core.Pod, **options meta.DeleteOptions**)) if not delete option i could do something like

func (d *drainer) Drain(ctx context.Context, data DrainRequest) ([]*core.Pod, error) {
	logger := logger.FromContext(ctx, d.log)

	logger.Info("starting drain")
	d.do(ctx, d.tryDrain / d.tryEvict)
	logger.Info("drain finished")

	return failed, nil
}

func (d *drainer) do(ctx context.Context, fn func (ctx context.Context, toEvict []*core.Pod) ([]*core.Pod, []*core.Pod, error)) {
         pods, err := d.list(ctx, data.Node)
	if err != nil ...

	toEvict := d.prioritizePods(pods, data.CastNamespace, data.SkipDeletedTimeoutSeconds)
	if len(toEvict) == 0 ... 

	_, failed, err := fn()
	err = d.waitTerminaition(ctx, data.Node, failed)
	if err != nil {
		return []*core.Pod{}, err
	}
}

but i can't, since i need to pass DeleteOptions param

or u have something else in mind?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I see. My idea was to the one you showed above. In theory we could do smth like:

opts := ...
f := func(ctx, pods) {
  d.tryDrain(ctx, pods, opts)
}
// or
f := func(ctx, pods) {
  d.tryEvict(ctx, pods)
}

d.do(f)

But I'm myself not convinced it's easier to read than just a having two copy-pastes.

@cirisked cirisked merged commit ce7586c into main Feb 13, 2026
3 checks passed
@cirisked cirisked deleted the kube-1735-7 branch February 13, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants