Skip to content

Commit 593cad6

Browse files
committed
Ensure auto updating stacks jump to latest version
fixes #6873 This checks to find end of the chain of replacement stacks when auto stack upgrade happens to skip steps between. This prevents unneeded restarts on subsquent maintenance windows.
1 parent 5d53428 commit 593cad6

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

forge/db/models/ProjectStack.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ module.exports = {
108108
instance: {
109109
projectCount: async function () {
110110
return await M.Project.count({ where: { ProjectStackId: this.id } })
111+
},
112+
findLatestStack: async function () {
113+
if (this.replacedBy) {
114+
return (await M.ProjectStack.byId(this.replacedBy)).findLatestStack()
115+
} else {
116+
return this
117+
}
111118
}
112119
}
113120
}

forge/ee/lib/autoUpdateStacks/tasks/upgrade-stack.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
if (project.Project.ProjectStack.replacedBy) {
2626
// need to add audit logging
2727
try {
28-
const newStack = await app.db.models.ProjectStack.byId(project.Project.ProjectStack.replacedBy)
28+
const newStack = await project.Project.ProjectStack.findLatestStack()
2929
app.log.info(`Updating project ${project.Project.id} to stack: '${newStack.hashid}'`)
3030

3131
const suspendOptions = {
@@ -46,6 +46,7 @@ module.exports = {
4646
// Space out restarts a little to not overwhelm k8s api
4747
await delay(2000)
4848
} catch (err) {
49+
console.log(err)
4950
app.log.info(`Problem updating project ${project.Project.id} - ${err.toString()}`)
5051
}
5152
} else if (project.value.restart) {

0 commit comments

Comments
 (0)