Skip to content

Commit 2853871

Browse files
Fix the poll for the API ReadyForShutdown even after logout (#8004)
1 parent 3694667 commit 2853871

6 files changed

Lines changed: 19 additions & 4 deletions

File tree

plugins/shutdown/src/main/java/org/apache/cloudstack/api/command/ReadyForShutdownCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import com.cloud.user.Account;
3131

3232
@APICommand(name = ReadyForShutdownCmd.APINAME,
33-
description = "Returs the status of CloudStack, whether a shutdown has been triggered and if ready to shutdown",
33+
description = "Returns the status of CloudStack, whether a shutdown has been triggered and if ready to shutdown",
3434
since = "4.19.0",
3535
responseObject = ReadyForShutdownResponse.class,
3636
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)

ui/src/components/page/GlobalLayout.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ export default {
199199
created () {
200200
this.menus = this.mainMenu.find((item) => item.path === '/').children
201201
this.collapsed = !this.sidebarOpened
202-
setInterval(this.checkShutdown, 5000)
202+
const readyForShutdownPollingJob = setInterval(this.checkShutdown, 5000)
203+
this.$store.commit('SET_READY_FOR_SHUTDOWN_POLLING_JOB', readyForShutdownPollingJob)
203204
},
204205
mounted () {
205206
const layoutMode = this.$config.theme['@layout-mode'] || 'light'

ui/src/store/getters.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ const getters = {
5050
twoFaIssuer: state => state.user.twoFaIssuer,
5151
loginFlag: state => state.user.loginFlag,
5252
allProjects: (state) => state.app.allProjects,
53-
customHypervisorName: state => state.user.customHypervisorName
53+
customHypervisorName: state => state.user.customHypervisorName,
54+
readyForShutdownPollingJob: state => state.user.readyForShutdownPollingJob
5455
}
5556

5657
export default getters

ui/src/store/modules/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ const app = {
130130
},
131131
SET_SHUTDOWN_TRIGGERED: (state, shutdownTriggered) => {
132132
state.shutdownTriggered = shutdownTriggered
133+
},
134+
SET_READY_FOR_SHUTDOWN_POLLING_JOB: (state, readyForShutdownPollingJob) => {
135+
state.readyForShutdownPollingJob = readyForShutdownPollingJob
133136
}
134137
},
135138
actions: {
@@ -192,6 +195,9 @@ const app = {
192195
},
193196
SetShutdownTriggered ({ commit }, bool) {
194197
commit('SET_SHUTDOWN_TRIGGERED', bool)
198+
},
199+
SetReadyForShutdownPollingJob ({ commit }, job) {
200+
commit('SET_READY_FOR_SHUTDOWN_POLLING_JOB', job)
195201
}
196202
}
197203
}

ui/src/store/modules/user.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ const user = {
6565
twoFaEnabled: false,
6666
twoFaProvider: '',
6767
twoFaIssuer: '',
68-
customHypervisorName: 'Custom'
68+
customHypervisorName: 'Custom',
69+
readyForShutdownPollingJob: ''
6970
},
7071

7172
mutations: {
@@ -155,6 +156,9 @@ const user = {
155156
},
156157
SET_CUSTOM_HYPERVISOR_NAME (state, name) {
157158
state.customHypervisorName = name
159+
},
160+
SET_READY_FOR_SHUTDOWN_POLLING_JOB: (state, job) => {
161+
state.readyForShutdownPollingJob = job
158162
}
159163
},
160164

ui/src/views/auth/Login.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ export default {
189189
}
190190
this.initForm()
191191
if (store.getters.logoutFlag) {
192+
if (store.getters.readyForShutdownPollingJob !== '' || store.getters.readyForShutdownPollingJob !== undefined) {
193+
clearInterval(store.getters.readyForShutdownPollingJob)
194+
}
192195
sourceToken.init()
193196
this.fetchData()
194197
} else {

0 commit comments

Comments
 (0)