Skip to content

Commit

Permalink
manager: set patched flag properly
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis committed Feb 22, 2021
1 parent 0b951ba commit 00af2ed
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions components/dm/spec/topology_dm.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ type MasterSpec struct {
Host string `yaml:"host"`
SSHPort int `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
Imported bool `yaml:"imported,omitempty"`
Patched bool `yaml:"patched,omitempty"`
// Use Name to get the name with a default value if it's empty.
Name string `yaml:"name,omitempty"`
Port int `yaml:"port,omitempty" default:"8261"`
Expand Down Expand Up @@ -173,6 +174,7 @@ type WorkerSpec struct {
Host string `yaml:"host"`
SSHPort int `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
Imported bool `yaml:"imported,omitempty"`
Patched bool `yaml:"patched,omitempty"`
// Use Name to get the name with a default value if it's empty.
Name string `yaml:"name,omitempty"`
Port int `yaml:"port,omitempty" default:"8262"`
Expand Down
13 changes: 13 additions & 0 deletions pkg/cluster/manager/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ func (m *Manager) Patch(name string, packagePath string, opt operator.Options, o
}
}

// mark instance as patched in meta
topo.IterInstance(func(ins spec.Instance) {
for _, pachedIns := range insts {
if ins.ID() == pachedIns.ID() {
ins.SetPatched(true)
break
}
}
})
if err := m.specManager.SaveMeta(name, metadata); err != nil {
return perrs.Trace(err)
}

return nil
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/cluster/spec/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ type Instance interface {
OS() string // only linux supported now
Arch() string
IsPatched() bool
SetPatched(bool)
}

// PortStarted wait until a port is being listened
Expand Down Expand Up @@ -369,6 +370,15 @@ func (i *BaseInstance) IsPatched() bool {
return v.Bool()
}

// SetPatched implements the Instance interface
func (i *BaseInstance) SetPatched(p bool) {
v := reflect.Indirect(reflect.ValueOf(i.InstanceSpec)).FieldByName("Patched")
if !v.CanSet() {
return
}
v.SetBool(p)
}

// PrepareStart checks instance requirements before starting
func (i *BaseInstance) PrepareStart(tlsCfg *tls.Config) error {
return nil
Expand Down

0 comments on commit 00af2ed

Please sign in to comment.