Skip to content

Commit

Permalink
EVEREST-1391 DB status details (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
oksana-grishchenko authored Aug 29, 2024
1 parent f76543d commit 671ead7
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha1/databasecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ type DatabaseClusterStatus struct {
// If set, the CR needs to be updated to this version before upgrading the operator.
// If unset, the CR is already at the recommended version.
RecommendedCRVersion *string `json:"recommendedCRVersion,omitempty"`
// Details provides full status of the upstream cluster as a plain text.
Details string `json:"details,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ metadata:
}
]
capabilities: Basic Install
createdAt: "2024-08-02T09:39:54Z"
createdAt: "2024-08-29T09:22:49Z"
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
name: everest-operator.v0.0.0
Expand Down
4 changes: 4 additions & 0 deletions bundle/manifests/everest.percona.com_databaseclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ spec:
description: CRVersion is the observed version of the CR used with
the underlying operator.
type: string
details:
description: Details provides full status of the upstream cluster
as a plain text.
type: string
hostname:
description: Hostname is the hostname where the cluster can be reached
type: string
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/everest.percona.com_databaseclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ spec:
description: CRVersion is the observed version of the CR used with
the underlying operator.
type: string
details:
description: Details provides full status of the upstream cluster
as a plain text.
type: string
hostname:
description: Hostname is the hostname where the cluster can be reached
type: string
Expand Down
6 changes: 6 additions & 0 deletions controllers/common/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/AlekSi/pointer"
crunchyv1beta1 "github.com/percona/percona-postgresql-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
psmdbv1 "github.com/percona/percona-server-mongodb-operator/pkg/apis/psmdb/v1"
"gopkg.in/yaml.v2"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
Expand Down Expand Up @@ -716,3 +717,8 @@ func DefaultAffinitySettings() *corev1.Affinity {
},
}
}

func StatusAsPlainTextOrEmptyString(status interface{}) string {
result, _ := yaml.Marshal(status)
return string(result)
}
1 change: 1 addition & 0 deletions controllers/providers/pg/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func (p *Provider) Status(ctx context.Context) (everestv1alpha1.DatabaseClusterS
status.Size = pg.Status.Postgres.Size + pg.Status.PGBouncer.Size
status.Port = 5432
status.CRVersion = pg.Spec.CRVersion
status.Details = common.StatusAsPlainTextOrEmptyString(pg.Status)

// If a restore is running for this database, set the database status to restoring
if restoring, err := common.IsDatabaseClusterRestoreRunning(ctx, c, p.DB.GetName(), p.DB.GetNamespace()); err != nil {
Expand Down
1 change: 1 addition & 0 deletions controllers/providers/psmdb/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func (p *Provider) Status(ctx context.Context) (everestv1alpha1.DatabaseClusterS
status.Port = 27017
status.ActiveStorage = activeStorage
status.CRVersion = psmdb.Spec.CRVersion
status.Details = common.StatusAsPlainTextOrEmptyString(psmdb.Status)

// If a restore is running for this database, set the database status to restoring.
if restoring, err := common.IsDatabaseClusterRestoreRunning(ctx, p.C, p.DB.GetName(), p.DB.GetNamespace()); err != nil {
Expand Down
1 change: 1 addition & 0 deletions controllers/providers/pxc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func (p *Provider) Status(ctx context.Context) (everestv1alpha1.DatabaseClusterS
status.Message = strings.Join(pxc.Status.Messages, ";")
status.Port = 3306
status.CRVersion = pxc.Spec.CRVersion
status.Details = common.StatusAsPlainTextOrEmptyString(pxc.Status)

// If a restore is running for this database, set the database status to restoring.
if restoring, err := common.IsDatabaseClusterRestoreRunning(ctx, p.C, p.DB.GetName(), p.DB.GetNamespace()); err != nil {
Expand Down
3 changes: 3 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,9 @@ spec:
crVersion:
description: CRVersion is the observed version of the CR used with the underlying operator.
type: string
details:
description: Details provides full status of the upstream cluster as a plain text.
type: string
hostname:
description: Hostname is the hostname where the cluster can be reached
type: string
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/percona/percona-xtradb-cluster-operator v1.15.0
github.com/stretchr/testify v1.9.0
golang.org/x/mod v0.20.0
gopkg.in/yaml.v2 v2.4.0
gotest.tools v2.2.0+incompatible
k8s.io/api v0.30.3
k8s.io/apimachinery v0.30.3
Expand Down Expand Up @@ -121,7 +122,6 @@ require (
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.30.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
Expand Down

0 comments on commit 671ead7

Please sign in to comment.