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

Conditionally set AWS network configuration directly on EC2 request if associate public ip is true #447

Merged
merged 2 commits into from
Apr 21, 2020

Conversation

jzyeezy
Copy link
Contributor

@jzyeezy jzyeezy commented Apr 1, 2020

I upgraded the EC2 plugin to the latest available version (ec2-1.49.1) and found that our cloud was spinning up workers with null public DNS hostnames:

An agent trying to connect would show these logs:

Connecting to null on port 22, with timeout 10000.

Additionally, I observed in the EC2 UI that this new instance's public DNS ip address was blank (i-003... corresponds to ec2-1.49.1; i-00f... corresponds to ec2-1.45).

Screen Shot 2020-04-01 at 5 13 51 PM

The underlying AWS VPC, subnet, and security groups were left unchanged between the plugin versions. Our EC2 cloud template is configured (and also unchanged) with the "Public DNS" connection strategy and "Associate Public IP" set to false.

Under ec2-1.49.1, the necessary AWS network configuration needed to provision a new EC2 instance is only set on the request's network interface specification, which seems to be inadequate for an instance to be created with a public DNS name.

Reviving the getAssociatePublicIP() conditions to set the target subnet and security group ids on the RunInstancesRequest culminates in the correct AWS EC2 request to provision a new worker with our current configuration.

I smoke-tested by uploading a patched plugin with these changes. New instances are created and can connect to master once again!

Copy link
Member

@jvz jvz left a comment

Choose a reason for hiding this comment

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

Can you supply unit tests for this?

@jzyeezy
Copy link
Contributor Author

jzyeezy commented Apr 2, 2020

@jvz I tried to look into that before opening, but it doesn't look like there were ever tests removed as part of removing the conditions that I added back in this PR. See git diff ec2-1.45..ec2-1.49.1 src/test/java/hudson/plugins/ec2/SlaveTemplateTest.java. I'm not sure what would be the most helpful kind of test to add here?

@jvz
Copy link
Member

jvz commented Apr 2, 2020

Any tests that would fail if your PR were changed incorrectly in the future. Regression tests mainly. Otherwise, features pop in and out of existence over time when their expected behavior is unknown. :)

@jzyeezy
Copy link
Contributor Author

jzyeezy commented Apr 2, 2020

Ok, I'll have to look into adding tests on another day. I do want to point this PR out though.

@jvz
Copy link
Member

jvz commented Apr 2, 2020

If you find there's no reasonable way to add tests, let me know. I don't want to block the PR for no reason.

accordingly based on associatePublicIp value
@jzyeezy
Copy link
Contributor Author

jzyeezy commented Apr 7, 2020

@jvz I have added a couple tests in the latest commit. Please let me know if there's a better direction than the one I took!

Copy link
Member

@jvz jvz left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@jvz jvz requested review from varyvol and res0nance April 7, 2020 16:13
@jzyeezy
Copy link
Contributor Author

jzyeezy commented Apr 20, 2020

@jvz when will this get merged?

@jvz
Copy link
Member

jvz commented Apr 20, 2020

I'm not the primary maintainer here, so I'm not really sure. @varyvol?

@res0nance
Copy link
Contributor

I think this is ok to merge as is, I left it to see if others wanted to take a look at it

@res0nance res0nance merged commit 1995146 into jenkinsci:master Apr 21, 2020
@res0nance
Copy link
Contributor

Looks like this caused an issue https://issues.jenkins-ci.org/browse/JENKINS-62090
@jzyeezy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants