Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVEREST-1814 add creating state #653

Open
wants to merge 1 commit into
base: EVEREST-1711-ui-remove-final-confirmation-step-from-the-wizard
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions api/v1alpha1/databasecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var (
const (
// AppStateUnknown is an unknown state.
AppStateUnknown AppState = "unknown"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we remove this since it is not used anywhere now?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in addition - is AppStateNew used somehow? and shall it be replaced with AppStateCreating as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way we map statuses now is everestv1alpha1.AppState(upstream.Status.State) which means we still need both

AppStateUnknown AppState = "unknown"
AppStateNew AppState = ""

because pxc has "unknown", psmdb has "", pg does not have any empty status.

As an alternative we could remove the statuses^ and have a switch mapping in each provider separately. I thought it's not really needed right now because the other statuses are mapping 1:1. Do you think it would be better to have the mapping for each upstream operator? I agree it's a bit confusing to have the statuses that are used only internally, but not sure which option would be better here.

// AppStateCreating is used when the db did not start to initialize yet.
AppStateCreating AppState = "creating"
// AppStateInit is a initializing state.
AppStateInit AppState = "initializing"
// AppStatePaused is a paused state.
Expand Down Expand Up @@ -101,6 +103,18 @@ const (
EngineSizeLarge EngineSize = "large"
)

// WithCreatingState transforms empty and unknown states to a single AppStateCreating.
// The upstream operators have the different statuses when a cluster is being created -
// pxc - "unknown", psmdb - "", pg does not have any empty status.
// Everest maps the DB status 1:1, and there is no point so far to create a separate mapping
// for each upstream operator separately only because we want to unify AppStateCreating.
func (s AppState) WithCreatingState() AppState {
if s == AppStateUnknown || s == AppStateNew {
return AppStateCreating
}
return s
}

// Applier provides methods for specifying how to apply a DatabaseCluster CR
// onto the CR(s) provided by the underlying DB operators (e.g. PerconaXtraDBCluster, PerconaServerMongoDB, PerconaPGCluster, etc.)
//
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/providers/pg/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (p *Provider) Status(ctx context.Context) (everestv1alpha1.DatabaseClusterS
pg := p.PerconaPGCluster

status := p.DB.Status
status.Status = everestv1alpha1.AppState(pg.Status.State)
status.Status = everestv1alpha1.AppState(pg.Status.State).WithCreatingState()
status.Hostname = pg.Status.Host
status.Ready = pg.Status.Postgres.Ready + pg.Status.PGBouncer.Ready
status.Size = pg.Status.Postgres.Size + pg.Status.PGBouncer.Size
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/providers/psmdb/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (p *Provider) Status(ctx context.Context) (everestv1alpha1.DatabaseClusterS
psmdb := p.PerconaServerMongoDB

activeStorage := getActiveStorage(psmdb)
status.Status = everestv1alpha1.AppState(psmdb.Status.State)
status.Status = everestv1alpha1.AppState(psmdb.Status.State).WithCreatingState()
status.Hostname = psmdb.Status.Host
status.Ready = psmdb.Status.Ready
status.Size = psmdb.Status.Size
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/providers/pxc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (p *Provider) Status(ctx context.Context) (everestv1alpha1.DatabaseClusterS
status := p.DB.Status
pxc := p.PerconaXtraDBCluster

status.Status = everestv1alpha1.AppState(p.PerconaXtraDBCluster.Status.Status)
status.Status = everestv1alpha1.AppState(p.PerconaXtraDBCluster.Status.Status).WithCreatingState()
status.Hostname = pxc.Status.Host
status.Ready = pxc.Status.Ready
status.Size = pxc.Status.Size
Expand Down