Skip to content

Fix data being replicated on VM's metadata file in VR #10987

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

Merged

Conversation

GutoVeronezi
Copy link
Contributor

@GutoVeronezi GutoVeronezi commented Jun 6, 2025

Description

While creating VMs, ACS configures HTTPd on the VR to serve metadata files to be consumed by CloudInit. However, the file /var/www/html/meta-data/<vm-ip>/metadata is appended with the same content every time a VM is started through CloudStack, causing the file to have replicated lines; as VMs are created/started, this file grows ad infinitum, consuming the VR's storage.

This PR intends to fix this metadata replication on the VRs.

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

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Without the changes:

  1. I created a network;
  2. I created a VM;
  3. I checked the VM's metadata file in the VR, and observed that it had only a single entry for each attribute;
  4. I checked the metadata in the VM;
  5. I stopped the VM;
  6. I started the VM again;
  7. I checked that the VM's metadata file in the VR had duplicated entries for every attribute;
  8. I checked the metadata in the VM;

With the changes:

  1. I created a network;
  2. I created a VM;
  3. I checked the VM's metadata file in the VR, and observed that it had only a single entry for each attribute;
  4. I checked the metadata in the VM;
  5. I stopped the VM;
  6. I started the VM again;
  7. I checked the VM's metadata file in the VR, and observed that it had only a single entry for each attribute;
  8. I checked the metadata in the VM;

Copy link

codecov bot commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 16.57%. Comparing base (41b4f0a) to head (2172c9e).
Report is 27 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #10987      +/-   ##
============================================
- Coverage     16.57%   16.57%   -0.01%     
+ Complexity    13870    13869       -1     
============================================
  Files          5719     5719              
  Lines        507200   507200              
  Branches      61574    61574              
============================================
- Hits          84093    84075      -18     
- Misses       413688   413711      +23     
+ Partials       9419     9414       -5     
Flag Coverage Δ
uitests 3.96% <ø> (ø)
unittests 17.45% <ø> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

Comment on lines 909 to +911
fh = open(metamanifest, "a+")
self.__exflock(fh)
fh.seek(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

@GutoVeronezi , I think your intention is

Suggested change
fh = open(metamanifest, "a+")
self.__exflock(fh)
fh.seek(0)
fh = open(metamanifest, “w+")
self.__exflock(fh)

opeing with a+ will not truncate the previous version, but only overwrite data afaik.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a is for appending; + is for allow reading, however, the pointer must be set to 0 to the validation work properly. w would overwrite the data. This is the same as #10254

Copy link
Contributor

Choose a reason for hiding this comment

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

you are right, I missed the fh.read() on the next line

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm

Copy link
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

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

code lgtm
Not tested

Copy link
Contributor

@harikrishna-patnala harikrishna-patnala left a comment

Choose a reason for hiding this comment

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

tested in my existing VR with these changes, LGTM

@DaanHoogland DaanHoogland merged commit 380884e into apache:main Jun 13, 2025
22 of 25 checks passed
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.

4 participants