Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for frequent loops when provisioningrequest is encountered in last iteration #7271

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

Duke0404
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

Created lastProvisioningRequestSeenTime which gets updated whenever a provisioningrequest is encountered in an iteration, which is used when frequent loops is enabled to start next iteration without delay.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Support for frequent loops when ProvisioiningRequest is encountered in last loop.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


cc: @yaroslava-serdiuk @aleksandra-malinowska @kawych

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 10, 2024
@k8s-ci-robot k8s-ci-robot added area/cluster-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 10, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @Duke0404. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 10, 2024
@aleksandra-malinowska
Copy link
Contributor

/ok-to-test

@kawych will you be able to review?

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 10, 2024
@yaroslava-serdiuk
Copy link
Contributor

@aleksandra-malinowska I can review later today

Copy link
Contributor

@yaroslava-serdiuk yaroslava-serdiuk left a comment

Choose a reason for hiding this comment

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

Have a small comment, otherwise LGTM

cluster-autoscaler/main.go Outdated Show resolved Hide resolved
@Duke0404 Duke0404 force-pushed the freqloops branch 2 times, most recently from 2f629ac to 169b99c Compare September 12, 2024 17:12
@k8s-ci-robot k8s-ci-robot added the area/provider/aws Issues or PRs related to aws provider label Sep 12, 2024
cluster-autoscaler/processors/provreq/injector.go Outdated Show resolved Hide resolved
cluster-autoscaler/loop/trigger.go Outdated Show resolved Hide resolved
cluster-autoscaler/loop/trigger.go Outdated Show resolved Hide resolved
cluster-autoscaler/loop/trigger.go Outdated Show resolved Hide resolved
@Duke0404 Duke0404 force-pushed the freqloops branch 2 times, most recently from 7fe3b40 to fc3ca6b Compare September 15, 2024 22:07
cluster-autoscaler/main.go Outdated Show resolved Hide resolved
cluster-autoscaler/main.go Outdated Show resolved Hide resolved
@kawych
Copy link
Contributor

kawych commented Sep 16, 2024

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 16, 2024
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 16, 2024
cluster-autoscaler/loop/trigger.go Outdated Show resolved Hide resolved
cluster-autoscaler/loop/trigger.go Outdated Show resolved Hide resolved
@Duke0404 Duke0404 force-pushed the freqloops branch 2 times, most recently from 9ba7e09 to 9cfa863 Compare September 23, 2024 14:58
cluster-autoscaler/loop/trigger.go Outdated Show resolved Hide resolved
t.initialized = true
}

// provisioningRequestWasProcessed is used to check if provisioningRequestProcessTimeGetter is not nil and a provisioning request was processed in the last iteration
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: pls remove the comments here and below. Comments are not required for private function and these functions are short and self-explanatory enough to not require extra insight.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed comment here but kept the comment on triggerNextIteration, because the behaviour of the function is not entirely self-explanatory imo.

cluster-autoscaler/loop/trigger.go Outdated Show resolved Hide resolved
@kawych
Copy link
Contributor

kawych commented Sep 24, 2024

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 24, 2024
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 24, 2024
@aleksandra-malinowska
Copy link
Contributor

/cc @x13n can you approve? I see you reviewed #6589, this expands on it by adding recently processing a ProvisioningRequest as trigger.

@kawych
Copy link
Contributor

kawych commented Sep 26, 2024

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 26, 2024
cluster-autoscaler/loop/trigger.go Outdated Show resolved Hide resolved
klog.Infof("Autoscaler loop triggered immediately after a productive iteration")
}
return
t.triggerNextIteration("Autoscaler loop triggered immediately after a productive iteration")
Copy link
Member

Choose a reason for hiding this comment

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

Isn't an iteration that processed a provisioning request also "productive"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessarily, because a ProvisioningRequest can be marked as failed and we will still trigger the next loop immidiately

Copy link
Member

Choose a reason for hiding this comment

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

Sure, though my point is it maybe makes sense to be a bit more explicit about the reason, as "productive" can mean different things. Autoscaler loop triggered immediately after scale up/Autoscaler loop triggered immediately after scale down?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added separate logs for scale up and scaled own.

}
}

// Initialize initializes the LoopTrigger object by providing a pointer to the UnschedulablePodObserver
func (t *LoopTrigger) Initialize(podObserver *UnschedulablePodObserver) {
Copy link
Member

Choose a reason for hiding this comment

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

What is the benefit of splitting initialization into 2 phases? This comes with additional complexity like the need to suddenly handle errors when waiting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The aim was to make minimal changes to the args and return values of the buildAutoscaler function.

The trigger can only be initialized within the buildAutoscaler function as the injector is present there. @yaroslava-serdiuk felt that creating the injector in the run function and passing that to buildAutoscaler was not good because the injector is only a relevant component for CA if the user has ProvisioningRequests enabled and thus should not be a part of the buildAutoscaler args.

The podObserver can only be created within the run function as it requires the background context of the function. Therefore, having an initialize method which serves as a setter for the podObserver was deemed as the best solution.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for sharing the background!

I think the context can safely be created before the call to buildAutoscaler and passed there - you can then remove two-phase init and actually simplify podObserver creation a bit too by reusing autoscaling options available there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified accordingly.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 12, 2024
@Duke0404 Duke0404 requested a review from x13n October 12, 2024 17:08
cluster-autoscaler/main.go Outdated Show resolved Hide resolved
cluster-autoscaler/loop/trigger.go Outdated Show resolved Hide resolved
@x13n
Copy link
Member

x13n commented Oct 15, 2024

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 15, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Duke0404, x13n

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 15, 2024
@k8s-ci-robot k8s-ci-robot merged commit bb94d27 into kubernetes:master Oct 15, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cluster-autoscaler area/provider/aws Issues or PRs related to aws provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants