Skip to content

metadata: add Oracle Cloud IMDSv2 service#205

Open
chl117 wants to merge 1 commit into
cloudbase:masterfrom
chl117:oracle_service_imdsv2
Open

metadata: add Oracle Cloud IMDSv2 service#205
chl117 wants to merge 1 commit into
cloudbase:masterfrom
chl117:oracle_service_imdsv2

Conversation

@chl117

@chl117 chl117 commented Jul 10, 2026

Copy link
Copy Markdown

Summary

Cloudbase-Init did not have a native Oracle Cloud Infrastructure metadata service. OCI Instance Metadata Service v2 exposes metadata under /opc/v2/ and requires every request to include:

Authorization: Bearer Oracle

Without an OCI-specific provider, Cloudbase-Init cannot retrieve OCI metadata through IMDSv2 when legacy IMDSv1 access is disabled. Metadata-dependent operations such as retrieving the instance ID, configuring the hostname, and processing user data are therefore unavailable.

This PR adds OracleCloudService, which:

  • Retrieves the instance ID and hostname from OCI IMDSv2.
  • Retrieves and base64-decodes instance user data.
  • Adds the required authorization header to every metadata request.
  • Adds the metadata IP route when configured.
  • Provides OCI-specific metadata URL and HTTPS options.
  • Registers the new oraclecloud configuration group.

The authorization header is added by overriding the service’s HTTP request method, following the existing GCE and MaaS provider patterns. No shared metadata base-class changes are required.

How to reproduce

  1. Launch a Windows instance in OCI with legacy IMDSv1 access disabled.

  2. Configure Cloudbase-Init to use:

    cloudbaseinit.metadata.services.oraclecloudservice.OracleCloudService
    
  3. An unauthenticated request to the following IMDSv2 endpoint is rejected:

    http://169.254.169.254/opc/v2/instance/id
    
  4. The same request succeeds when it includes:

    Authorization: Bearer Oracle
    

OCI documents the IMDSv2 endpoints and authorization requirement here:

https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/gettingmetadata.htm

Test plan

New unit tests cover:

  • Successful service loading.
  • Service load failure handling.
  • OCI authorization-header injection.
  • Preservation of caller-provided headers.
  • Instance ID retrieval.
  • Hostname retrieval.
  • Base64 user-data decoding.

Oracle service tests:

stestr run \
  cloudbaseinit.tests.metadata.services.test_oraclecloudservice

# Ran: 6
# Passed: 6
# Failed: 0

Full Python test suite:

stestr run --slowest

# Ran: 1075
# Passed: 1075
# Failed: 0

Repository-wide lint:

flake8
# Passed

DCO sign-off on the commit.

Related

OCI IMDSv2 exposes instance metadata under /opc/v2 and requires an
Authorization: Bearer Oracle header on every request [1].
Cloudbase-Init does not have an OCI-specific metadata provider, so it
cannot use the OCI IMDSv2 endpoints when legacy IMDSv1 access is
disabled.

Add OracleCloudService to retrieve the instance ID, hostname, and
base64-encoded user data. Add the required authorization header through
the service's HTTP request override, following the existing GCE and
MaaS patterns. Register the related oraclecloud configuration options
and add unit-test coverage for service loading, request headers, and
metadata retrieval.

[1] https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/gettingmetadata.htm

AI-assisted contribution: I reviewed the change and submit it under
the DCO terms at
https://github.com/cloudbase/cloudbase-init/blob/master/DCO#L16
(clause (a) — the contribution is mine).

Signed-off-by: Lucas Quinney <lucas.quinney@oracle.com>
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.

1 participant