Skip to content

systemvm: serve cloud-domain and cloud-domain-id from their own metadata files - #14157

Open
rootnomad wants to merge 1 commit into
apache:4.20from
rootnomad:fix/vr-metadata-cloud-domain
Open

rootnomad wants to merge 1 commit into
apache:4.20from
rootnomad:fix/vr-metadata-cloud-domain

Conversation

@rootnomad

Copy link
Copy Markdown
Collaborator

Description

On the virtual router, the latest/cloud-domain and latest/cloud-domain-id rewrite rules in systemvm/debian/var/www/html/latest/.htaccess point at the vm-id metadata file, so a guest asking its router for either gets its VM id instead of the domain name or domain id. The router already writes the right cloud-domain and cloud-domain-id files when metadata.allow.expose.domain is enabled, and latest/meta-data/cloud-domain returns them correctly through the generic meta-data/ rule. This points each rule at its own file.

When the domain is not exposed, the old rules also handed out the VM id for these two paths. With this change they return 404, the same as latest/meta-data/cloud-domain.

configure.py (__htaccess) also appends ^cloud-domain$ and ^cloud-domain-id$ rules pointing at the right files when it writes the guest's metadata, but it only appends and never touches the static lines, and the static ^cloud-domain/?$ rules come first in the file, so they win.

The same lines are on 4.20, 4.22 and main, so this targets 4.20.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

N/A

How Has This Been Tested?

Live tested on a KVM zone with an isolated network and a virtual router, requesting the metadata from inside a guest with wget -qO- http://<router>/latest/<path>. The router picks up .htaccess changes on the next request, so the fixed file was applied on the running router. Values are shown by what they matched.

With metadata.allow.expose.domain=true, before the change:

latest/vm-id                        VM id
latest/cloud-domain                 VM id
latest/cloud-domain-id              VM id
latest/meta-data/cloud-domain       domain name
latest/meta-data/cloud-domain-id    domain id

With the change:

latest/vm-id                        VM id
latest/cloud-domain                 domain name
latest/cloud-domain-id              domain id
latest/meta-data/cloud-domain       domain name
latest/meta-data/cloud-domain-id    domain id

With metadata.allow.expose.domain=false and a new guest, before the change:

latest/vm-id                        VM id
latest/cloud-domain                 VM id
latest/cloud-domain-id              VM id
latest/meta-data/cloud-domain       404 Not Found
latest/meta-data/cloud-domain-id    404 Not Found

With the change:

latest/vm-id                        VM id
latest/cloud-domain                 404 Not Found
latest/cloud-domain-id              404 Not Found
latest/meta-data/cloud-domain       404 Not Found
latest/meta-data/cloud-domain-id    404 Not Found

The file is part of cloud-scripts.tgz (the systemvm build copies systemvm/debian/), so routers get it when they are patched on restart.

How did you try to break this feature and the system with this change?

Only the two rules change. latest/vm-id, the other metadata paths and the generic meta-data/ rule return the same values as before, and user data is not touched.

…ata files

The latest/cloud-domain and latest/cloud-domain-id rewrite rules on the
virtual router pointed at the vm-id file, so both returned the VM id
instead of the domain name and domain id. The latest/meta-data/cloud-domain
paths were not affected.
@rootnomad
rootnomad marked this pull request as ready for review September 14, 2026 18:46

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clgtm

@weizhouapache weizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

code lgtm

@DaanHoogland DaanHoogland added this to the 4.20.4 milestone Nov 3, 2026
@rootnomad
rootnomad force-pushed the fix/vr-metadata-cloud-domain branch from fd2d5ad to 7d618c5 Compare December 2, 2026 16:12
@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 16.46%. Comparing base (8261bec) to head (7d618c5).
⚠️ Report is 15 commits behind head on 4.20.

Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #14157      +/-   ##
============================================
+ Coverage     16.38%   16.46%   +0.08%     
- Complexity    13615    13713      +98     
============================================
  Files          5669     5670       +1     
  Lines        501561   501771     +210     
  Branches      60922    60965      +43     
============================================
+ Hits          82168    82610     +442     
+ Misses       410185   409905     -280     
- Partials       9208     9256      +48     
Flag Coverage Δ
uitests 4.16% <ø> (+<0.01%) ⬆️
unittests 17.33% <ø> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants