Skip to content

Commit 6ac834a

Browse files
davidjumaniPearl1594Pearl Dsilvaustcweizhouyadvr
authored
Adding AutoScaling for cks + CKS CoreOS EOL update + systemvmtemplate improvements (#4329)
Adding AutoScaling support for cks Kubernetes PR : kubernetes/autoscaler#3629 Also replaces CoreOS with Debian Fixes #4198 Co-authored-by: Pearl Dsilva <[email protected]> Co-authored-by: Pearl Dsilva <[email protected]> Co-authored-by: Wei Zhou <[email protected]> Co-authored-by: Rohit Yadav <[email protected]>
1 parent e4beb1f commit 6ac834a

File tree

98 files changed

+3542
-1116
lines changed

Some content is hidden

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

98 files changed

+3542
-1116
lines changed

api/src/main/java/com/cloud/vm/UserVmService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
379379
String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData,
380380
String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList,
381381
Map<String, String> customParameters, String customId, Map<String, Map<Integer, String>> dhcpOptionMap, Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
382-
Map<String, String> templateOvfPropertiesMap, boolean dynamicScalingEnabled)
382+
Map<String, String> templateOvfPropertiesMap, boolean dynamicScalingEnabled, String type)
383383

384384
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
385385

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,16 @@ public class ApiConstants {
838838
public static final String KUBERNETES_VERSION_ID = "kubernetesversionid";
839839
public static final String KUBERNETES_VERSION_NAME = "kubernetesversionname";
840840
public static final String MASTER_NODES = "masternodes";
841+
public static final String NODE_IDS = "nodeids";
841842
public static final String CONTROL_NODES = "controlnodes";
842843
public static final String MIN_SEMANTIC_VERSION = "minimumsemanticversion";
843844
public static final String MIN_KUBERNETES_VERSION_ID = "minimumkubernetesversionid";
844845
public static final String NODE_ROOT_DISK_SIZE = "noderootdisksize";
845846
public static final String SUPPORTS_HA = "supportsha";
847+
public static final String SUPPORTS_AUTOSCALING = "supportsautoscaling";
848+
public static final String AUTOSCALING_ENABLED = "autoscalingenabled";
849+
public static final String MIN_SIZE = "minsize";
850+
public static final String MAX_SIZE = "maxsize";
846851

847852
public static final String BOOT_TYPE = "boottype";
848853
public static final String BOOT_MODE = "bootmode";

debian/rules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,21 @@ override_dh_auto_install:
6666
mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-management
6767
mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-management/lib
6868
mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-management/setup
69+
mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-management/templates/systemvm
6970
mkdir $(DESTDIR)/var/log/$(PACKAGE)/management
7071
mkdir $(DESTDIR)/var/cache/$(PACKAGE)/management
7172
mkdir $(DESTDIR)/var/log/$(PACKAGE)/ipallocator
7273
mkdir $(DESTDIR)/var/lib/$(PACKAGE)/management
7374
mkdir $(DESTDIR)/var/lib/$(PACKAGE)/mnt
75+
7476
cp -r client/target/utilities/scripts/db/* $(DESTDIR)/usr/share/$(PACKAGE)-management/setup/
7577
cp -r client/target/classes/META-INF/webapp $(DESTDIR)/usr/share/$(PACKAGE)-management/webapp
7678
cp server/target/conf/* $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/server/
7779
cp client/target/conf/* $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/management/
7880
cp client/target/cloud-client-ui-$(VERSION).jar $(DESTDIR)/usr/share/$(PACKAGE)-management/lib/cloudstack-$(VERSION).jar
7981
cp client/target/lib/*jar $(DESTDIR)/usr/share/$(PACKAGE)-management/lib/
82+
cp -r engine/schema/dist/systemvm-templates/* $(DESTDIR)/usr/share/$(PACKAGE)-management/templates/systemvm/
83+
rm -rf $(DESTDIR)/usr/share/$(PACKAGE)-management/templates/systemvm/md5sum.txt
8084

8185
# nast hack for a couple of configuration files
8286
mv $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/server/cloudstack-limits.conf $(DESTDIR)/$(SYSCONFDIR)/security/limits.d/

engine/api/src/main/java/com/cloud/vm/VirtualMachineGuru.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
import com.cloud.agent.manager.Commands;
2121
import com.cloud.deploy.DeployDestination;
2222
import com.cloud.exception.ResourceUnavailableException;
23+
24+
import java.nio.charset.StandardCharsets;
25+
import java.util.Base64;
26+
2327
/**
2428
* A VirtualMachineGuru knows how to process a certain type of virtual machine.
2529
*
@@ -60,4 +64,12 @@ public interface VirtualMachineGuru {
6064
void prepareStop(VirtualMachineProfile profile);
6165

6266
void finalizeUnmanage(VirtualMachine vm);
67+
68+
static String getEncodedMsPublicKey(String pubKey) {
69+
String base64EncodedPublicKey = null;
70+
if (pubKey != null) {
71+
base64EncodedPublicKey = Base64.getEncoder().encodeToString(pubKey.getBytes(StandardCharsets.UTF_8));
72+
}
73+
return base64EncodedPublicKey;
74+
}
6375
}

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
413413
static final ConfigKey<Boolean> HaVmRestartHostUp = new ConfigKey<Boolean>("Advanced", Boolean.class, "ha.vm.restart.hostup", "true",
414414
"If an out-of-band stop of a VM is detected and its host is up, then power on the VM", true);
415415

416+
static final ConfigKey<Long> SystemVmRootDiskSize = new ConfigKey<Long>("Advanced",
417+
Long.class, "systemvm.root.disk.size", "-1",
418+
"Size of root volume (in GB) of system VMs and virtual routers", true);
419+
416420
ScheduledExecutorService _executor = null;
417421

418422
private long _nodeId;
@@ -461,6 +465,12 @@ public void allocate(final String vmInstanceName, final VirtualMachineTemplate t
461465

462466
final VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmFinal, template, serviceOffering, null, null);
463467

468+
Long rootDiskSize = rootDiskOfferingInfo.getSize();
469+
if (vm.getType().isUsedBySystem() && SystemVmRootDiskSize.value() != null && SystemVmRootDiskSize.value() > 0L) {
470+
rootDiskSize = SystemVmRootDiskSize.value();
471+
}
472+
final Long rootDiskSizeFinal = rootDiskSize;
473+
464474
Transaction.execute(new TransactionCallbackWithExceptionNoReturn<InsufficientCapacityException>() {
465475
@Override
466476
public void doInTransactionWithoutResult(final TransactionStatus status) throws InsufficientCapacityException {
@@ -486,7 +496,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) throws
486496
} else if (template.getFormat() == ImageFormat.BAREMETAL) {
487497
// Do nothing
488498
} else {
489-
volumeMgr.allocateTemplatedVolumes(Type.ROOT, "ROOT-" + vmFinal.getId(), rootDiskOfferingInfo.getDiskOffering(), rootDiskOfferingInfo.getSize(),
499+
volumeMgr.allocateTemplatedVolumes(Type.ROOT, "ROOT-" + vmFinal.getId(), rootDiskOfferingInfo.getDiskOffering(), rootDiskSizeFinal,
490500
rootDiskOfferingInfo.getMinIops(), rootDiskOfferingInfo.getMaxIops(), template, vmFinal, owner);
491501
}
492502

@@ -1729,7 +1739,7 @@ protected boolean sendStop(final VirtualMachineGuru guru, final VirtualMachinePr
17291739

17301740
final UserVmVO userVm = _userVmDao.findById(vm.getId());
17311741
if (vm.getType() == VirtualMachine.Type.User) {
1732-
if (userVm != null){
1742+
if (userVm != null) {
17331743
userVm.setPowerState(PowerState.PowerOff);
17341744
_userVmDao.update(userVm.getId(), userVm);
17351745
}
@@ -4833,7 +4843,7 @@ public ConfigKey<?>[] getConfigKeys() {
48334843
return new ConfigKey<?>[] { ClusterDeltaSyncInterval, StartRetry, VmDestroyForcestop, VmOpCancelInterval, VmOpCleanupInterval, VmOpCleanupWait,
48344844
VmOpLockStateRetry, VmOpWaitInterval, ExecuteInSequence, VmJobCheckInterval, VmJobTimeout, VmJobStateReportInterval,
48354845
VmConfigDriveLabel, VmConfigDriveOnPrimaryPool, VmConfigDriveForceHostCacheUse, VmConfigDriveUseHostCacheOnUnsupportedPool,
4836-
HaVmRestartHostUp, ResourceCountRunningVMsonly, AllowExposeHypervisorHostname, AllowExposeHypervisorHostnameAccountLevel };
4846+
HaVmRestartHostUp, ResourceCountRunningVMsonly, AllowExposeHypervisorHostname, AllowExposeHypervisorHostnameAccountLevel, SystemVmRootDiskSize };
48374847
}
48384848

48394849
public List<StoragePoolAllocator> getStoragePoolAllocators() {

engine/schema/pom.xml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,175 @@
5252
<groupId>mysql</groupId>
5353
<artifactId>mysql-connector-java</artifactId>
5454
</dependency>
55+
<dependency>
56+
<groupId>org.ini4j</groupId>
57+
<artifactId>ini4j</artifactId>
58+
<version>${cs.ini.version}</version>
59+
</dependency>
5560
</dependencies>
61+
<build>
62+
<plugins>
63+
<plugin>
64+
<groupId>org.codehaus.gmaven</groupId>
65+
<artifactId>gmaven-plugin</artifactId>
66+
<version>1.5</version>
67+
<executions>
68+
<execution>
69+
<id>setproperty</id>
70+
<phase>validate</phase>
71+
<goals>
72+
<goal>execute</goal>
73+
</goals>
74+
<configuration>
75+
<source>
76+
def projectVersion = project.version
77+
String[] versionParts = projectVersion.tokenize('.')
78+
pom.properties['cs.version'] = versionParts[0] + "." + versionParts[1]
79+
pom.properties['patch.version'] = versionParts[2]
80+
</source>
81+
</configuration>
82+
</execution>
83+
</executions>
84+
</plugin>
85+
<plugin>
86+
<groupId>com.googlecode.maven-download-plugin</groupId>
87+
<artifactId>download-maven-plugin</artifactId>
88+
<version>1.6.3</version>
89+
<executions>
90+
<execution>
91+
<id>download-checksums</id>
92+
<phase>validate</phase>
93+
<goals>
94+
<goal>wget</goal>
95+
</goals>
96+
<configuration>
97+
<url>https://download.cloudstack.org/systemvm/${cs.version}/md5sum.txt</url>
98+
<outputDirectory>${basedir}/dist/systemvm-templates/</outputDirectory>
99+
<skipCache>true</skipCache>
100+
<overwrite>true</overwrite>
101+
</configuration>
102+
</execution>
103+
</executions>
104+
</plugin>
105+
<plugin>
106+
<groupId>org.codehaus.gmaven</groupId>
107+
<artifactId>gmaven-plugin</artifactId>
108+
<version>1.5</version>
109+
<executions>
110+
<execution>
111+
<id>set-properties</id>
112+
<phase>generate-sources</phase>
113+
<goals>
114+
<goal>execute</goal>
115+
</goals>
116+
<configuration>
117+
<source>
118+
def csVersion = pom.properties['cs.version']
119+
def patch = pom.properties['patch.version']
120+
def templateList = []
121+
templateList.add("systemvmtemplate-${csVersion}.${patch}-kvm")
122+
templateList.add("systemvmtemplate-${csVersion}.${patch}-vmware")
123+
templateList.add("systemvmtemplate-${csVersion}.${patch}-xen")
124+
templateList.add("systemvmtemplate-${csVersion}.${patch}-ovm")
125+
templateList.add("systemvmtemplate-${csVersion}.${patch}-hyperv")
126+
File file = new File("./engine/schema/dist/systemvm-templates/md5sum.txt")
127+
def lines = file.readLines()
128+
for (template in templateList) {
129+
def data = lines.findAll { it.contains(template) }
130+
if (data != null) {
131+
def hypervisor = template.tokenize('-')[-1]
132+
pom.properties["$hypervisor" + ".checksum"] = data[0].tokenize(' ')[0]
133+
}
134+
}
135+
</source>
136+
</configuration>
137+
</execution>
138+
</executions>
139+
</plugin>
140+
<plugin>
141+
<groupId>org.codehaus.mojo</groupId>
142+
<artifactId>exec-maven-plugin</artifactId>
143+
<version>1.2.1</version>
144+
<executions>
145+
<execution>
146+
<id>systemvm-template-metadata</id>
147+
<phase>package</phase>
148+
<goals>
149+
<goal>exec</goal>
150+
</goals>
151+
<configuration>
152+
<workingDirectory>${basedir}/</workingDirectory>
153+
<executable>bash</executable>
154+
<arguments>
155+
<argument>templateConfig.sh</argument>
156+
<armument>${project.version}</armument>
157+
</arguments>
158+
</configuration>
159+
</execution>
160+
</executions>
161+
</plugin>
162+
</plugins>
163+
</build>
164+
<profiles>
165+
<profile>
166+
<id>template-create</id>
167+
<activation>
168+
<property>
169+
<name>noredist</name>
170+
</property>
171+
</activation>
172+
<build>
173+
<plugins>
174+
<plugin>
175+
<groupId>org.apache.maven.plugins</groupId>
176+
<artifactId>maven-resources-plugin</artifactId>
177+
<version>${cs.resources-plugin.version}</version>
178+
</plugin>
179+
<plugin>
180+
<groupId>com.googlecode.maven-download-plugin</groupId>
181+
<artifactId>download-maven-plugin</artifactId>
182+
<version>1.6.3</version>
183+
<executions>
184+
<execution>
185+
<id>download-kvm-template</id>
186+
<goals>
187+
<goal>wget</goal>
188+
</goals>
189+
<configuration>
190+
<checkSignature>true</checkSignature>
191+
<url>https://download.cloudstack.org/systemvm/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-kvm.qcow2.bz2</url>
192+
<outputDirectory>${basedir}/dist/systemvm-templates/</outputDirectory>
193+
<md5>${kvm.checksum}</md5>
194+
</configuration>
195+
</execution>
196+
<execution>
197+
<id>download-vmware-template</id>
198+
<goals>
199+
<goal>wget</goal>
200+
</goals>
201+
<configuration>
202+
<checkSignature>true</checkSignature>
203+
<url>https://download.cloudstack.org/systemvm/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-vmware.ova</url>
204+
<outputDirectory>${basedir}/dist/systemvm-templates/</outputDirectory>
205+
<md5>${vmware.checksum}</md5>
206+
</configuration>
207+
</execution>
208+
<execution>
209+
<id>download-xenserver-template</id>
210+
<goals>
211+
<goal>wget</goal>
212+
</goals>
213+
<configuration>
214+
<checkSignature>true</checkSignature>
215+
<url>https://download.cloudstack.org/systemvm/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-xen.vhd.bz2</url>
216+
<outputDirectory>${basedir}/dist/systemvm-templates/</outputDirectory>
217+
<md5>${xen.checksum}</md5>
218+
</configuration>
219+
</execution>
220+
</executions>
221+
</plugin>
222+
</plugins>
223+
</build>
224+
</profile>
225+
</profiles>
56226
</project>

engine/schema/src/main/java/com/cloud/dc/dao/ClusterDao.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.util.List;
2424
import java.util.Map;
25+
import java.util.Set;
2526

2627
public interface ClusterDao extends GenericDao<ClusterVO, Long> {
2728
List<ClusterVO> listByPodId(long podId);
@@ -34,6 +35,8 @@ public interface ClusterDao extends GenericDao<ClusterVO, Long> {
3435

3536
List<HypervisorType> getAvailableHypervisorInZone(Long zoneId);
3637

38+
Set<HypervisorType> getDistictAvailableHypervisorsAcrossClusters();
39+
3740
List<ClusterVO> listByDcHyType(long dcId, String hyType);
3841

3942
Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds);

engine/schema/src/main/java/com/cloud/dc/dao/ClusterDaoImpl.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939
import java.sql.SQLException;
4040
import java.util.ArrayList;
4141
import java.util.HashMap;
42+
import java.util.HashSet;
4243
import java.util.List;
4344
import java.util.Map;
45+
import java.util.Set;
4446

4547
@Component
4648
public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements ClusterDao {
@@ -51,6 +53,7 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
5153
protected final SearchBuilder<ClusterVO> ZoneSearch;
5254
protected final SearchBuilder<ClusterVO> ZoneHyTypeSearch;
5355
protected final SearchBuilder<ClusterVO> ZoneClusterSearch;
56+
protected final SearchBuilder<ClusterVO> ClusterSearch;
5457

5558
protected GenericSearchBuilder<ClusterVO, Long> ClusterIdSearch;
5659

@@ -97,6 +100,10 @@ public ClusterDaoImpl() {
97100
ClusterIdSearch.selectFields(ClusterIdSearch.entity().getId());
98101
ClusterIdSearch.and("dataCenterId", ClusterIdSearch.entity().getDataCenterId(), Op.EQ);
99102
ClusterIdSearch.done();
103+
104+
ClusterSearch = createSearchBuilder();
105+
ClusterSearch.select(null, Func.DISTINCT, ClusterSearch.entity().getHypervisorType());
106+
ClusterIdSearch.done();
100107
}
101108

102109
@Override
@@ -154,6 +161,17 @@ public List<HypervisorType> getAvailableHypervisorInZone(Long zoneId) {
154161
return hypers;
155162
}
156163

164+
@Override
165+
public Set<HypervisorType> getDistictAvailableHypervisorsAcrossClusters() {
166+
SearchCriteria<ClusterVO> sc = ClusterSearch.create();
167+
List<ClusterVO> clusters = listBy(sc);
168+
Set<HypervisorType> hypers = new HashSet<>();
169+
for (ClusterVO cluster : clusters) {
170+
hypers.add(cluster.getHypervisorType());
171+
}
172+
return hypers;
173+
}
174+
157175
@Override
158176
public Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds) {
159177
TransactionLegacy txn = TransactionLegacy.currentTxn();

engine/schema/src/main/java/com/cloud/storage/dao/VMTemplateDao.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121

2222
import com.cloud.hypervisor.Hypervisor.HypervisorType;
23+
import com.cloud.storage.Storage;
2324
import com.cloud.storage.VMTemplateVO;
2425
import com.cloud.template.VirtualMachineTemplate;
2526
import com.cloud.utils.db.GenericDao;
@@ -72,6 +73,8 @@ public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long>, StateDao<
7273

7374
VMTemplateVO findRoutingTemplate(HypervisorType type, String templateName);
7475

76+
VMTemplateVO findLatestTemplateByTypeAndHypervisor(HypervisorType hypervisorType, Storage.TemplateType type);
77+
7578
public Long countTemplatesForAccount(long accountId);
7679

7780
public List<VMTemplateVO> listUnRemovedTemplatesByStates(VirtualMachineTemplate.State ...states);
@@ -81,4 +84,6 @@ public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long>, StateDao<
8184
void saveDetails(VMTemplateVO tmpl);
8285

8386
List<VMTemplateVO> listByParentTemplatetId(long parentTemplatetId);
87+
88+
VMTemplateVO findLatestTemplateByName(String name);
8489
}

0 commit comments

Comments
 (0)