You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "erikbocks (via GitHub)" <gi...@apache.org> on 2026/06/12 16:27:12 UTC

[PR] Snapshot state normalization for failure due to malformed secondary s… [cloudstack]

erikbocks opened a new pull request, #13411:
URL: https://github.com/apache/cloudstack/pull/13411

   ### Description
   
   If the environment has a malformed (wrong logic, syntax error, etc.) secondary storage selector heuristic rule, an exception is thrown during its interpretation. The snapshot creation process gets the environment's `SNAPSHOT` type secondary storage selectors and interprets its heuristic rule, if any was returned. However, this validation does not handle exceptions thrown by the interpreter.
   
   With that, the snapshot record that was created in the `Allocated` state is never normalized, even though the creation process was finished prematurely due to the interpretation error. Therefore, changes were made to normalize the snapshot state to `Error` in these cases.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [X] 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
   - [X] Minor
   - [ ] Trivial
   
   ### Screenshots (if appropriate):
   
   ### How Has This Been Tested?
   
   First, I created a malformed secondary storage selector:
   
   <details><summary>Secondary storage selector creation command</summary>
   
   ```bash
   create secondarystorageselector name=a description=a type=SNAPSHOT zoneid=a9a3fc15-008f-48b1-8964-d946104b4b17 heuristicrule="if"
   ```
   
   </details>
   
   Then, I tried to create a volume snapshot, and validated that it was set to the `Allocated` state. After applying the changes, I repeated the process and validated that the snapshot was set to the `Error` state.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Snapshot state normalization for failure due to malformed secondary s… [cloudstack]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #13411:
URL: https://github.com/apache/cloudstack/pull/13411#issuecomment-4693239903

   ## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/13411?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 3.69%. Comparing base ([`8e933b7`](https://app.codecov.io/gh/apache/cloudstack/commit/8e933b735e21d1b6bda95425fe76994499ec308d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`08ff17d`](https://app.codecov.io/gh/apache/cloudstack/commit/08ff17d5f9882e56ee194e0f23c9b1dceac09bcf?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   > :exclamation:  There is a different number of reports uploaded between BASE (8e933b7) and HEAD (08ff17d). Click for more details.
   > 
   > <details><summary>HEAD has 1 upload less than BASE</summary>
   >
   >| Flag | BASE (8e933b7) | HEAD (08ff17d) |
   >|------|------|------|
   >|unittests|1|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff              @@
   ##               4.22   #13411       +/-   ##
   =============================================
   - Coverage     17.67%    3.69%   -13.98%     
   =============================================
     Files          5922      448     -5474     
     Lines        533167    38107   -495060     
     Branches      65210     7061    -58149     
   =============================================
   - Hits          94246     1409    -92837     
   + Misses       428276    36511   -391765     
   + Partials      10645      187    -10458     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/13411/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/13411/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `3.69% <ø> (ø)` | |
   | [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/13411/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/cloudstack/pull/13411?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Snapshot state normalization for failure due to malformed secondary s… [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on PR #13411:
URL: https://github.com/apache/cloudstack/pull/13411#issuecomment-4694128721

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Snapshot state normalization for failure due to malformed secondary s… [cloudstack]

Posted by "Damans227 (via GitHub)" <gi...@apache.org>.
Damans227 commented on code in PR #13411:
URL: https://github.com/apache/cloudstack/pull/13411#discussion_r4295870825


##########
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java:
##########
@@ -1633,11 +1633,17 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationExc
         boolean backupSnapToSecondary = isBackupSnapshotToSecondaryForZone(volume.getDataCenterId());
 
         if (isKvmAndFileBasedStorage && backupSnapToSecondary) {
-            DataStore imageStore = snapshotSrv.findSnapshotImageStore(snapshot);
-            if (imageStore == null) {
-                throw new CloudRuntimeException(String.format("Could not find any secondary storage to allocate snapshot [%s].", snapshot));
+            try {
+                DataStore imageStore = snapshotSrv.findSnapshotImageStore(snapshot);
+                if (imageStore == null) {
+                    throw new CloudRuntimeException(String.format("Could not find any secondary storage to allocate snapshot [%s].", snapshot));
+                }
+                snapshot.setImageStore(imageStore);
+            } catch (CloudRuntimeException ex) {
+                logger.error("There was an error while selecting image store for snapshot: {}", ex.getMessage());
+                handleErrorInUncreatedSnapshot(snapshotId);

Review Comment:
   should this also give back the snapshot and storage counts the account was charged? it throws before the catch below that does that, and deleting a snapshot in error doesnt give them back either



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Snapshot state normalization for failure due to malformed secondary s… [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13411:
URL: https://github.com/apache/cloudstack/pull/13411#issuecomment-4694138445

   @winterhazel a [SL] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Snapshot state normalization for failure due to malformed secondary s… [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13411:
URL: https://github.com/apache/cloudstack/pull/13411#issuecomment-4694453667

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org