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

Add PostgresOpsRequest ReconnectStandby, ForceFailover, SetRaftKeyPair #1404

Merged
merged 1 commit into from
Feb 18, 2025
Merged
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
36 changes: 36 additions & 0 deletions apis/ops/v1alpha1/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,42 @@ const (

RestartPrimary = "RestartPrimary"
RestartSecondary = "RestartSecondary"

StartRunScript = "StartRunScriptWithRestart"
KillRunScript = "KillRunScript"
StickyLeader = "STICKYLEADER" // We want a id(sticky id) to be always leader in raft
UpdateDataDirectory = "UpdateDataDirectory"
PausePgCoordinatorBeforeUpgrade = "PausePgCoordinatorBeforeUpdate"
RunningLeaderSticky = "RunningLeaderSticky"
EnsureStickyId = "EnsureStickyId"
SetPrimaryPodNameInStatus = "SetPrimaryPodNameInStatus"
NonTransferableResumeAfterUpgrade = "NonTransferableResumeAfterUpgrade"
PausePgCoordinatorBeforeCustomRestart = "PausePgCoordinatorBeforeCustomRestart"
NonTransferableResumeAfterCustomRestart = "NonTransferableResumeAfterCustomRestart"
ReadyPrimaryCheck = "ReadyPrimaryCheck"
PrimaryPodName = "PrimaryPodName"
OpsRequestProgressing = "OpsRequestProgressing"
SetRaftKeyOpsRequestProgressing = "SetRaftKeyOpsRequestProgressing"
UnsetRaftKeyOpsRequestProgressing = "UnsetRaftKeyOpsRequestProgressing"
NotReadyReplicas = "NotReadyReplicas"
RestartNotReadyStandby = "RestartNotReadyStandby"
StandbyReadyCheck = "StandbyReadyCheck"
PrimaryRunningCheck = "PrimaryRunningCheck"
StopPostgresServer = "StopPostgresServer"
SetupRecoverySettings = "SetupRecoverySettings"
RunPostgresBaseBackup = "RunPostgresBaseBackup"
StartPostgresRecovery = "StartPostgresRecovery"
RestartNotReadyStandbyAfterBaseBackup = "RestartNotReadyStandbyAfterBaseBackup"
StandbyReadyCheckAfterBaseBackup = "StandbyReadyCheckAfterBaseBackup"
ReconnectStandbyWithRestart = "ReconnectStandbyWithRestart"
ReconnectStandbyWithBaseBackup = "ReconnectStandbyWithBaseBackup"
UpdateRaftKVStore = "UpdateRaftKVStore"
CreateFailOverFile = "CreateFailOverFile"
TransitionCandidateToLeader = "TransitionCandidateToLeader"
ForceFailOverFileName = "force-failover-with-lsn"
// need reveiw about this two
StringFalse = "false"
StringTrue = "true"
)

// Redis Constants
Expand Down
96 changes: 95 additions & 1 deletion apis/ops/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 25 additions & 3 deletions apis/ops/v1alpha1/postgres_ops_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,21 @@ type PostgresOpsRequestSpec struct {
Authentication *AuthSpec `json:"authentication,omitempty"`
// Specifies information necessary for restarting database
Restart *RestartSpec `json:"restart,omitempty"`
// Try to reconnect standby's with primary
ReconnectStandby *PostgresReconnectStandby `json:"reconnectStandby,omitempty"`
// Forcefully do a failover to the given candidate
ForceFailOver *PostgresForceFailOver `json:"forceFailOver,omitempty"`
// Set given key pairs to raft storage
SetRaftKeyPair *PostgresSetRaftKeyPair `json:"setRaftKeyPair,omitempty"`
// Timeout for each step of the ops request in second. If a step doesn't finish within the specified timeout, the ops request will result in failure.
Timeout *metav1.Duration `json:"timeout,omitempty"`
// ApplyOption is to control the execution of OpsRequest depending on the database state.
// +kubebuilder:default="IfReady"
Apply ApplyOption `json:"apply,omitempty"`
}

// +kubebuilder:validation:Enum=Upgrade;UpdateVersion;HorizontalScaling;VerticalScaling;VolumeExpansion;Restart;Reconfigure;ReconfigureTLS;RotateAuth
// ENUM(UpdateVersion, HorizontalScaling, VerticalScaling, VolumeExpansion, Restart, Reconfigure, ReconfigureTLS, RotateAuth)
// +kubebuilder:validation:Enum=Upgrade;UpdateVersion;HorizontalScaling;VerticalScaling;VolumeExpansion;Restart;Reconfigure;ReconfigureTLS;RotateAuth;ReconnectStandby;ForceFailOver;SetRaftKeyPair
// ENUM(UpdateVersion, HorizontalScaling, VerticalScaling, VolumeExpansion, Restart, Reconfigure, ReconfigureTLS, RotateAuth, ReconnectStandby, ForceFailOver, SetRaftKeyPair)
type PostgresOpsRequestType string

type PostgresUpdateVersionSpec struct {
Expand All @@ -116,11 +122,13 @@ const (
WarmPostgresStandbyMode PostgresStandbyMode = "Warm"
)

type PostgresPrimaryCandidate string

// HorizontalScaling is the spec for Postgres horizontal scaling
type PostgresHorizontalScalingSpec struct {
Replicas *int32 `json:"replicas,omitempty"`
// Standby mode
// +kubebuilder:default="Warm"
// +kubebuilder:default="Hot"
StandbyMode *PostgresStandbyMode `json:"standbyMode,omitempty"`

// Streaming mode
Expand Down Expand Up @@ -156,6 +164,20 @@ type PostgresCustomConfiguration struct {
Remove bool `json:"remove,omitempty"`
}

type PostgresReconnectStandby struct {
// ReadyTimeOut is the time to wait for standby`s to become ready
// +optional
ReadyTimeOut *metav1.Duration `json:"readyTimeOut,omitempty"`
}

type PostgresForceFailOver struct {
Candidates []PostgresPrimaryCandidate `json:"candidates,omitempty"`
}

type PostgresSetRaftKeyPair struct {
KeyPair map[string]string `json:"keyPair,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// PostgresOpsRequestList is a list of PostgresOpsRequests
Expand Down
15 changes: 15 additions & 0 deletions apis/ops/v1alpha1/postgres_ops_types_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions apis/ops/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading