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 additional error codes for invalid reservations to GCE client #6093

Merged
merged 1 commit into from
Sep 11, 2023

Conversation

hbostan
Copy link
Contributor

@hbostan hbostan commented Sep 7, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds more error codes related to the reservations increasing the visibility of GCE Errors.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

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

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/provider/gce labels Sep 7, 2023
@k8s-ci-robot k8s-ci-robot added area/cluster-autoscaler size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 7, 2023
regexp.MustCompile("only compatible with Aggregate Reservations"),
regexp.MustCompile("instance configuration is optimized for ([a-z0-9*-]+) workloads"),
regexp.MustCompile("should be a ([a-zA-Z0-9*-]+) VM Family for instance with ([a-zA-Z0-9*\\ -]*) machine type"),
regexp.MustCompile("is not supported for aggregate reservations. It must be one of"),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you check this with a prefix "VM Family: %s "? Makes it a little bit clearer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

regexp.MustCompile("must use ReservationAffinity of"),
regexp.MustCompile("The reservation must exist in the same project as the instance"),
regexp.MustCompile("only compatible with Aggregate Reservations"),
regexp.MustCompile("instance configuration is optimized for ([a-z0-9*-]+) workloads"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use the other part of the error message: "Please target a reservation with workload_type" (makes it clear that the error is about reservations and what's it about).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

regexp.MustCompile("The reservation must exist in the same project as the instance"),
regexp.MustCompile("only compatible with Aggregate Reservations"),
regexp.MustCompile("instance configuration is optimized for ([a-z0-9*-]+) workloads"),
regexp.MustCompile("should be a ([a-zA-Z0-9*-]+) VM Family for instance with ([a-zA-Z0-9*\\ -]*) machine type"),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you check this with a prefix "AggregateReservation VMFamily: %s?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

"must use ReservationAffinity of",
"The reservation must exist in the same project as the instance",
"only compatible with Aggregate Reservations",
regexReservationErrors := []*regexp.Regexp{
Copy link
Member

Choose a reason for hiding this comment

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

This list is static. Can we compile the regexps once, rather than on every call to this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the regexp slice to a var block.

for _, rErr := range reservationErrors {
if strings.Contains(errorMessage, rErr) {
for _, re := range regexReservationErrors {
if re.MatchString(errorMessage) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm concerned that this change will make the matching more restrictive.
Old checkers uses a contains logic, wheres now we're doing a full-match (I think).
This could potentially break existing logic where we would have stacktrace to the errorMessage?

Can we explore if we can do a regex contains?

Copy link
Member

Choose a reason for hiding this comment

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

It will work: in order to do a full match you'd have to include ^ and $ in the regex string. It's not anchored by default.

@x13n
Copy link
Member

x13n commented Sep 11, 2023

/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 Sep 11, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hbostan, 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 Sep 11, 2023
@k8s-ci-robot k8s-ci-robot merged commit 3852f35 into kubernetes:master Sep 11, 2023
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/gce 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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants