Skip to content

Conversation

@DaanHoogland
Copy link
Contributor

Description

This PR...

Fixes: #11973

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?

@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

❌ Patch coverage is 56.14035% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.19%. Comparing base (028dd86) to head (e79dacb).
⚠️ Report is 3 commits behind head on 4.20.

Files with missing lines Patch % Lines
...java/com/cloud/upgrade/DatabaseUpgradeChecker.java 56.14% 22 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #12140      +/-   ##
============================================
+ Coverage     16.18%   16.19%   +0.01%     
- Complexity    13298    13304       +6     
============================================
  Files          5657     5657              
  Lines        498470   498511      +41     
  Branches      60493    60505      +12     
============================================
+ Hits          80660    80725      +65     
+ Misses       408830   408800      -30     
- Partials       8980     8986       +6     
Flag Coverage Δ
uitests 4.00% <ø> (-0.01%) ⬇️
unittests 17.04% <56.14%> (+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.

Copy link
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

This PR adds a check to prevent database upgrades from running when multiple management servers are active. The implementation verifies that only one management server with status 'UP' exists in the database before proceeding with the upgrade process, addressing issue #11973.

  • Extracts the upgrade logic into a new doUpgrades() method for better code organization
  • Introduces checkIfStandalone() to query the management_server table and enforce single-server mode
  • Throws an exception if multiple active management servers are detected, preventing concurrent upgrade attempts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@DaanHoogland DaanHoogland requested a review from Copilot November 27, 2025 15:44
Copilot finished reviewing on behalf of DaanHoogland November 27, 2025 15:45
@apache apache deleted a comment from blueorangutan Nov 27, 2025
Copy link
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 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@apache apache deleted a comment from blueorangutan Dec 1, 2025
@apache apache deleted a comment from blueorangutan Dec 1, 2025
@apache apache deleted a comment from blueorangutan Dec 1, 2025
@apache apache deleted a comment from blueorangutan Dec 2, 2025
@blueorangutan
Copy link

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

Copilot finished reviewing on behalf of DaanHoogland December 2, 2025 09:23
Copy link
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 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ResultSet rs = pstmt.executeQuery()) {
if (rs.next()) {
int count = rs.getInt(1);
return count == 0;
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The logic here has a subtle issue. The query counts management servers with state = 'UP', and returns true (standalone) when count is 0. However, this check is being performed by a management server that is currently running.

This means:

  1. If this MS has already registered itself in the mshost table as 'UP', the count would be at least 1, and it would never be considered standalone.
  2. If this MS hasn't registered yet, the count might be 0 even in a clustered environment if other MSes are down or not yet started.

The check should likely exclude the current management server from the count, or check for count <= 1 instead of count == 0, to properly detect if this is the only running MS.

Suggested change
return count == 0;
return count <= 1;

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

@DaanHoogland DaanHoogland Dec 2, 2025

Choose a reason for hiding this comment

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

one valid issue is that an MS performing an upgrade is not yet registered as UP. so this fix is better than what we have but certainly not watertight yet.

@apache apache deleted a comment from blueorangutan Dec 2, 2025
@blueorangutan
Copy link

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

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.

3 participants