From 5f8450f28f1272bb2a3b73e3a5c88e717cb6e910 Mon Sep 17 00:00:00 2001 From: dahn Date: Fri, 19 Apr 2024 09:18:41 +0200 Subject: [PATCH 1/3] Add a shutdownhook to remove jobs owned by the process (#8896) Co-authored-by: Suresh Kumar Anaparti --- .../java/com/cloud/usage/UsageManagerImpl.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/usage/src/main/java/com/cloud/usage/UsageManagerImpl.java b/usage/src/main/java/com/cloud/usage/UsageManagerImpl.java index dd838f2f3ff..29f8a8decdd 100644 --- a/usage/src/main/java/com/cloud/usage/UsageManagerImpl.java +++ b/usage/src/main/java/com/cloud/usage/UsageManagerImpl.java @@ -316,6 +316,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna _sanity = _sanityExecutor.scheduleAtFixedRate(new SanityCheck(), 1, _sanityCheckInterval, TimeUnit.DAYS); } + Runtime.getRuntime().addShutdownHook(new AbandonJob()); TransactionLegacy usageTxn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); try { if (_heartbeatLock.lock(3)) { // 3 second timeout @@ -345,9 +346,11 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna if (_sanity != null) { _sanity.cancel(true); } + return true; } + @Override public void run() { (new ManagedContextRunnable() { @@ -2183,4 +2186,17 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna } } } + private class AbandonJob extends Thread { + @Override + public void run() { + s_logger.info("exitting Usage Manager"); + deleteOpenjob(); + } + private void deleteOpenjob() { + UsageJobVO job = _usageJobDao.isOwner(_hostname, _pid); + if (job != null) { + _usageJobDao.remove(job.getId()); + } + } + } } From d4a5459a8300a37712bb0bd60b21bb1baf52ea91 Mon Sep 17 00:00:00 2001 From: Vishesh Date: Fri, 19 Apr 2024 15:01:51 +0530 Subject: [PATCH 2/3] UI: Fix missing locale strings for Status widget (#8792) --- ui/src/components/widgets/Status.vue | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/ui/src/components/widgets/Status.vue b/ui/src/components/widgets/Status.vue index 62438820314..73b1a9af930 100644 --- a/ui/src/components/widgets/Status.vue +++ b/ui/src/components/widgets/Status.vue @@ -166,23 +166,24 @@ export default { if (!(state && this.displayText)) { return '' } + let result if (this.$route.path === '/vmsnapshot' || this.$route.path.includes('/vmsnapshot/')) { - return this.$t('message.vmsnapshot.state.' + state.toLowerCase()) + result = this.$t('message.vmsnapshot.state.' + state.toLowerCase()) + } else if (this.$route.path === '/vm' || this.$route.path.includes('/vm/')) { + result = this.$t('message.vm.state.' + state.toLowerCase()) + } else if (this.$route.path === '/volume' || this.$route.path.includes('/volume/')) { + result = this.$t('message.volume.state.' + state.toLowerCase()) + } else if (this.$route.path === '/guestnetwork' || this.$route.path.includes('/guestnetwork/')) { + result = this.$t('message.guestnetwork.state.' + state.toLowerCase()) + } else if (this.$route.path === '/publicip' || this.$route.path.includes('/publicip/')) { + result = this.$t('message.publicip.state.' + state.toLowerCase()) } - if (this.$route.path === '/vm' || this.$route.path.includes('/vm/')) { - return this.$t('message.vm.state.' + state.toLowerCase()) + + if (!result || (result.startsWith('message.') && result.endsWith('.state.' + state.toLowerCase()))) { + // Nothing for snapshots, vpcs, gateways, vnpnconn, vpnuser, kubectl, event, project, account, infra. They're all self explanatory + result = this.$t(state) } - if (this.$route.path === '/volume' || this.$route.path.includes('/volume/')) { - return this.$t('message.volume.state.' + state.toLowerCase()) - } - if (this.$route.path === '/guestnetwork' || this.$route.path.includes('/guestnetwork/')) { - return this.$t('message.guestnetwork.state.' + state.toLowerCase()) - } - if (this.$route.path === '/publicip' || this.$route.path.includes('/publicip/')) { - return this.$t('message.publicip.state.' + state.toLowerCase()) - } - // Nothing for snapshots, vpcs, gateways, vnpnconn, vpnuser, kubectl, event, project, account, infra. They're all self explanatory - return this.$t(state) + return result }, getStyle () { let styles = { display: 'inline-flex' } From 7affbb1dacf709424b33f30a5305c44ea201acd4 Mon Sep 17 00:00:00 2001 From: dahn Date: Fri, 19 Apr 2024 12:23:31 +0200 Subject: [PATCH 3/3] protect against null-path (#8915) Co-authored-by: Vladimir Dombrovski Co-authored-by: Vishesh Co-authored-by: Suresh Kumar Anaparti --- .../com/cloud/hypervisor/vmware/resource/VmwareResource.java | 5 ++++- systemvm/debian/etc/logrotate.d/haproxy | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java index b65a7847675..0612ed70510 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -3066,7 +3066,10 @@ public class VmwareResource extends ServerResourceBase implements StoragePoolRes } private String appendFileType(String path, String fileType) { - if (path.toLowerCase().endsWith(fileType.toLowerCase())) { + if (StringUtils.isBlank(path)) { + throw new CloudRuntimeException("No path given, cannot append filetype " + fileType); + } + if (fileType == null || path.toLowerCase().endsWith(fileType.toLowerCase())) { return path; } diff --git a/systemvm/debian/etc/logrotate.d/haproxy b/systemvm/debian/etc/logrotate.d/haproxy index 464209791a3..a6b72b6f77a 100644 --- a/systemvm/debian/etc/logrotate.d/haproxy +++ b/systemvm/debian/etc/logrotate.d/haproxy @@ -4,6 +4,6 @@ notifempty maxsize 10M postrotate - /bin/kill -HUP `cat /var/run/rsyslog.pid 2> /dev/null` 2> /dev/null || true + /usr/lib/rsyslog/rsyslog-rotate endscript }