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 addresses to machine status #1314

Merged
merged 1 commit into from
Nov 7, 2019

Conversation

rsmitty
Copy link
Contributor

@rsmitty rsmitty commented Oct 31, 2019

What this PR does / why we need it:
This PR is pretty similar to one merged in the GCP provider a few hours ago.

It will add the ability to fish out the internal and external IPs
associated with an awsmachine resource and populate those values in
.status.addresses.

Happy to backport to release-0.4 after merge as well.

Signed-off-by: Spencer Smith robertspencersmith@gmail.com

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 31, 2019
@k8s-ci-robot
Copy link
Contributor

Welcome @rsmitty!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-aws 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-aws has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @rsmitty. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 31, 2019
controllers/awsmachine_controller.go Outdated Show resolved Hide resolved
controllers/awsmachine_controller.go Outdated Show resolved Hide resolved
controllers/awsmachine_controller.go Outdated Show resolved Hide resolved
controllers/awsmachine_controller.go Outdated Show resolved Hide resolved
controllers/awsmachine_controller.go Outdated Show resolved Hide resolved
controllers/awsmachine_controller.go Outdated Show resolved Hide resolved
pkg/cloud/scope/machine.go Outdated Show resolved Hide resolved
pkg/cloud/scope/machine.go Outdated Show resolved Hide resolved
controllers/awsmachine_controller.go Outdated Show resolved Hide resolved
@rsmitty
Copy link
Contributor Author

rsmitty commented Nov 1, 2019

Went ahead and amended the v1 -> corev1 import issues. Thanks for the heads up there. I need a little more time to explore the ENI stuff. Will tackle that this morning.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 1, 2019
@@ -485,7 +485,8 @@ func (s *Service) UpdateResourceTags(resourceID *string, create map[string]strin
return nil
}

func (s *Service) getInstanceENIs(instanceID string) ([]*ec2.NetworkInterface, error) {
// GetInstanceENIs returns a list of ec2 network interfaces for a given instance
func (s *Service) GetInstanceENIs(instanceID string) ([]*ec2.NetworkInterface, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this a public func so that I could call it from machine controller.

@@ -310,16 +310,16 @@ func (s *Service) runInstance(role string, i *infrav1.Instance) (*infrav1.Instan
}

if len(i.NetworkInterfaces) > 0 {
instances := make([]*ec2.InstanceNetworkInterfaceSpecification, 0, len(i.NetworkInterfaces))
netInterfaces := make([]*ec2.InstanceNetworkInterfaceSpecification, 0, len(i.NetworkInterfaces))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these were mistakenly called instances I think. updated the name to be more clear that they're network interfaces.

func (r *AWSMachineReconciler) getAddresses(instance *infrav1.Instance, ec2svc *ec2.Service) ([]corev1.NodeAddress, error) {
addresses := []corev1.NodeAddress{}

enis, err := ec2svc.GetInstanceENIs(instance.ID)
Copy link
Contributor Author

@rsmitty rsmitty Nov 1, 2019

Choose a reason for hiding this comment

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

every instance has one or more ENIs attached regardless of if it's specified in the spec, as you can have a pre-created ENI or an ephemeral one for the instance. changed the logic to just range through the ENIs and fish out IPs and DNS names.

@rsmitty
Copy link
Contributor Author

rsmitty commented Nov 1, 2019

@detiber I reworked the logic for this to just look for the ENIs directly. PTAL and see what you think. It results in a pretty nice status output like:

...
  status:
    addresses:
    - address: ip-172-31-11-240.ec2.internal
      type: InternalDNS
    - address: 172.31.11.240
      type: InternalIP
    - address: ec2-x-x-x-x.compute-1.amazonaws.com
      type: ExternalDNS
    - address: x.x.x.x
      type: ExternalIP
...

@rsmitty
Copy link
Contributor Author

rsmitty commented Nov 5, 2019

@detiber gentle ping on this when you get a second.

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

Few comments, logic LGTM

/ok-to-test

controllers/awsmachine_controller.go Outdated Show resolved Hide resolved
@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 Nov 6, 2019
@rsmitty rsmitty force-pushed the master branch 3 times, most recently from d8fccd5 to 7c8b1ea Compare November 6, 2019 19:16
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 6, 2019
@rsmitty rsmitty force-pushed the master branch 2 times, most recently from 4a23102 to f722910 Compare November 6, 2019 19:22
@rsmitty
Copy link
Contributor Author

rsmitty commented Nov 6, 2019

Okay, @vincepri, I think I've got a pretty decent implementation of what we talked about earlier today. Updated the logic to add an addresses field to the instance structs, as well as moving the logic to populate that field into the SDKToInstance function. It then bubbles up from there to get added into the awsmachine resource's status inside the controller.

@rsmitty
Copy link
Contributor Author

rsmitty commented Nov 6, 2019

/retest

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve
/milestone v0.5.0
/assign @detiber @randomvariable

@k8s-ci-robot k8s-ci-robot added this to the v0.5.0 milestone Nov 7, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rsmitty, vincepri

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 Nov 7, 2019
This PR will add the ability to fish out the internal and external IPs
associated with an awsmachine resource and populate those values in
.status.addresses.

Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
@detiber
Copy link
Member

detiber commented Nov 7, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 7, 2019
@k8s-ci-robot k8s-ci-robot merged commit 2f2c8da into kubernetes-sigs:master Nov 7, 2019
@k8s-ci-robot
Copy link
Contributor

@rsmitty: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-cluster-api-provider-aws-make-conformance 9cf4eee link /test pull-cluster-api-provider-aws-make-conformance

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

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. 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.

None yet

5 participants