Skip to content

Commit

Permalink
cluster: handle patched flags on scale-out and upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis committed Feb 24, 2021
1 parent 196c6be commit 224ff6d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pkg/cluster/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (m *Manager) confirmTopology(name, version string, topo spec.Topology, patc

topo.IterInstance(func(instance spec.Instance) {
comp := instance.ComponentName()
if patchedRoles.Exist(comp) {
if patchedRoles.Exist(comp) || instance.IsPatched() {
comp += " (patched)"
}
clusterTable = append(clusterTable, []string{
Expand Down
6 changes: 1 addition & 5 deletions pkg/cluster/manager/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ func (m *Manager) Patch(name string, packagePath string, opt operator.Options, o
}
}
})
if err := m.specManager.SaveMeta(name, metadata); err != nil {
return perrs.Trace(err)
}

return nil
return m.specManager.SaveMeta(name, metadata)
}

func checkPackage(bindVersion spec.BindVersion, specManager *spec.SpecManager, name, comp, nodeOS, arch, packagePath string) error {
Expand Down
1 change: 1 addition & 0 deletions pkg/cluster/manager/scale_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func (m *Manager) ScaleOut(
newPart.IterInstance(func(instance spec.Instance) {
if utils.IsExist(m.specManager.Path(name, spec.PatchDirName, instance.ComponentName()+".tar.gz")) {
patchedComponents.Insert(instance.ComponentName())
instance.SetPatched(true)
}
})

Expand Down
16 changes: 11 additions & 5 deletions pkg/cluster/manager/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,20 @@ func (m *Manager) Upgrade(name string, clusterVersion string, opt operator.Optio
return perrs.Trace(err)
}

metadata.SetVersion(clusterVersion)

if err := m.specManager.SaveMeta(name, metadata); err != nil {
// clear patched packages and tags
if err := os.RemoveAll(m.specManager.Path(name, "patch")); err != nil {
return perrs.Trace(err)
}
topo.IterInstance(func(ins spec.Instance) {
if ins.IsPatched() {
ins.SetPatched(false)
}
})

if err := os.RemoveAll(m.specManager.Path(name, "patch")); err != nil {
return perrs.Trace(err)
metadata.SetVersion(clusterVersion)

if err := m.specManager.SaveMeta(name, metadata); err != nil {
return err
}

log.Infof("Upgraded cluster `%s` successfully", name)
Expand Down

0 comments on commit 224ff6d

Please sign in to comment.