Skip to content

Commit c29428d

Browse files
committed
Register nodes into orchestrator at upgrade time
1 parent 3a293e1 commit c29428d

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

hack/charts/mysql-operator/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ orchestrator:
6060
image: quay.io/presslabs/mysql-operator-orchestrator:latest
6161

6262
# orchestrator user and password to manage MySQL clusters
63-
topologyUser: sys_orchestrator
63+
topologyUser: orchestrator
6464
topologyPassword: # this is empty and will be random generated if not specified
6565

6666
resources:
@@ -105,7 +105,7 @@ orchestrator:
105105

106106
# key value map of orchestrator conf directives.
107107
# see: https://github.com/github/orchestrator/blob/master/conf/orchestrator-sample.conf.json
108-
# the following keys are manages and thus cannot be ovewritten:
108+
# the following keys are manages and thus cannot be overwritten:
109109
# - ListenAddress :3000
110110
# - MySQLTopologyCredentialsConfigFile /orchestrator/conf/orc-topology.cnf
111111
# - BackendDB sqlite

pkg/controller/mysqlcluster/internal/upgrades/upgrades.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"github.com/presslabs/mysql-operator/pkg/internal/mysqlcluster"
3434
"github.com/presslabs/mysql-operator/pkg/options"
3535
orc "github.com/presslabs/mysql-operator/pkg/orchestrator"
36+
"github.com/presslabs/mysql-operator/pkg/util/constants"
3637
)
3738

3839
var log = logf.Log.WithName("upgrades.cluster")
@@ -69,14 +70,20 @@ func (u *upgrader) Run(ctx context.Context) error {
6970
return err
7071
}
7172

73+
// register old nodes in new orchestrator
74+
for _, ns := range u.cluster.Status.Nodes {
75+
if err = u.orcClient.Discover(ns.Name, constants.MysqlPort); err != nil {
76+
log.Error(err, "failed to discover old hosts in new orchestrator - continue", "host", ns.Name)
77+
}
78+
}
79+
80+
// retrieve instances from orchestrator
7281
insts, err := u.instancesFromOrc()
7382
if err != nil {
7483
return err
7584
}
7685

77-
// more than 1 replica so there is the case when node 0 is slave so mark all other nodes as
78-
// in maintenance except node 0.
79-
// TODO: or set promotion rules
86+
// more than 1 replica so there is the case when node 0 is slave so scale down to 1
8087
if int(*sts.Spec.Replicas) > 1 {
8188
one := int32(1)
8289
sts.Spec.Replicas = &one

0 commit comments

Comments
 (0)