From f373420d65597bfc8d0cfcde0877c6022716005b Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Mon, 12 Aug 2024 10:44:49 +0200 Subject: [PATCH 1/2] Remove SSLInternalSecretName option. (#724) --- api/v1alpha1/perconaservermysql_types.go | 35 +++++++++---------- .../ps.percona.com_perconaservermysqls.yaml | 2 -- deploy/bundle.yaml | 2 -- deploy/crd.yaml | 2 -- deploy/cw-bundle.yaml | 2 -- 5 files changed, 17 insertions(+), 26 deletions(-) diff --git a/api/v1alpha1/perconaservermysql_types.go b/api/v1alpha1/perconaservermysql_types.go index 7d9ee26b9..414480e5e 100644 --- a/api/v1alpha1/perconaservermysql_types.go +++ b/api/v1alpha1/perconaservermysql_types.go @@ -44,24 +44,23 @@ import ( // PerconaServerMySQLSpec defines the desired state of PerconaServerMySQL type PerconaServerMySQLSpec struct { - CRVersion string `json:"crVersion,omitempty"` - Pause bool `json:"pause,omitempty"` - SecretsName string `json:"secretsName,omitempty"` - SSLSecretName string `json:"sslSecretName,omitempty"` - SSLInternalSecretName string `json:"sslInternalSecretName,omitempty"` - Unsafe UnsafeFlags `json:"unsafeFlags,omitempty"` - InitImage string `json:"initImage,omitempty"` - IgnoreAnnotations []string `json:"ignoreAnnotations,omitempty"` - IgnoreLabels []string `json:"ignoreLabels,omitempty"` - MySQL MySQLSpec `json:"mysql,omitempty"` - Orchestrator OrchestratorSpec `json:"orchestrator,omitempty"` - PMM *PMMSpec `json:"pmm,omitempty"` - Backup *BackupSpec `json:"backup,omitempty"` - Proxy ProxySpec `json:"proxy,omitempty"` - TLS *TLSSpec `json:"tls,omitempty"` - Toolkit *ToolkitSpec `json:"toolkit,omitempty"` - UpgradeOptions UpgradeOptions `json:"upgradeOptions,omitempty"` - UpdateStrategy appsv1.StatefulSetUpdateStrategyType `json:"updateStrategy,omitempty"` + CRVersion string `json:"crVersion,omitempty"` + Pause bool `json:"pause,omitempty"` + SecretsName string `json:"secretsName,omitempty"` + SSLSecretName string `json:"sslSecretName,omitempty"` + Unsafe UnsafeFlags `json:"unsafeFlags,omitempty"` + InitImage string `json:"initImage,omitempty"` + IgnoreAnnotations []string `json:"ignoreAnnotations,omitempty"` + IgnoreLabels []string `json:"ignoreLabels,omitempty"` + MySQL MySQLSpec `json:"mysql,omitempty"` + Orchestrator OrchestratorSpec `json:"orchestrator,omitempty"` + PMM *PMMSpec `json:"pmm,omitempty"` + Backup *BackupSpec `json:"backup,omitempty"` + Proxy ProxySpec `json:"proxy,omitempty"` + TLS *TLSSpec `json:"tls,omitempty"` + Toolkit *ToolkitSpec `json:"toolkit,omitempty"` + UpgradeOptions UpgradeOptions `json:"upgradeOptions,omitempty"` + UpdateStrategy appsv1.StatefulSetUpdateStrategyType `json:"updateStrategy,omitempty"` } type UnsafeFlags struct { diff --git a/config/crd/bases/ps.percona.com_perconaservermysqls.yaml b/config/crd/bases/ps.percona.com_perconaservermysqls.yaml index 5e053c724..d50d86e25 100644 --- a/config/crd/bases/ps.percona.com_perconaservermysqls.yaml +++ b/config/crd/bases/ps.percona.com_perconaservermysqls.yaml @@ -7570,8 +7570,6 @@ spec: type: object secretsName: type: string - sslInternalSecretName: - type: string sslSecretName: type: string tls: diff --git a/deploy/bundle.yaml b/deploy/bundle.yaml index 0f7e26367..b80686269 100644 --- a/deploy/bundle.yaml +++ b/deploy/bundle.yaml @@ -9466,8 +9466,6 @@ spec: type: object secretsName: type: string - sslInternalSecretName: - type: string sslSecretName: type: string tls: diff --git a/deploy/crd.yaml b/deploy/crd.yaml index 59f6b1a17..a229ed219 100644 --- a/deploy/crd.yaml +++ b/deploy/crd.yaml @@ -9466,8 +9466,6 @@ spec: type: object secretsName: type: string - sslInternalSecretName: - type: string sslSecretName: type: string tls: diff --git a/deploy/cw-bundle.yaml b/deploy/cw-bundle.yaml index 88502a0c3..d83d41d18 100644 --- a/deploy/cw-bundle.yaml +++ b/deploy/cw-bundle.yaml @@ -9466,8 +9466,6 @@ spec: type: object secretsName: type: string - sslInternalSecretName: - type: string sslSecretName: type: string tls: From a111a9c2e2ca16e35c0b581201910861163c6fa1 Mon Sep 17 00:00:00 2001 From: Andrii Dema Date: Mon, 12 Aug 2024 13:15:56 +0300 Subject: [PATCH 2/2] K8SPS-372: fix bootstrap for cluster with 2 mysql pods (#722) https://perconadev.atlassian.net/browse/K8SPS-372 Co-authored-by: Viacheslav Sarzhan --- cmd/bootstrap/async_replication.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/cmd/bootstrap/async_replication.go b/cmd/bootstrap/async_replication.go index 4da4426d3..c0b4fc400 100644 --- a/cmd/bootstrap/async_replication.go +++ b/cmd/bootstrap/async_replication.go @@ -37,18 +37,18 @@ func bootstrapAsyncReplication(ctx context.Context) error { } log.Printf("Peers: %v", sets.List(peers)) - primary, replicas, err := getTopology(ctx, peers) - if err != nil { - return errors.Wrap(err, "select donor") - } - log.Printf("Primary: %s Replicas: %v", primary, replicas) - fqdn, err := getFQDN(mysqlSvc) if err != nil { return errors.Wrap(err, "get FQDN") } log.Printf("FQDN: %s", fqdn) + primary, replicas, err := getTopology(ctx, fqdn, peers) + if err != nil { + return errors.Wrap(err, "select donor") + } + log.Printf("Primary: %s Replicas: %v", primary, replicas) + podHostname, err := os.Hostname() if err != nil { return errors.Wrap(err, "get hostname") @@ -189,7 +189,7 @@ func bootstrapAsyncReplication(ctx context.Context) error { return nil } -func getTopology(ctx context.Context, peers sets.Set[string]) (string, []string, error) { +func getTopology(ctx context.Context, fqdn string, peers sets.Set[string]) (string, []string, error) { replicas := sets.New[string]() primary := "" @@ -227,7 +227,15 @@ func getTopology(ctx context.Context, peers sets.Set[string]) (string, []string, if primary == "" && peers.Len() == 1 { primary = sets.List(peers)[0] } else if primary == "" { - primary = sets.List(replicas)[0] + for _, r := range sets.List(replicas) { + // We should set primary to the first replica, which is not the bootstrapped pod. + // The bootstrapped pod can't be a primary. + // Even if it was a primary before, orchestrator will promote another replica "as result of DeadMaster". + if r != fqdn { + primary = r + break + } + } } if replicas.Len() > 0 {