Skip to content

Commit

Permalink
Merge branch 'main' into dev/K8SPS-348
Browse files Browse the repository at this point in the history
  • Loading branch information
hors authored Aug 12, 2024
2 parents 9bfa4a1 + a111a9c commit 81b76b5
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 34 deletions.
35 changes: 17 additions & 18 deletions api/v1alpha1/perconaservermysql_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,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 {
Expand Down
24 changes: 16 additions & 8 deletions cmd/bootstrap/async_replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 := ""

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions config/crd/bases/ps.percona.com_perconaservermysqls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7583,8 +7583,6 @@ spec:
type: object
secretsName:
type: string
sslInternalSecretName:
type: string
sslSecretName:
type: string
tls:
Expand Down
2 changes: 0 additions & 2 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9479,8 +9479,6 @@ spec:
type: object
secretsName:
type: string
sslInternalSecretName:
type: string
sslSecretName:
type: string
tls:
Expand Down
2 changes: 0 additions & 2 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9479,8 +9479,6 @@ spec:
type: object
secretsName:
type: string
sslInternalSecretName:
type: string
sslSecretName:
type: string
tls:
Expand Down
2 changes: 0 additions & 2 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9479,8 +9479,6 @@ spec:
type: object
secretsName:
type: string
sslInternalSecretName:
type: string
sslSecretName:
type: string
tls:
Expand Down

0 comments on commit 81b76b5

Please sign in to comment.