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 IMDSv2 support to AwsCandidateHarvester #294

Closed
wants to merge 1 commit into from

Conversation

dsmeytis
Copy link
Contributor

Hello, AWS recommend to disable IMDSv1 support for EC2 instances: https://aws.amazon.com/blogs/security/get-the-full-benefits-of-imdsv2-and-disable-imdsv1-across-your-aws-infrastructure/
However it breaks AwsCandidateHarvester functionality because REST endpoints it uses to detect EC2 and obtain private/public IPs become unavailable. I would like to propose the fix that will work for both IMDSv1 and IMDSv2:

  • doTestEc2() will now try to obtain an API token as EC2_TEST_URL is unavailable without a token.
  • added parameters to fetch() to set a method and pass required headers.

@jitsi-jenkins
Copy link

Hi, thanks for your contribution!
If you haven't already done so, could you please make sure you sign our CLA (https://jitsi.org/icla for individuals and https://jitsi.org/ccla for corporations)? We would unfortunately be unable to merge your patch unless we have that piece :(.

@dsmeytis
Copy link
Contributor Author

already signed

@@ -183,11 +206,10 @@ private static boolean doTestEc2()
{
try
{
URLConnection conn = new URL(EC2_TEST_URL).openConnection();
conn.setConnectTimeout(500); //don't hang for too long
Copy link
Member

Choose a reason for hiding this comment

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

Can you bring back the short timeout please?

@@ -21,6 +21,8 @@

import java.io.*;
import java.net.*;
import java.util.Collections;
Copy link
Member

Choose a reason for hiding this comment

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

Change this to a * import please

@bgrozev
Copy link
Member

bgrozev commented Dec 2, 2024

Thanks for the contribution! I left a couple of minor requests. I'll run a manual test and let you know if I have more.

Confirmed CLA. Jenkins, please add to whitelist

@bgrozev
Copy link
Member

bgrozev commented Dec 2, 2024

Looks good after testing

@dsmeytis
Copy link
Contributor Author

dsmeytis commented Dec 2, 2024

hi @bgrozev, thanks for the review! Actually for my deployment I ended up with the java.net.http.HttpClient implementation. If you wish I can push updated solution, otherwise I'll address your requests and we'll proceed with it.

@bgrozev
Copy link
Member

bgrozev commented Dec 2, 2024

Sure, unless it's a large change let's go with HttpClient

@dsmeytis
Copy link
Contributor Author

dsmeytis commented Dec 3, 2024

@bgrozev please take a look at #297

@bgrozev bgrozev closed this Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants