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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
* Copyright (c) 2023, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -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?

}

static boolean canReach(String address,
Expand Down