You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by we...@apache.org on 2023/08/29 12:36:25 UTC
[cloudstack] branch 4.19-fix-test_vm_autoscaling created (now f6366fa0c45)
This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a change to branch 4.19-fix-test_vm_autoscaling
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
at f6366fa0c45 test: fix test_vm_autoscaling.py which does not work due to userdata improvement
This branch includes the following new commits:
new 2c226829762 fix cloudstack-utils.jar
new 07750b3702e utils: build both SHADED and original jars
new f262ec178f8 userdata: support plain text
new 043c1c0dc8d Revert "userdata: support plain text"
new f6366fa0c45 test: fix test_vm_autoscaling.py which does not work due to userdata improvement
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[cloudstack] 04/05: Revert "userdata: support plain text"
Posted by we...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a commit to branch 4.19-fix-test_vm_autoscaling
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 043c1c0dc8d39c7a03e5150811bda9b530a10ccd
Author: Wei Zhou <we...@apache.org>
AuthorDate: Tue Aug 29 14:28:38 2023 +0200
Revert "userdata: support plain text"
This reverts commit f262ec178f847c10411daee3c6de5198b8d47827.
---
.../cloudstack/userdata/CloudInitUserDataProvider.java | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/engine/userdata/cloud-init/src/main/java/org/apache/cloudstack/userdata/CloudInitUserDataProvider.java b/engine/userdata/cloud-init/src/main/java/org/apache/cloudstack/userdata/CloudInitUserDataProvider.java
index 25be89ed5fb..6e1086c631e 100644
--- a/engine/userdata/cloud-init/src/main/java/org/apache/cloudstack/userdata/CloudInitUserDataProvider.java
+++ b/engine/userdata/cloud-init/src/main/java/org/apache/cloudstack/userdata/CloudInitUserDataProvider.java
@@ -46,21 +46,19 @@ import com.sun.mail.util.BASE64DecoderStream;
public class CloudInitUserDataProvider extends AdapterBase implements UserDataProvider {
protected enum FormatType {
- CLOUD_CONFIG, BASH_SCRIPT, MIME, CLOUD_BOOTHOOK, INCLUDE_FILE, PLAIN_TEXT
+ CLOUD_CONFIG, BASH_SCRIPT, MIME, CLOUD_BOOTHOOK, INCLUDE_FILE
}
private static final String CLOUD_CONFIG_CONTENT_TYPE = "text/cloud-config";
private static final String BASH_SCRIPT_CONTENT_TYPE = "text/x-shellscript";
private static final String INCLUDE_FILE_CONTENT_TYPE = "text/x-include-url";
private static final String CLOUD_BOOTHOOK_CONTENT_TYPE = "text/cloud-boothook";
- private static final String PLAIN_TEXT_CONTENT_TYPE = "text/plain";
private static final Map<FormatType, String> formatContentTypeMap = Map.ofEntries(
Map.entry(FormatType.CLOUD_CONFIG, CLOUD_CONFIG_CONTENT_TYPE),
Map.entry(FormatType.BASH_SCRIPT, BASH_SCRIPT_CONTENT_TYPE),
Map.entry(FormatType.CLOUD_BOOTHOOK, CLOUD_BOOTHOOK_CONTENT_TYPE),
- Map.entry(FormatType.INCLUDE_FILE, INCLUDE_FILE_CONTENT_TYPE),
- Map.entry(FormatType.PLAIN_TEXT, PLAIN_TEXT_CONTENT_TYPE)
+ Map.entry(FormatType.INCLUDE_FILE, INCLUDE_FILE_CONTENT_TYPE)
);
private static final Session session = Session.getDefaultInstance(new Properties());
@@ -87,17 +85,14 @@ public class CloudInitUserDataProvider extends AdapterBase implements UserDataPr
.filter(x -> (x.startsWith("#") && !x.startsWith("##")) || (x.startsWith("Content-Type:")))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(lines)) {
- logger.info("Failed to detect the user data format type as it " +
- "does not contain a header, regard it as plain text");
- return null;
+ throw new CloudRuntimeException("Failed to detect the user data format type as it " +
+ "does not contain a header");
}
return lines.get(0);
}
protected FormatType mapUserDataHeaderToFormatType(String header) {
- if (header == null) {
- return FormatType.PLAIN_TEXT;
- } else if (header.equalsIgnoreCase("#cloud-config")) {
+ if (header.equalsIgnoreCase("#cloud-config")) {
return FormatType.CLOUD_CONFIG;
} else if (header.startsWith("#!")) {
return FormatType.BASH_SCRIPT;
@@ -253,7 +248,7 @@ public class CloudInitUserDataProvider extends AdapterBase implements UserDataPr
String userData2 = new String(Base64.decodeBase64(encodedUserData2));
FormatType formatType1 = getUserDataFormatType(userData1);
FormatType formatType2 = getUserDataFormatType(userData2);
- if (formatType1.equals(formatType2) && List.of(FormatType.CLOUD_CONFIG, FormatType.BASH_SCRIPT, FormatType.PLAIN_TEXT).contains(formatType1)) {
+ if (formatType1.equals(formatType2) && List.of(FormatType.CLOUD_CONFIG, FormatType.BASH_SCRIPT).contains(formatType1)) {
return simpleAppendSameFormatTypeUserData(userData1, userData2);
}
NoIdMimeMessage message = new NoIdMimeMessage(session);
[cloudstack] 01/05: fix cloudstack-utils.jar
Posted by we...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a commit to branch 4.19-fix-test_vm_autoscaling
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 2c2268297623f19178c104c8417406f9e0568a32
Author: Wei Zhou <we...@apache.org>
AuthorDate: Fri Aug 25 08:06:38 2023 +0200
fix cloudstack-utils.jar
---
utils/pom.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/utils/pom.xml b/utils/pom.xml
index 46897031d14..14b05c8706b 100755
--- a/utils/pom.xml
+++ b/utils/pom.xml
@@ -269,6 +269,8 @@
<include>commons-codec:commons-codec</include>
<include>org.apache.commons:commons-lang3</include>
<include>org.jasypt:jasypt</include>
+ <include>org.apache.logging.log4j:log4j-core</include>
+ <include>org.apache.logging.log4j:log4j-api</include>
</includes>
</artifactSet>
</configuration>
[cloudstack] 02/05: utils: build both SHADED and original jars
Posted by we...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a commit to branch 4.19-fix-test_vm_autoscaling
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 07750b3702eecf506bacffa8a543bdd3cbc29960
Author: Wei Zhou <we...@apache.org>
AuthorDate: Fri Aug 25 09:15:40 2023 +0200
utils: build both SHADED and original jars
---
debian/rules | 2 +-
packaging/centos7/cloud.spec | 2 +-
packaging/centos8/cloud.spec | 2 +-
utils/pom.xml | 1 +
4 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/debian/rules b/debian/rules
index bac6572e64c..36d20cdad08 100755
--- a/debian/rules
+++ b/debian/rules
@@ -135,7 +135,7 @@ override_dh_auto_install:
install -D systemvm/dist/* $(DESTDIR)/usr/share/$(PACKAGE)-common/vms/
# We need jasypt for cloud-install-sys-tmplt, so this is a nasty hack to get it into the right place
install -D agent/target/dependencies/jasypt-1.9.3.jar $(DESTDIR)/usr/share/$(PACKAGE)-common/lib
- install -D utils/target/cloud-utils-$(VERSION).jar $(DESTDIR)/usr/share/$(PACKAGE)-common/lib/$(PACKAGE)-utils.jar
+ install -D utils/target/cloud-utils-$(VERSION)-SHADED.jar $(DESTDIR)/usr/share/$(PACKAGE)-common/lib/$(PACKAGE)-utils.jar
install -D agent/target/dependencies/log4j-api-2.19.0.jar $(DESTDIR)/usr/share/$(PACKAGE)-common/lib
install -D agent/target/dependencies/log4j-core-2.19.0.jar $(DESTDIR)/usr/share/$(PACKAGE)-common/lib
diff --git a/packaging/centos7/cloud.spec b/packaging/centos7/cloud.spec
index 80dbf35abd7..d15c5af4be8 100644
--- a/packaging/centos7/cloud.spec
+++ b/packaging/centos7/cloud.spec
@@ -302,7 +302,7 @@ ln -sf log4j-cloud.xml ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/log4j
install python/bindir/cloud-external-ipallocator.py ${RPM_BUILD_ROOT}%{_bindir}/%{name}-external-ipallocator.py
install -D client/target/pythonlibs/jasypt-1.9.3.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/jasypt-1.9.3.jar
-install -D utils/target/cloud-utils-%{_maventag}.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/%{name}-utils.jar
+install -D utils/target/cloud-utils-%{_maventag}-SHADED.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/%{name}-utils.jar
install -D agent/target/dependencies/log4j-core-2.19.0.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/log4j-core-2.19.0.jar
install -D agent/target/dependencies/log4j-api-2.19.0.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/log4j-api-2.19.0.jar
diff --git a/packaging/centos8/cloud.spec b/packaging/centos8/cloud.spec
index 58968aaf226..b8d00d29f9f 100644
--- a/packaging/centos8/cloud.spec
+++ b/packaging/centos8/cloud.spec
@@ -284,7 +284,7 @@ ln -sf log4j-cloud.xml ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/log4j
install python/bindir/cloud-external-ipallocator.py ${RPM_BUILD_ROOT}%{_bindir}/%{name}-external-ipallocator.py
install -D client/target/pythonlibs/jasypt-1.9.3.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/jasypt-1.9.3.jar
-install -D utils/target/cloud-utils-%{_maventag}.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/%{name}-utils.jar
+install -D utils/target/cloud-utils-%{_maventag}-SHADED.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/%{name}-utils.jar
install -D agent/target/dependencies/log4j-core-2.19.0.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/log4j-core-2.19.0.jar
install -D agent/target/dependencies/log4j-api-2.19.0.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/log4j-api-2.19.0.jar
diff --git a/utils/pom.xml b/utils/pom.xml
index 14b05c8706b..629b8aed304 100755
--- a/utils/pom.xml
+++ b/utils/pom.xml
@@ -260,6 +260,7 @@
<goal>shade</goal>
</goals>
<configuration>
+ <finalName>${project.artifactId}-${project.version}-SHADED</finalName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
[cloudstack] 05/05: test: fix test_vm_autoscaling.py which does not work due to userdata improvement
Posted by we...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a commit to branch 4.19-fix-test_vm_autoscaling
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit f6366fa0c45186fecee9c7524ea7d4bc57715634
Author: Wei Zhou <we...@apache.org>
AuthorDate: Tue Aug 29 14:34:44 2023 +0200
test: fix test_vm_autoscaling.py which does not work due to userdata improvement
---
test/integration/smoke/test_vm_autoscaling.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/test/integration/smoke/test_vm_autoscaling.py b/test/integration/smoke/test_vm_autoscaling.py
index 316f94fd5fd..7ae61ce57da 100644
--- a/test/integration/smoke/test_vm_autoscaling.py
+++ b/test/integration/smoke/test_vm_autoscaling.py
@@ -204,7 +204,10 @@ class TestVmAutoScaling(cloudstackTestCase):
cls.apiUserdata = UserData.register(
cls.apiclient,
name="ApiUserdata",
- userdata="QVBJdXNlcmRhdGE=", #APIuserdata
+ userdata="IyEvYmluL2Jhc2gKCmVjaG8gIkFQSVVzZXJkYXRhIgoK",
+ # #!/bin/bash
+ #
+ # echo "APIUserData"
account=cls.regular_user.name,
domainid=cls.regular_user.domainid
)
@@ -327,7 +330,10 @@ class TestVmAutoScaling(cloudstackTestCase):
serviceofferingid=cls.service_offering.id,
zoneid=cls.zone.id,
templateid=cls.template.id,
- userdata="VGVzdFVzZXJEYXRh", #TestUserData
+ userdata="IyEvYmluL2Jhc2gKCmVjaG8gIlRlc3RVc2VyRGF0YSIKCg==",
+ # #!/bin/bash
+ #
+ # echo "TestUserData"
expungevmgraceperiod=DEFAULT_EXPUNGE_VM_GRACE_PERIOD,
otherdeployparams=cls.otherdeployparams
)
[cloudstack] 03/05: userdata: support plain text
Posted by we...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a commit to branch 4.19-fix-test_vm_autoscaling
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit f262ec178f847c10411daee3c6de5198b8d47827
Author: Wei Zhou <we...@apache.org>
AuthorDate: Sat Aug 26 15:23:13 2023 +0200
userdata: support plain text
---
.../cloudstack/userdata/CloudInitUserDataProvider.java | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/engine/userdata/cloud-init/src/main/java/org/apache/cloudstack/userdata/CloudInitUserDataProvider.java b/engine/userdata/cloud-init/src/main/java/org/apache/cloudstack/userdata/CloudInitUserDataProvider.java
index 6e1086c631e..25be89ed5fb 100644
--- a/engine/userdata/cloud-init/src/main/java/org/apache/cloudstack/userdata/CloudInitUserDataProvider.java
+++ b/engine/userdata/cloud-init/src/main/java/org/apache/cloudstack/userdata/CloudInitUserDataProvider.java
@@ -46,19 +46,21 @@ import com.sun.mail.util.BASE64DecoderStream;
public class CloudInitUserDataProvider extends AdapterBase implements UserDataProvider {
protected enum FormatType {
- CLOUD_CONFIG, BASH_SCRIPT, MIME, CLOUD_BOOTHOOK, INCLUDE_FILE
+ CLOUD_CONFIG, BASH_SCRIPT, MIME, CLOUD_BOOTHOOK, INCLUDE_FILE, PLAIN_TEXT
}
private static final String CLOUD_CONFIG_CONTENT_TYPE = "text/cloud-config";
private static final String BASH_SCRIPT_CONTENT_TYPE = "text/x-shellscript";
private static final String INCLUDE_FILE_CONTENT_TYPE = "text/x-include-url";
private static final String CLOUD_BOOTHOOK_CONTENT_TYPE = "text/cloud-boothook";
+ private static final String PLAIN_TEXT_CONTENT_TYPE = "text/plain";
private static final Map<FormatType, String> formatContentTypeMap = Map.ofEntries(
Map.entry(FormatType.CLOUD_CONFIG, CLOUD_CONFIG_CONTENT_TYPE),
Map.entry(FormatType.BASH_SCRIPT, BASH_SCRIPT_CONTENT_TYPE),
Map.entry(FormatType.CLOUD_BOOTHOOK, CLOUD_BOOTHOOK_CONTENT_TYPE),
- Map.entry(FormatType.INCLUDE_FILE, INCLUDE_FILE_CONTENT_TYPE)
+ Map.entry(FormatType.INCLUDE_FILE, INCLUDE_FILE_CONTENT_TYPE),
+ Map.entry(FormatType.PLAIN_TEXT, PLAIN_TEXT_CONTENT_TYPE)
);
private static final Session session = Session.getDefaultInstance(new Properties());
@@ -85,14 +87,17 @@ public class CloudInitUserDataProvider extends AdapterBase implements UserDataPr
.filter(x -> (x.startsWith("#") && !x.startsWith("##")) || (x.startsWith("Content-Type:")))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(lines)) {
- throw new CloudRuntimeException("Failed to detect the user data format type as it " +
- "does not contain a header");
+ logger.info("Failed to detect the user data format type as it " +
+ "does not contain a header, regard it as plain text");
+ return null;
}
return lines.get(0);
}
protected FormatType mapUserDataHeaderToFormatType(String header) {
- if (header.equalsIgnoreCase("#cloud-config")) {
+ if (header == null) {
+ return FormatType.PLAIN_TEXT;
+ } else if (header.equalsIgnoreCase("#cloud-config")) {
return FormatType.CLOUD_CONFIG;
} else if (header.startsWith("#!")) {
return FormatType.BASH_SCRIPT;
@@ -248,7 +253,7 @@ public class CloudInitUserDataProvider extends AdapterBase implements UserDataPr
String userData2 = new String(Base64.decodeBase64(encodedUserData2));
FormatType formatType1 = getUserDataFormatType(userData1);
FormatType formatType2 = getUserDataFormatType(userData2);
- if (formatType1.equals(formatType2) && List.of(FormatType.CLOUD_CONFIG, FormatType.BASH_SCRIPT).contains(formatType1)) {
+ if (formatType1.equals(formatType2) && List.of(FormatType.CLOUD_CONFIG, FormatType.BASH_SCRIPT, FormatType.PLAIN_TEXT).contains(formatType1)) {
return simpleAppendSameFormatTypeUserData(userData1, userData2);
}
NoIdMimeMessage message = new NoIdMimeMessage(session);