Skip to content

Commit 9e02a1a

Browse files
Merge branch '4.22' into 4.22-vr-fix-haproxy-check-with-ssl-offloading
2 parents b97a2c9 + 7aa0558 commit 9e02a1a

File tree

39 files changed

+428
-388
lines changed

39 files changed

+428
-388
lines changed

.github/workflows/merge-conflict-checker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
name: "PR Merge Conflict Check"
1919
on:
2020
push:
21-
pull_request_target:
22-
types: [synchronize]
21+
pull_request:
22+
types: [opened, synchronize, reopened]
2323

2424
permissions: # added using https://github.com/step-security/secure-workflows
2525
contents: read

api/src/main/java/org/apache/cloudstack/api/ApiServerService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,7 @@ public ResponseObject loginUser(HttpSession session, String username, String pas
4949

5050
boolean resetPassword(UserAccount userAccount, String token, String password);
5151

52+
String getDomainId(Map<String, Object[]> params);
53+
5254
boolean isPostRequestsAndTimestampsEnforced();
5355
}

core/src/main/java/com/cloud/agent/api/ModifyStoragePoolAnswer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public ModifyStoragePoolAnswer(ModifyStoragePoolCommand cmd, long capacityBytes,
4646
templateInfo = tInfo;
4747
}
4848

49+
public ModifyStoragePoolAnswer(final Command command, final boolean success, final String details) {
50+
super(command, success, details);
51+
}
52+
4953
public ModifyStoragePoolAnswer(ModifyStoragePoolCommand cmd, boolean success, String details) {
5054
super(cmd, success, details);
5155
}

engine/schema/src/main/java/com/cloud/user/UserVO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ public UserVO() {
123123
}
124124

125125
public UserVO(long id) {
126+
this();
126127
this.id = id;
127-
this.uuid = UUID.randomUUID().toString();
128128
}
129129

130130
public UserVO(long accountId, String username, String password, String firstName, String lastName, String email, String timezone, String uuid, Source source) {

engine/schema/src/main/java/com/cloud/user/dao/AccountDao.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121

2222
import com.cloud.user.Account;
2323
import com.cloud.user.AccountVO;
24-
import com.cloud.user.User;
2524
import com.cloud.utils.Pair;
2625
import com.cloud.utils.db.Filter;
2726
import com.cloud.utils.db.GenericDao;
2827

2928
public interface AccountDao extends GenericDao<AccountVO, Long> {
30-
Pair<User, Account> findUserAccountByApiKey(String apiKey);
3129

3230
List<AccountVO> findAccountsLike(String accountName);
3331

engine/schema/src/main/java/com/cloud/user/dao/AccountDaoImpl.java

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// under the License.
1717
package com.cloud.user.dao;
1818

19-
import java.sql.PreparedStatement;
20-
import java.sql.ResultSet;
2119
import java.util.Date;
2220
import java.util.List;
2321

@@ -27,24 +25,17 @@
2725
import com.cloud.user.Account;
2826
import com.cloud.user.Account.State;
2927
import com.cloud.user.AccountVO;
30-
import com.cloud.user.User;
31-
import com.cloud.user.UserVO;
3228
import com.cloud.utils.Pair;
33-
import com.cloud.utils.crypt.DBEncryptionUtil;
3429
import com.cloud.utils.db.Filter;
3530
import com.cloud.utils.db.GenericDaoBase;
3631
import com.cloud.utils.db.GenericSearchBuilder;
3732
import com.cloud.utils.db.SearchBuilder;
3833
import com.cloud.utils.db.SearchCriteria;
3934
import com.cloud.utils.db.SearchCriteria.Func;
4035
import com.cloud.utils.db.SearchCriteria.Op;
41-
import com.cloud.utils.db.TransactionLegacy;
4236

4337
@Component
4438
public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements AccountDao {
45-
private static final String FIND_USER_ACCOUNT_BY_API_KEY = "SELECT u.id, u.username, u.account_id, u.secret_key, u.state, u.api_key_access, "
46-
+ "a.id, a.account_name, a.type, a.role_id, a.domain_id, a.state, a.api_key_access " + "FROM `cloud`.`user` u, `cloud`.`account` a "
47-
+ "WHERE u.account_id = a.id AND u.api_key = ? and u.removed IS NULL";
4839

4940
protected final SearchBuilder<AccountVO> AllFieldsSearch;
5041
protected final SearchBuilder<AccountVO> AccountTypeSearch;
@@ -132,51 +123,6 @@ public List<AccountVO> findCleanupsForDisabledAccounts() {
132123
return listBy(sc);
133124
}
134125

135-
@Override
136-
public Pair<User, Account> findUserAccountByApiKey(String apiKey) {
137-
TransactionLegacy txn = TransactionLegacy.currentTxn();
138-
PreparedStatement pstmt = null;
139-
Pair<User, Account> userAcctPair = null;
140-
try {
141-
String sql = FIND_USER_ACCOUNT_BY_API_KEY;
142-
pstmt = txn.prepareAutoCloseStatement(sql);
143-
pstmt.setString(1, apiKey);
144-
ResultSet rs = pstmt.executeQuery();
145-
// TODO: make sure we don't have more than 1 result? ApiKey had better be unique
146-
if (rs.next()) {
147-
User u = new UserVO(rs.getLong(1));
148-
u.setUsername(rs.getString(2));
149-
u.setAccountId(rs.getLong(3));
150-
u.setSecretKey(DBEncryptionUtil.decrypt(rs.getString(4)));
151-
u.setState(State.getValueOf(rs.getString(5)));
152-
boolean apiKeyAccess = rs.getBoolean(6);
153-
if (rs.wasNull()) {
154-
u.setApiKeyAccess(null);
155-
} else {
156-
u.setApiKeyAccess(apiKeyAccess);
157-
}
158-
159-
AccountVO a = new AccountVO(rs.getLong(7));
160-
a.setAccountName(rs.getString(8));
161-
a.setType(Account.Type.getFromValue(rs.getInt(9)));
162-
a.setRoleId(rs.getLong(10));
163-
a.setDomainId(rs.getLong(11));
164-
a.setState(State.getValueOf(rs.getString(12)));
165-
apiKeyAccess = rs.getBoolean(13);
166-
if (rs.wasNull()) {
167-
a.setApiKeyAccess(null);
168-
} else {
169-
a.setApiKeyAccess(apiKeyAccess);
170-
}
171-
172-
userAcctPair = new Pair<User, Account>(u, a);
173-
}
174-
} catch (Exception e) {
175-
logger.warn("Exception finding user/acct by api key: " + apiKey, e);
176-
}
177-
return userAcctPair;
178-
}
179-
180126
@Override
181127
public List<AccountVO> findAccountsLike(String accountName) {
182128
return findAccountsLike(accountName, null).first();
@@ -341,11 +287,9 @@ public long getDomainIdForGivenAccountId(long id) {
341287
domain_id = account_vo.getDomainId();
342288
}
343289
catch (Exception e) {
344-
logger.warn("getDomainIdForGivenAccountId: Exception :" + e.getMessage());
345-
}
346-
finally {
347-
return domain_id;
290+
logger.warn("Can not get DomainId for the given AccountId; exception message : {}", e.getMessage());
348291
}
292+
return domain_id;
349293
}
350294

351295
@Override

engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,15 +846,18 @@ public HashMap<String, Long> countVgpuVMs(Long dcId, Long podId, Long clusterId)
846846

847847
try {
848848
pstmtLegacy = txn.prepareAutoCloseStatement(finalQueryLegacy.toString());
849-
pstmt = txn.prepareAutoCloseStatement(finalQuery.toString());
850849
for (int i = 0; i < resourceIdList.size(); i++) {
851850
pstmtLegacy.setLong(1 + i, resourceIdList.get(i));
852-
pstmt.setLong(1 + i, resourceIdList.get(i));
853851
}
854852
ResultSet rs = pstmtLegacy.executeQuery();
855853
while (rs.next()) {
856854
result.put(rs.getString(1).concat(rs.getString(2)), rs.getLong(3));
857855
}
856+
857+
pstmt = txn.prepareAutoCloseStatement(finalQuery.toString());
858+
for (int i = 0; i < resourceIdList.size(); i++) {
859+
pstmt.setLong(1 + i, resourceIdList.get(i));
860+
}
858861
rs = pstmt.executeQuery();
859862
while (rs.next()) {
860863
result.put(rs.getString(1).concat(rs.getString(2)), rs.getLong(3));

engine/schema/src/main/resources/META-INF/db/schema-42200to42210-cleanup.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818
--;
1919
-- Schema upgrade cleanup from 4.22.0.0 to 4.22.1.0
2020
--;
21+
22+
DROP VIEW IF EXISTS `cloud`.`account_netstats_view`;

engine/schema/src/main/resources/META-INF/db/views/cloud.account_netstats_view.sql

Lines changed: 0 additions & 31 deletions
This file was deleted.

engine/schema/src/main/resources/META-INF/db/views/cloud.account_view.sql

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ select
3939
`data_center`.`id` AS `data_center_id`,
4040
`data_center`.`uuid` AS `data_center_uuid`,
4141
`data_center`.`name` AS `data_center_name`,
42-
`account_netstats_view`.`bytesReceived` AS `bytesReceived`,
43-
`account_netstats_view`.`bytesSent` AS `bytesSent`,
42+
`account_netstats`.`bytesReceived` AS `bytesReceived`,
43+
`account_netstats`.`bytesSent` AS `bytesSent`,
4444
`vmlimit`.`max` AS `vmLimit`,
4545
`vmcount`.`count` AS `vmTotal`,
4646
`runningvm`.`vmcount` AS `runningVms`,
@@ -89,8 +89,15 @@ from
8989
`cloud`.`domain` ON account.domain_id = domain.id
9090
left join
9191
`cloud`.`data_center` ON account.default_zone_id = data_center.id
92-
left join
93-
`cloud`.`account_netstats_view` ON account.id = account_netstats_view.account_id
92+
left join lateral (
93+
select
94+
coalesce(sum(`user_statistics`.`net_bytes_received` + `user_statistics`.`current_bytes_received`), 0) AS `bytesReceived`,
95+
coalesce(sum(`user_statistics`.`net_bytes_sent` + `user_statistics`.`current_bytes_sent`), 0) AS `bytesSent`
96+
from
97+
`cloud`.`user_statistics`
98+
where
99+
`user_statistics`.`account_id` = `account`.`id`
100+
) AS `account_netstats` ON TRUE
94101
left join
95102
`cloud`.`resource_limit` vmlimit ON account.id = vmlimit.account_id
96103
and vmlimit.type = 'user_vm' and vmlimit.tag IS NULL

0 commit comments

Comments
 (0)