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

Fix issue for checking if app is running in an OCI instance which causes Instance Principal auth to fail #8197

Merged

Conversation

klustria
Copy link
Member

@klustria klustria commented Jan 5, 2024

Description

The call to Region.getRegionFromImds() in OciAvailabilityDefault.runningOnOci(OciConfig ociConfig) is returning null causing Instance Principal authentication to not work because the code thinks it is not running in an OCI instance. To resolve this issue, passing in the Metadata Service Url in Region.getRegionFromImds() helps return a valid value.

Tested and validated this change to be working in a helidon app that is running in an OCI instance.

Documentation

If no doc impact: None

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jan 5, 2024
@trentjeff trentjeff added the OCI label Jan 5, 2024
@@ -46,7 +46,7 @@ static boolean runningOnOci(OciConfig ociConfig) {
return false;
}

return (Region.getRegionFromImds() != null);
return (Region.getRegionFromImds("http://" + ociConfig.imdsHostName() + "/opc/v2/") != null);
Copy link
Member

Choose a reason for hiding this comment

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

What is the issue with calling the no arg method? It seems like we should not need to pass the path.

If we really must take ownership of the path, then "/opc/v2/" should be configurable. We should therefore follow-up to make that configurable - perhaps using oci.yaml.

Copy link
Member Author

Choose a reason for hiding this comment

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

without the arg, it is returning null. It can be fixed by using Region.registerFromInstanceMetadataService() but this uses http://169.254.169.254/opc/v2/. Our code however allows IMDS host to be configurable via ociConfig.imdsHostName(), hence why we cannot use Region.registerFromInstanceMetadataService(). The IMDS URL is in the format, http:///opc/v2/ hence why I derived it and hence why "/opc/v2/" does not need to be configurable?

@klustria
Copy link
Member Author

klustria commented Jan 5, 2024

This PR is potential fix for #8191

@klustria klustria self-assigned this Jan 6, 2024
@klustria klustria modified the milestone: 4.0.3 Jan 9, 2024
@klustria klustria merged commit fa7a543 into helidon-io:main Jan 9, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement. OCI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants