Skip to content

Commit

Permalink
Removed state for removed accounts (#7868)
Browse files Browse the repository at this point in the history
Co-authored-by: Henrique Sato <henrique.sato@scclouds.com.br>
  • Loading branch information
hsato03 and Henrique Sato committed Sep 28, 2023
1 parent ae5dda8 commit 31e2b62
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/src/main/java/com/cloud/user/Account.java
Expand Up @@ -30,7 +30,7 @@ public interface Account extends ControlledEntity, InternalIdentity, Identity {
* Account states.
* */
enum State {
DISABLED, ENABLED, LOCKED;
DISABLED, ENABLED, LOCKED, REMOVED;

/**
* The toString method was overridden to maintain consistency in the DB, as the GenericDaoBase uses toString in the enum value to make the sql statements
Expand Down
Expand Up @@ -180,3 +180,6 @@ CREATE TABLE `cloud`.`vm_scheduled_job` (
-- Add support for different cluster types for kubernetes
ALTER TABLE `cloud`.`kubernetes_cluster` ADD COLUMN `cluster_type` varchar(64) DEFAULT 'CloudManaged' COMMENT 'type of cluster';
ALTER TABLE `cloud`.`kubernetes_cluster` MODIFY COLUMN `kubernetes_version_id` bigint unsigned NULL COMMENT 'the ID of the Kubernetes version of this Kubernetes cluster';

-- Set removed state for all removed accounts
UPDATE `cloud`.`account` SET state='removed' WHERE `removed` IS NOT NULL;
3 changes: 3 additions & 0 deletions server/src/main/java/com/cloud/user/AccountManagerImpl.java
Expand Up @@ -814,6 +814,9 @@ public boolean deleteAccount(AccountVO account, long callerUserId, Account calle
return false;
}

account.setState(State.REMOVED);
_accountDao.update(accountId, account);

if (s_logger.isDebugEnabled()) {
s_logger.debug("Removed account " + accountId);
}
Expand Down

0 comments on commit 31e2b62

Please sign in to comment.