Skip to content

[WIP] Add support to update secondary and primary storage URLs#13193

Draft
Pearl1594 wants to merge 3 commits into
mainfrom
support-update-pri-sec-stg-url
Draft

[WIP] Add support to update secondary and primary storage URLs#13193
Pearl1594 wants to merge 3 commits into
mainfrom
support-update-pri-sec-stg-url

Conversation

@Pearl1594
Copy link
Copy Markdown
Contributor

@Pearl1594 Pearl1594 commented May 19, 2026

Description

This PR fixes: #11742

Adds support to update the URL of primary and secondary stores. However, the support is limited to API and not extended to the UI as this is an operation that if performed without caution can lead to issues - data loss.

Secondary store:
The store needs to be in read-only mode before attempting to change the url.
Secondary storage VM needs to be recreated to remount the new store

Primary store:
The primary store needs to be in Maintenance mode to proceed with updating the URL
The update of URL was previously purely cosmetic / informational ie updated in the database - details table. This continues to be true for storage pools other than nfs and gluster
For NFS and Gluster, if the URL is changed, it propagates it to the connected hosts and attempts to remove the old store and add the new one
In case , no hosts are found, it only changes the URL in the DB and this would require a MS restart to propagate to the host.

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):

How Has This Been Tested?

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

@Pearl1594
Copy link
Copy Markdown
Contributor Author

Pearl1594 commented May 19, 2026

@DaanHoogland do you think we need to expose updating this via UI or leave this as a API only field? I feel it could be a bit of a dangerous operation should it be used incorrectly.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 30.76923% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.12%. Comparing base (522283b) to head (bb8f28c).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...ain/java/com/cloud/storage/StorageManagerImpl.java 22.07% 56 Missing and 4 partials ⚠️
.../hypervisor/kvm/storage/LibvirtStorageAdaptor.java 65.21% 3 Missing and 5 partials ⚠️
...api/command/admin/storage/UpdateImageStoreCmd.java 0.00% 3 Missing ⚠️
...src/main/java/com/cloud/server/StatsCollector.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13193      +/-   ##
============================================
+ Coverage     18.08%   18.12%   +0.04%     
- Complexity    16718    16790      +72     
============================================
  Files          6037     6037              
  Lines        542580   543893    +1313     
  Branches      66427    66757     +330     
============================================
+ Hits          98136    98597     +461     
- Misses       433417   434227     +810     
- Partials      11027    11069      +42     
Flag Coverage Δ
uitests 3.51% <ø> (ø)
unittests 19.29% <30.76%> (+0.04%) ⬆️

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.

@DaanHoogland
Copy link
Copy Markdown
Contributor

@DaanHoogland do you think we need to expose updating this via UI or leave this as a API only field? I feel it could be a bit of a dangerous operation should it be used incorrectly.

I agree, let limit to API

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Comment thread server/src/main/java/com/cloud/storage/StorageManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/storage/StorageManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/storage/StorageManagerImpl.java
Comment on lines +4222 to +4227
if (url != null) {
if (!imageStoreVO.isReadonly()) {
throw new InvalidParameterValueException("Image store must be set to read-only (maintenance) state before its URL can be changed. " +
"Please set readOnly=true on the image store first.");
}
imageStoreVO.setUrl(url);
Comment on lines +4222 to +4228
if (url != null) {
if (!imageStoreVO.isReadonly()) {
throw new InvalidParameterValueException("Image store must be set to read-only (maintenance) state before its URL can be changed. " +
"Please set readOnly=true on the image store first.");
}
imageStoreVO.setUrl(url);
}
Comment on lines +76 to +81
description = "the URL of the storage pool. Supported only for NFS and Gluster pool type." +
"The pool must be in Maintenance mode before changing the URL. WARNING: use this parameter" +
"with caution. It is intended for failover scenarios where the storage content is already " +
"fully mirrored at the new location. Pointing to a new location without ensuring complete " +
"data parity will result in data loss or corruption. After the URL is updated, the new mount" +
"is applied to all connected hosts or restart the Management server",
Comment on lines 1306 to +1336
if (cmd.getUrl() != null) {
details.put("url", cmd.getUrl());

// Updating host/path/port and propagating the remount to agents is only
// supported for NFS and Gluster pools. For other types of storage pools, the URL is just informational and won't be used for actual connection, so we don't need to parse and propagate it.
StoragePoolType poolType = storagePool.getPoolType();
if (poolType == StoragePoolType.NetworkFilesystem || poolType == StoragePoolType.Gluster) {
if (!storagePool.isInMaintenance()) {
throw new InvalidParameterValueException("Storage pool must be in Maintenance state before its URL can be changed. " +
"Please put the pool into maintenance first.");
}
URI newUri;
try {
newUri = new URI(cmd.getUrl());
} catch (URISyntaxException e) {
throw new InvalidParameterValueException("Invalid URL format: " + cmd.getUrl());
}
storagePool.setHostAddress(newUri.getHost());
storagePool.setPath(newUri.getPath());
if (newUri.getPort() != -1) {
storagePool.setPort(newUri.getPort());
}
}
}
_storagePoolDao.update(id, storagePool);
_storagePoolDao.updateDetails(id, details);
((PrimaryDataStoreLifeCycle) dataStoreLifeCycle).updateStoragePool(storagePool, details);
StoragePoolType poolType = storagePool.getPoolType();
if (cmd.getUrl() != null &&
(poolType == StoragePoolType.NetworkFilesystem || poolType == StoragePoolType.Gluster)) {
propagateStoragePoolUrlChangeToHosts(storagePool);
Comment on lines +4222 to +4226
if (url != null) {
if (!imageStoreVO.isReadonly()) {
throw new InvalidParameterValueException("Image store must be set to read-only (maintenance) state before its URL can be changed. " +
"Please set readOnly=true on the image store first.");
}
@Pearl1594
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@Pearl1594 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
28.3% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube Cloud

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@blueorangutan
Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17965

@Pearl1594
Copy link
Copy Markdown
Contributor Author

@sureshanaparti I'd like some advice, as part of addressing this improvement request, I attempted to allow changing primary store url and let it propagate to the hosts, and remount the stores on the host, but it's only taken care of for kvm. Now Im wondering :

  • if we should either keep the operation of mounting the stores on the host out of this scope and let that be handled manually by operators OR
  • Not allow the change of url for primary store.

For secondary store it's alright as we can restart the SSVM.

@Pearl1594 Pearl1594 changed the title Add support to update secondary and primary storage URLs [WIP] Add support to update secondary and primary storage URLs May 21, 2026
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.

Add the ability to change storage server IP addresses with the API and in the UI

4 participants