Skip to content

Commit cf6aae4

Browse files
committed
Update comments (TODOs), fix queries and rebase issues
1 parent 27b3e0f commit cf6aae4

File tree

9 files changed

+16
-14
lines changed

9 files changed

+16
-14
lines changed

pkg/controller/mysqlcluster/internal/syncer/secret.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131

3232
// NewSecretSyncer returns secret syncer
3333
// nolint: gocyclo
34-
// TODO: this syncer is not needed anymore and can be removed in future version
34+
// TODO: this syncer is not needed anymore and can be removed in future version (v0.4)
3535
func NewSecretSyncer(c client.Client, scheme *runtime.Scheme, cluster *mysqlcluster.MysqlCluster, opt *options.Options) syncer.Interface {
3636
obj := &core.Secret{
3737
ObjectMeta: metav1.ObjectMeta{

pkg/controller/mysqlcluster/internal/syncer/statefullset.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ func (s *sfsSyncer) ensureContainersSpec() []core.Container {
281281
"mysql",
282282
fmt.Sprintf("--defaults-file=%s", confClientPath),
283283
"-e",
284-
"SELECT 1", // TODO: ...
285-
// fmt.Sprintf("SELECT * FROM %s.%s", constants.OperatorDbName, "readiness"),
284+
fmt.Sprintf("SELECT * FROM %s.%s", constants.OperatorDbName, constants.OperatorReadinessTableName),
286285
},
287286
},
288287
})

pkg/controller/node/node_controller.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ func isOwnedByMySQL(meta metav1.Object) bool {
7272
return false
7373
}
7474

75-
// TODO: add more checks here
7675
labels := meta.GetLabels()
7776
if val, ok := labels["app.kubernetes.io/managed-by"]; ok {
7877
return val == "mysql.presslabs.org"
@@ -106,7 +105,6 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
106105
return isOwnedByMySQL(evt.Meta) && !isInitialized(evt.Object)
107106
},
108107
UpdateFunc: func(evt event.UpdateEvent) bool {
109-
log.V(1).Info("pod update event", "meta", evt.MetaNew)
110108
return isOwnedByMySQL(evt.MetaNew) && !isInitialized(evt.ObjectNew)
111109
},
112110
DeleteFunc: func(evt event.DeleteEvent) bool {

pkg/controller/node/sql.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (r *nodeSQLRunner) Wait(ctx context.Context) error {
8080

8181
func (r *nodeSQLRunner) DisableSuperReadOnly(ctx context.Context) (func(), error) {
8282
enable := func() {
83-
err := r.runQuery(ctx, "SET GLOBAL SUPER_READ_ONLY = 0;")
83+
err := r.runQuery(ctx, "SET GLOBAL SUPER_READ_ONLY = 1;")
8484
if err != nil {
8585
log.Error(err, "failed to set node super read only", "node", r.Host())
8686
}
@@ -123,6 +123,7 @@ func (r *nodeSQLRunner) ChangeMasterTo(ctx context.Context, masterHost, user, pa
123123
return nil
124124
}
125125

126+
// MarkConfigurationDone write in a MEMORY table value. The readiness probe checks for that value to exist to succeed.
126127
func (r *nodeSQLRunner) MarkConfigurationDone(ctx context.Context) error {
127128
query := `
128129
CREATE TABLE IF NOT EXISTS %s.%s (
@@ -131,7 +132,7 @@ func (r *nodeSQLRunner) MarkConfigurationDone(ctx context.Context) error {
131132
132133
INSERT INTO %[1]s.%[2]s VALUES (1);
133134
`
134-
query = fmt.Sprintf(query, constants.OperatorDbName, "readiness")
135+
query = fmt.Sprintf(query, constants.OperatorDbName, constants.OperatorReadinessTableName)
135136

136137
if err := r.runQuery(ctx, query); err != nil {
137138
return fmt.Errorf("failed to mark configuration done, err: %s", err)
@@ -210,10 +211,11 @@ func (r *nodeSQLRunner) SetPurgedGTID(ctx context.Context) error {
210211
var used bool
211212
if err := r.readFromMysql(ctx, qq, &used); err != nil {
212213
// if it's a: "Table doesn't exist" error then GTID should not be set, it's a master case.
213-
if isMySQLError(err, 1146) {
214+
if isMySQLError(err, 1146) || err == sql.ErrNoRows {
214215
log.V(1).Info("GTID purged table does not exists", "host", r.Host())
215216
return nil
216217
}
218+
217219
return err
218220
}
219221

pkg/controller/orchestrator/orchestrator_reconcile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func (ou *orcUpdater) updateNodeCondition(host string, cType api.NodeConditionTy
391391
}
392392

393393
// removeNodeConditionNotInOrc marks nodes not in orc with unknown condition
394-
// TODO: this function should remove completly from cluster.Status.Nodes nodes
394+
// TODO: this function should remove completely from cluster.Status.Nodes nodes
395395
// that are no longer in orchestrator and in k8s
396396
func (ou *orcUpdater) removeNodeConditionNotInOrc(insts InstancesSet) {
397397
for _, ns := range ou.cluster.Status.Nodes {

pkg/controller/orchestrator/orchestrator_syncers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func newFinalizerSyncer(c client.Client, scheme *runtime.Scheme, cluster *mysqlc
3535

3636
// always add finalizer, this action is idempotent
3737
addFinalizer(out, OrchestratorFinalizer)
38-
// TODO: remove this in next version
38+
// TODO: remove this in next version (v0.4)
3939
removeFinalizer(out, OldOrchestratorFinalizer)
4040

4141
// if cluster is deleted then check orchestrator status and remove finalizer if no node is in orchestrator

pkg/internal/mysqlcluster/mysqlcluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (c *MysqlCluster) GetMysqlImage() string {
188188

189189
// UpdateSpec updates the cluster specs that need to be saved
190190
func (c *MysqlCluster) UpdateSpec() {
191-
// TODO: remove this in next major release
191+
// TODO: remove this in next major release (v0.4)
192192
if len(c.Spec.InitBucketURL) == 0 {
193193
c.Spec.InitBucketURL = c.Spec.InitBucketURI
194194
}

pkg/sidecar/appconf.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func initFileQuery(cfg *Config, gtidPurged string) []byte {
151151
}
152152

153153
// create operator database because GRANTS need it
154-
queries = append(queries, fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s;", toolsDbName))
154+
queries = append(queries, fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", toolsDbName))
155155

156156
// configure operator utility user
157157
queries = append(queries, createUserQuery(cfg.OperatorUser, cfg.OperatorPassword, "%",
@@ -190,11 +190,11 @@ func initFileQuery(cfg *Config, gtidPurged string) []byte {
190190
)`, constants.OperatorDbName, constants.OperatorGtidsTableName))
191191

192192
// nolint: gosec
193-
queries = append(queries, fmt.Sprintf(`REPLACE INTO %s.%s VALUES (1, '%s')`,
193+
queries = append(queries, fmt.Sprintf(`REPLACE INTO %s.%s (id, gtid) VALUES (1, '%s')`,
194194
constants.OperatorDbName, constants.OperatorGtidsTableName, gtidPurged))
195195
}
196196

197-
return []byte(strings.Join(queries, ";\n"))
197+
return []byte(strings.Join(queries, ";\n") + ";\n")
198198
}
199199

200200
func createUserQuery(name, pass, host string, rights ...interface{}) []string {

pkg/util/constants/constants.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ const (
4444
// OperatorGtidsTableName represents the name of the table that is used to store the GTID
4545
OperatorGtidsTableName = "gtids"
4646

47+
// OperatorReadinessTableName is the name of the table that is used to store a readiness flag (boolean)
48+
OperatorReadinessTableName = "readiness"
49+
4750
// ConfVolumeMountPath is the path where mysql configs will be mounted
4851
ConfVolumeMountPath = "/etc/mysql"
4952

0 commit comments

Comments
 (0)