Skip to content

Commit 830f306

Browse files
authored
SystemVM optimizations (#5831)
* Support for live patching systemVMs and deprecating systemVM.iso. Includes: - fix systemVM template version - Include agent.zip, cloud-scripts.tgz to the commons package - Support for live-patching systemVMs - CPVM, SSVM, Routers - Fix Unit test - Remove systemvm.iso dependency * The following commit: - refactors logic added to support SystemVM deployment on KVM - Adds support to copy specific files (required for patching) to the hosts on Xenserver - Modifies vmops method - createFileInDomr to take cleanup param - Adds configuratble sleep param to CitrixResourceBase::connect() used to verify if telnet to specifc port is possible (if sleep is 0, then default to _sleep = 10000ms) - Adds Command/Answer for patch systemVMs on XenServer/Xcp * - Support to patch SystemVMs - VMWare - Remove attaching systemvm.iso to systemVMs - Modify / Refactor VMware start command to copy patch related files to the systemvms - cleanup * Commit comprises of: - remove docker from systemvm template - use containerd as container runtime - update create-k8s-binaries script to use ctr for all docker operations - Update userdata sent to the k8s nodes - update cksnode script, run during patching of the cks/k8s nodes * Add ssh to k8s nodes details in the Access tab on the UI * test * Refactor ca/cert patching logic * Commit comprises of the following changes: - Use restart network/VPC API to patch routers - use livePatch API support patching of only cpvm/ssvm - add timeout to the keystore setup/import script * remove all references of systemvm.iso * Fix keystore-cert-import invocation + refactor cert timeout in CP/SS VMs * fix script timeout * Refactor cert patching for systemVMs + update keystore-cert-import script + patch-sysvms script + remove patchSysvmCommand from networkelementcommand * remove commented code + change core user to cloud for cks nodes * Update ownership of ssh directory * NEED TO DISCUSS - add on the fly template conversion as an ExecStartPre action (systemd) * Add UI changes + move changes from patch file to runcmd * test: validate performance for template modification during seeding * create vms folder in cloudstack-commons directory - debian rules * remove logic for on the fly template convert + update k8s test * fix syntax issue - causing issue with shared network tests * Code cleanup * refactor patching logic - certs * move logic of fixing rootdiskcontroller from upgrade to kubernetes service * add livepatch option to restart network & vpc * smooth upgrade of cks clusters * Support for live patching systemVMs and deprecating systemVM.iso. Includes: - fix systemVM template version - Include agent.zip, cloud-scripts.tgz to the commons package - Support for live-patching systemVMs - CPVM, SSVM, Routers - Fix Unit test - Remove systemvm.iso dependency * The following commit: - refactors logic added to support SystemVM deployment on KVM - Adds support to copy specific files (required for patching) to the hosts on Xenserver - Modifies vmops method - createFileInDomr to take cleanup param - Adds configuratble sleep param to CitrixResourceBase::connect() used to verify if telnet to specifc port is possible (if sleep is 0, then default to _sleep = 10000ms) - Adds Command/Answer for patch systemVMs on XenServer/Xcp * - Support to patch SystemVMs - VMWare - Remove attaching systemvm.iso to systemVMs - Modify / Refactor VMware start command to copy patch related files to the systemvms - cleanup * Commit comprises of: - remove docker from systemvm template - use containerd as container runtime - update create-k8s-binaries script to use ctr for all docker operations - Update userdata sent to the k8s nodes - update cksnode script, run during patching of the cks/k8s nodes * Add ssh to k8s nodes details in the Access tab on the UI * test * Refactor ca/cert patching logic * Commit comprises of the following changes: - Use restart network/VPC API to patch routers - use livePatch API support patching of only cpvm/ssvm - add timeout to the keystore setup/import script * remove all references of systemvm.iso * Fix keystore-cert-import invocation + refactor cert timeout in CP/SS VMs * fix script timeout * Refactor cert patching for systemVMs + update keystore-cert-import script + patch-sysvms script + remove patchSysvmCommand from networkelementcommand * remove commented code + change core user to cloud for cks nodes * Update ownership of ssh directory * NEED TO DISCUSS - add on the fly template conversion as an ExecStartPre action (systemd) * Add UI changes + move changes from patch file to runcmd * test: validate performance for template modification during seeding * create vms folder in cloudstack-commons directory - debian rules * remove logic for on the fly template convert + update k8s test * fix syntax issue - causing issue with shared network tests * Code cleanup * add cgroup config for containerd * add systemd config for kubelet * add additional info during image registry config * address comments * add temp links of download.cloudstack.org * address part of the comments * address comments * update containerd config - as version has upgraded to 1.5 from 1.4.12 in 4.17.0 * address comments - simplify * fix vue3 related icon changes * allow network commands when router template version is lower but is patched * add internal LB to the list of routers to be patched on network restart with live patch * add unit tests for API param validations and new helper utilities - file scp & checksum validations * perform patching only for non-user i.e., system VMs * add test to validate params * remove unused import * add column to domain_router to display software version and support networkrestart with livePatch from router view * Requires upgrade column to consider package (cloud-scripts) checksum to identify if true/false * use router software version instead of checksum * show N/A if no software version reported i.e., in upgraded envs * fix deb failure * update pom to official links of systemVM template
1 parent 18d9c6d commit 830f306

File tree

116 files changed

+2348
-545
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+2348
-545
lines changed

agent/src/main/java/com/cloud/agent/Agent.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,10 @@ private Answer setupAgentCertificate(final SetupCertificateCommand cmd) {
763763
throw new CloudRuntimeException("Unable to save received agent client and ca certificates", e);
764764
}
765765

766+
String ksPassphrase = _shell.getPersistentProperty(null, KeyStoreUtils.KS_PASSPHRASE_PROPERTY);
766767
Script script = new Script(_keystoreCertImportPath, 300000, s_logger);
767768
script.add(agentFile.getAbsolutePath());
769+
script.add(ksPassphrase);
768770
script.add(keyStoreFile);
769771
script.add(KeyStoreUtils.AGENT_MODE);
770772
script.add(certFile);

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,9 @@ public class EventTypes {
637637
// Storage Policies
638638
public static final String EVENT_IMPORT_VCENTER_STORAGE_POLICIES = "IMPORT.VCENTER.STORAGE.POLICIES";
639639

640+
// SystemVM
641+
public static final String EVENT_LIVE_PATCH_SYSTEMVM = "LIVE.PATCH.SYSTEM.VM";
642+
640643
static {
641644

642645
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
@@ -1048,6 +1051,7 @@ public class EventTypes {
10481051
entityEventDetails.put(EVENT_IMPORT_VCENTER_STORAGE_POLICIES, "StoragePolicies");
10491052

10501053
entityEventDetails.put(EVENT_IMAGE_STORE_DATA_MIGRATE, ImageStore.class);
1054+
entityEventDetails.put(EVENT_LIVE_PATCH_SYSTEMVM, "SystemVMs");
10511055
}
10521056

10531057
public static String getEntityForEvent(String eventName) {

api/src/main/java/com/cloud/network/NetworkService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ IpAddress allocatePortableIP(Account ipOwner, int regionId, Long zoneId, Long ne
8181

8282
boolean deleteNetwork(long networkId, boolean forced);
8383

84-
boolean restartNetwork(Long networkId, boolean cleanup, boolean makeRedundant, User user) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
84+
boolean restartNetwork(Long networkId, boolean cleanup, boolean makeRedundant, boolean livePatch, User user) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
8585

8686
boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
8787

api/src/main/java/com/cloud/network/router/VirtualRouter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ public enum RedundantState {
5252
Long getVpcId();
5353

5454
String getTemplateVersion();
55+
56+
String getScriptsVersion();
5557
}

api/src/main/java/com/cloud/network/vpc/VpcService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, Stri
137137
*/
138138
boolean restartVpc(RestartVPCCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
139139

140-
boolean restartVpc(Long networkId, boolean cleanup, boolean makeRedundant, User user) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
140+
boolean restartVpc(Long networkId, boolean cleanup, boolean makeRedundant, boolean livePatch, User user) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
141141

142142
/**
143143
* Returns a Private gateway found in the VPC by id

api/src/main/java/com/cloud/server/ManagementService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.apache.cloudstack.api.command.admin.resource.UploadCustomCertificateCmd;
4141
import org.apache.cloudstack.api.command.admin.systemvm.DestroySystemVmCmd;
4242
import org.apache.cloudstack.api.command.admin.systemvm.ListSystemVMsCmd;
43+
import org.apache.cloudstack.api.command.admin.systemvm.PatchSystemVMCmd;
4344
import org.apache.cloudstack.api.command.admin.systemvm.RebootSystemVmCmd;
4445
import org.apache.cloudstack.api.command.admin.systemvm.ScaleSystemVMCmd;
4546
import org.apache.cloudstack.api.command.admin.systemvm.StopSystemVmCmd;
@@ -428,5 +429,6 @@ VirtualMachine upgradeSystemVM(ScaleSystemVMCmd cmd) throws ResourceUnavailableE
428429

429430
void cleanupVMReservations();
430431

432+
Pair<Boolean, String> patchSystemVM(PatchSystemVMCmd cmd);
431433

432434
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class ApiConstants {
3636
public static final String USER_API_KEY = "userapikey";
3737
public static final String APPLIED = "applied";
3838
public static final String LIST_LB_VMIPS = "lbvmips";
39+
public static final String LIVE_PATCH = "livepatch";
3940
public static final String AVAILABLE = "available";
4041
public static final String BACKUP_ID = "backupid";
4142
public static final String BACKUP_OFFERING_NAME = "backupofferingname";
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.api.command.admin.systemvm;
18+
19+
import com.cloud.event.EventTypes;
20+
import com.cloud.user.Account;
21+
import com.cloud.utils.Pair;
22+
import com.cloud.vm.VirtualMachine;
23+
import org.apache.cloudstack.acl.RoleType;
24+
import org.apache.cloudstack.api.APICommand;
25+
import org.apache.cloudstack.api.ApiConstants;
26+
import org.apache.cloudstack.api.ApiErrorCode;
27+
import org.apache.cloudstack.api.BaseAsyncCmd;
28+
import org.apache.cloudstack.api.BaseCmd;
29+
import org.apache.cloudstack.api.Parameter;
30+
import org.apache.cloudstack.api.ServerApiException;
31+
import org.apache.cloudstack.api.response.SuccessResponse;
32+
import org.apache.cloudstack.api.response.SystemVmResponse;
33+
import org.apache.cloudstack.context.CallContext;
34+
import org.apache.log4j.Logger;
35+
36+
@APICommand(name = PatchSystemVMCmd.APINAME, description = "Attempts to live patch systemVMs - CPVM, SSVM ",
37+
responseObject = SuccessResponse.class, requestHasSensitiveInfo = false,
38+
responseHasSensitiveInfo = false, authorized = { RoleType.Admin }, since = "4.17.0")
39+
public class PatchSystemVMCmd extends BaseAsyncCmd {
40+
public static final Logger s_logger = Logger.getLogger(PatchSystemVMCmd.class.getName());
41+
public static final String APINAME = "patchSystemVm";
42+
43+
/////////////////////////////////////////////////////
44+
//////////////// API parameters /////////////////////
45+
/////////////////////////////////////////////////////
46+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SystemVmResponse.class,
47+
description = "patches systemVM - CPVM/SSVM with the specified ID")
48+
private Long id;
49+
50+
@Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN,
51+
description = "If true, initiates copy of scripts and restart of the agent, even if the scripts version matches." +
52+
"To be used with ID parameter only")
53+
private Boolean force;
54+
55+
/////////////////////////////////////////////////////
56+
/////////////////// Accessors ///////////////////////
57+
/////////////////////////////////////////////////////
58+
59+
60+
public Long getId() {
61+
return id;
62+
}
63+
64+
public boolean isForced() {
65+
return force != null && force;
66+
}
67+
68+
/////////////////////////////////////////////////////
69+
/////////////// API Implementation///////////////////
70+
/////////////////////////////////////////////////////
71+
72+
@Override
73+
public String getEventType() {
74+
return EventTypes.EVENT_LIVE_PATCH_SYSTEMVM;
75+
}
76+
77+
@Override
78+
public String getEventDescription() {
79+
return String.format("Attempting to live patch System VM with Id: %s ", this._uuidMgr.getUuid(VirtualMachine.class, getId()));
80+
}
81+
82+
@Override
83+
public String getCommandName() {
84+
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
85+
}
86+
87+
@Override
88+
public long getEntityOwnerId() {
89+
Account account = CallContext.current().getCallingAccount();
90+
if (account != null) {
91+
return account.getId();
92+
}
93+
94+
return Account.ACCOUNT_ID_SYSTEM;
95+
}
96+
97+
@Override
98+
public void execute() {
99+
Pair<Boolean, String> patched = _mgr.patchSystemVM(this);
100+
if (patched.first()) {
101+
final SuccessResponse response = new SuccessResponse(getCommandName());
102+
response.setDisplayText(patched.second());
103+
setResponseObject(response);
104+
} else {
105+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, patched.second());
106+
}
107+
}
108+
}

api/src/main/java/org/apache/cloudstack/api/command/user/network/RestartNetworkCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public class RestartNetworkCmd extends BaseAsyncCmd {
6060
@Parameter(name = ApiConstants.MAKEREDUNDANT, type = CommandType.BOOLEAN, required = false, description = "Turn the network into a network with redundant routers.", since = "4.11.1")
6161
private Boolean makeRedundant = false;
6262

63+
@Parameter(name = ApiConstants.LIVE_PATCH, type = CommandType.BOOLEAN, required = false,
64+
description = "Live patches the router software before restarting it. This parameter will only work when 'cleanup' is false.",
65+
since = "4.17.0")
66+
private Boolean livePatch = false;
67+
6368
/////////////////////////////////////////////////////
6469
/////////////////// Accessors ///////////////////////
6570
/////////////////////////////////////////////////////
@@ -81,6 +86,8 @@ public Boolean getMakeRedundant() {
8186
return makeRedundant;
8287
}
8388

89+
public Boolean getLivePatch() { return livePatch; }
90+
8491
/////////////////////////////////////////////////////
8592
/////////////// API Implementation///////////////////
8693
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/user/vpc/RestartVPCCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public class RestartVPCCmd extends BaseAsyncCmd {
5454
@Parameter(name = ApiConstants.MAKEREDUNDANT, type = CommandType.BOOLEAN, required = false, description = "Turn a single VPC into a redundant one.")
5555
private Boolean makeredundant = false;
5656

57+
@Parameter(name = ApiConstants.LIVE_PATCH, type = CommandType.BOOLEAN, required = false,
58+
description = "Live patches the router software before restarting it. This parameter will only work when 'cleanup' is false.",
59+
since = "4.17.0")
60+
private Boolean livePatch = false;
61+
5762
/////////////////////////////////////////////////////
5863
/////////////////// Accessors ///////////////////////
5964
/////////////////////////////////////////////////////
@@ -70,6 +75,8 @@ public Boolean getMakeredundant() {
7075
return makeredundant;
7176
}
7277

78+
public Boolean getLivePatch() { return livePatch; }
79+
7380
/////////////////////////////////////////////////////
7481
/////////////// API Implementation///////////////////
7582
/////////////////////////////////////////////////////

0 commit comments

Comments
 (0)