Skip to content

Commit c3816ad

Browse files
author
Fabrício Duarte
committed
Merge branch 'fix-standard-offering-creation' into '4.20.0.0-scclouds'
Corrige criação da oferta de backup nativo Standard See merge request scclouds/scclouds!1328
2 parents 5c0c51d + 9290476 commit c3816ad

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42005to42006.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ private void normalizeBackupOfferingsIfNeeded(Connection conn) {
9191
String uuid;
9292
try (PreparedStatement pstmt = conn.prepareStatement(SELECT_NATIVE_OFFERING)) {
9393
ResultSet result = pstmt.executeQuery();
94-
if (!result.next()) {
95-
result = createStandardOffering(conn);
94+
if (result.next()) {
95+
uuid = result.getString("uuid");
96+
} else {
97+
uuid = createStandardOffering(conn);
9698
}
97-
uuid = result.getString("uuid");
9899
} catch (SQLException e) {
99100
String message = String.format("Unable to retrieve Standard native backup offering due to [%s].", e.getMessage());
100101
logger.error(message, e);
@@ -122,7 +123,7 @@ private void normalizeBackupOfferingsIfNeeded(Connection conn) {
122123
}
123124
}
124125

125-
private ResultSet createStandardOffering(Connection conn) {
126+
private String createStandardOffering(Connection conn) {
126127
logger.warn("Found backup offerings that are inconsistent, but the Standard native backup offering does not exist. Will create it again.");
127128
try (PreparedStatement pstmt = conn.prepareStatement(INSERT_OFFERING)) {
128129
pstmt.executeUpdate();
@@ -139,7 +140,7 @@ private ResultSet createStandardOffering(Connection conn) {
139140
logger.error(message);
140141
throw new CloudRuntimeException(message);
141142
}
142-
return resultSet;
143+
return resultSet.getString("uuid");
143144
} catch (SQLException e) {
144145
String message = String.format("Unable to retrieve native backup offering due to [%s].", e.getMessage());
145146
logger.error(message, e);

0 commit comments

Comments
 (0)