Skip to content

Commit

Permalink
fix(pg) remove pg status check
Browse files Browse the repository at this point in the history
 remove pg status check

fix #474

Signed-off-by: zhuhuijun <zhuhuijunzhj@gmail.com>
  • Loading branch information
Ghostbaby committed Mar 5, 2021
1 parent bc6508c commit 6e75341
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions pkg/cluster/controllers/database/readiness.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const (
ClairSecretName = "clair"
NotaryServerSecretName = "notary-server"
NotarySignerSecretName = "notary-signer"

PsqlRunningStatus = "Running"
)

// Readiness reconcile will check postgre sql cluster if that has available.
Expand All @@ -55,31 +57,35 @@ func (p *PostgreSQLController) Readiness(ctx context.Context) (*lcm.CRStatus, er
return nil, err
}

properties := &lcm.Properties{}
crStatus := lcm.New(goharborv1alpha2.DatabaseReady).WithProperties(*properties)

var pg api.Postgresql
if err := runtime.DefaultUnstructuredConverter.
FromUnstructured(p.ActualCR.UnstructuredContent(), &pg); err != nil {
return nil, err
}

if pg.Status.PostgresClusterStatus != "Running" {
return nil, errors.New("database is not ready")
if pg.Status.PostgresClusterStatus != PsqlRunningStatus {
crStatus.WithStatus(corev1.ConditionFalse).
WithReason("database is not ready").
WithMessage(fmt.Sprintf("psql is %s", pg.Status.PostgresClusterStatus))

return crStatus, nil
}

p.Log.Info("Database already ready.",
p.Log.Info("database is ready.",
"namespace", p.HarborCluster.Namespace,
"name", p.HarborCluster.Name)

properties := &lcm.Properties{}

if err := p.DeployComponentSecret(conn, getDatabasePasswordRefName(name)); err != nil {
return nil, err
}

addProperties(name, conn, properties)

crStatus := lcm.New(goharborv1alpha2.DatabaseReady).
crStatus = lcm.New(goharborv1alpha2.DatabaseReady).
WithStatus(corev1.ConditionTrue).
WithReason("database already ready").
WithReason("database is ready").
WithMessage("harbor component database secrets are already create.").
WithProperties(*properties)

Expand Down

0 comments on commit 6e75341

Please sign in to comment.