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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Generate event when instance fails to launch because no subnets available in an availability zone #1445

Merged
merged 1 commit into from
Jan 16, 2020

Conversation

aaroniscode
Copy link
Contributor

@aaroniscode aaroniscode commented Dec 23, 2019

What this PR does / why we need it:
When a user specifies the availabilityZone or failureDomain in a AWSMachine and there are no available subnets to launch the EC2 instance, there are no events registered with the AWSMachine. This PR adds the event.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of #1425

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 23, 2019
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Dec 23, 2019
@@ -159,6 +159,9 @@ func (s *Service) CreateInstance(scope *scope.MachineScope) (*infrav1.Instance,

sns := s.scope.Subnets().FilterPrivate().FilterByZone(*availabilityZone)
if len(sns) == 0 {
record.Warnf(scope.AWSMachine, "FailedCreate",
"Failed to create instance: no subnets available in availaibility zone %q", *availabilityZone)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Failed to create instance: no subnets available in availaibility zone %q", *availabilityZone)
"Failed to create instance: no subnets available in availability zone %q", *availabilityZone)

@@ -159,6 +159,9 @@ func (s *Service) CreateInstance(scope *scope.MachineScope) (*infrav1.Instance,

sns := s.scope.Subnets().FilterPrivate().FilterByZone(*availabilityZone)
if len(sns) == 0 {
record.Warnf(scope.AWSMachine, "FailedCreate",
"Failed to create instance: no subnets available in availaibility zone %q", *availabilityZone)

return nil, awserrors.NewFailedDependency(
errors.Errorf("failed to run machine %q, no subnets available in availaibility zone %q",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
errors.Errorf("failed to run machine %q, no subnets available in availaibility zone %q",
errors.Errorf("failed to run machine %q, no subnets available in availability zone %q",

Copy link
Member

@detiber detiber left a comment

Choose a reason for hiding this comment

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

minor spelling nit, but otherwise lgtm

@ncdc
Copy link
Contributor

ncdc commented Dec 23, 2019

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 23, 2019
@ncdc
Copy link
Contributor

ncdc commented Dec 23, 2019

Looking at the code in CreateInstance, there are other places where we might return an error without recording an event. Do we want to reevaluate this function in terms of event generation? Perhaps move them up a level (and maybe reevaluate the "failed dependency" errors too)?

@aaroniscode
Copy link
Contributor Author

Looking at the code in CreateInstance, there are other places where we might return an error without recording an event. Do we want to reevaluate this function in terms of event generation? Perhaps move them up a level (and maybe reevaluate the "failed dependency" errors too)?

@ncdc I can take a look at CreateInstance and see if I can identity all the places where events should be generated and perhaps look at a different approach. Will likely be next week.

@randomvariable
Copy link
Member

@aaroniscode, @ncdc what do you want to do with this PR?

@ncdc
Copy link
Contributor

ncdc commented Jan 15, 2020

It's definitely helpful, but it doesn't cover 100% of the possible errors where we are not generating events. I guess let's get the 2 typos fixed and merge it for now until we have a more comprehensive solution.

@vincepri
Copy link
Member

If we merge this but it's not complete, we shouldn't close the related issue

@randomvariable
Copy link
Member

Edited PR desc so it won't close the issue

@aaroniscode
Copy link
Contributor Author

spelling fixed

/unhold
/assign @ncdc

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 16, 2020
@vincepri
Copy link
Member

vincepri commented Jan 16, 2020

@aaroniscode It looks like the updated version with the fixed spelling didn't get pushed?

@aaroniscode
Copy link
Contributor Author

@aaroniscode It looks like the updated version with the fixed spelling didn't get pushed?

sorry @vincepri was git error on my side ... fixed now

@ncdc
Copy link
Contributor

ncdc commented Jan 16, 2020

/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 Jan 16, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aaroniscode, ncdc

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 Jan 16, 2020
@k8s-ci-robot k8s-ci-robot merged commit 9b99309 into kubernetes-sigs:master Jan 16, 2020
@aaroniscode aaroniscode deleted the subnet_not_available_event branch January 18, 2020 04:00
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants