Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change vmsnapshot.max configuration to be dynamic #9883

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface VMSnapshotManager extends VMSnapshotService, Manager {
static final ConfigKey<Integer> VMSnapshotExpireInterval = new ConfigKey<Integer>("Advanced", Integer.class, "vmsnapshot.expire.interval", "-1",
"VM Snapshot expire interval in hours", true, ConfigKey.Scope.Account);

public static final int VMSNAPSHOTMAX = 10;
ConfigKey<Integer> VMSnapshotMax = new ConfigKey<Integer>("Advanced", Integer.class, "vmsnapshot.max", "10", "Maximum vm snapshots for a single vm", true, ConfigKey.Scope.Global);

/**
* Delete all VM snapshots belonging to one VM
Expand Down
1 change: 0 additions & 1 deletion server/src/main/java/com/cloud/configuration/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,6 @@ public enum Config {
null),

// VMSnapshots
VMSnapshotMax("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.max", "10", "Maximum vm snapshots for a vm", null),
VMSnapshotCreateWait("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.create.wait", "1800", "In second, timeout for create vm snapshot", null),

CloudDnsName("Advanced", ManagementServer.class, String.class, "cloud.dns.name", null, "DNS name of the cloud for the GSLB service", null),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@

VmWorkJobHandlerProxy _jobHandlerProxy = new VmWorkJobHandlerProxy(this);

int _vmSnapshotMax;
int _wait;

static final ConfigKey<Long> VmJobCheckInterval = new ConfigKey<Long>("Advanced",
Expand All @@ -188,8 +187,6 @@
throw new ConfigurationException("Unable to get the configuration dao.");
}

_vmSnapshotMax = NumbersUtil.parseInt(_configDao.getValue("vmsnapshot.max"), VMSNAPSHOTMAX);

String value = _configDao.getValue("vmsnapshot.create.wait");
_wait = NumbersUtil.parseInt(value, 1800);

Expand Down Expand Up @@ -398,8 +395,10 @@
_accountMgr.checkAccess(caller, null, true, userVmVo);

// check max snapshot limit for per VM
if (_vmSnapshotDao.findByVm(vmId).size() >= _vmSnapshotMax) {
throw new CloudRuntimeException("Creating vm snapshot failed due to a VM can just have : " + _vmSnapshotMax + " VM snapshots. Please delete old ones");
int vmSnapshotMax = VMSnapshotManager.VMSnapshotMax.value();

if (_vmSnapshotDao.findByVm(vmId).size() >= vmSnapshotMax) {
throw new CloudRuntimeException("Creating vm snapshot failed due to a VM can just have : " + vmSnapshotMax + " VM snapshots. Please delete old ones");
}

// check if there are active volume snapshots tasks
Expand Down Expand Up @@ -1391,6 +1390,6 @@

@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {VMSnapshotExpireInterval};
return new ConfigKey<?>[] {VMSnapshotExpireInterval, VMSnapshotMax};

Check warning on line 1393 in server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java#L1393

Added line #L1393 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public class VMSnapshotManagerTest {
VMSnapshotDetailsDao _vmSnapshotDetailsDao;
@Mock
UserVmManager _userVmManager;
int _vmSnapshotMax = 10;

private static final long TEST_VM_ID = 3L;
private static final long SERVICE_OFFERING_ID = 1L;
Expand Down Expand Up @@ -194,8 +193,6 @@ public void setup() {

doNothing().when(_accountMgr).checkAccess(any(Account.class), any(AccessType.class), any(Boolean.class), any(ControlledEntity.class));

_vmSnapshotMgr._vmSnapshotMax = _vmSnapshotMax;

_vmSnapshotMgr._serviceOfferingDao = _serviceOfferingDao;
_vmSnapshotMgr._userVmDetailsDao = _userVmDetailsDao;
_vmSnapshotMgr._vmSnapshotDetailsDao = _vmSnapshotDetailsDao;
Expand Down
Loading