Skip to content

Commit

Permalink
Add reconfigure ops-request
Browse files Browse the repository at this point in the history
Signed-off-by: MobarakHsn <[email protected]>
  • Loading branch information
MobarakHsn committed May 31, 2024
1 parent 18fbdb3 commit 063e5bd
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 40 deletions.
1 change: 1 addition & 0 deletions apis/kubedb/v1alpha2/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ const (
PgpoolPrimaryServicePortName = "primary"
PgpoolDatabasePortName = "db"
PgpoolPcpServicePortName = "pcp"
PgpoolCustomConfigFile = "pgpool.conf"
// ========================================== ZooKeeper Constants =================================================//

KubeDBZooKeeperRoleName = "kubedb:zookeeper-version-reader"
Expand Down
8 changes: 4 additions & 4 deletions apis/kubedb/v1alpha2/pgpool_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (p *Pgpool) ValidateCreateOrUpdate() field.ErrorList {
))
}

if p.Spec.ConfigSecret != nil && (p.Spec.InitConfiguration != nil || p.Spec.InitConfiguration.PgpoolConfig != nil) {
if p.Spec.ConfigSecret != nil && (p.Spec.InitConfiguration != nil && p.Spec.InitConfiguration.PgpoolConfig != nil) {
errorList = append(errorList, field.Invalid(field.NewPath("spec").Child("configSecret"),
p.Name,
"use either `spec.configSecret` or `spec.initConfig`"))
Expand All @@ -134,19 +134,19 @@ func (p *Pgpool) ValidateCreateOrUpdate() field.ErrorList {
secret := core.Secret{}
err := DefaultClient.Get(context.TODO(), types.NamespacedName{
Name: p.Spec.ConfigSecret.Name,
Namespace: p.Spec.PostgresRef.Namespace,
Namespace: p.Namespace,
}, &secret)
if err != nil {
errorList = append(errorList, field.Invalid(field.NewPath("spec").Child("configSecret"),
p.Name,
err.Error(),
))
}
_, ok := secret.Data["pgpool.conf"]
_, ok := secret.Data[PgpoolCustomConfigFile]
if !ok {
errorList = append(errorList, field.Invalid(field.NewPath("spec").Child("configSecret"),
p.Name,
"`pgpool.conf` is missing",
fmt.Sprintf("`%v` is missing", PgpoolCustomConfigFile),
))
}
}
Expand Down
61 changes: 48 additions & 13 deletions apis/ops/v1alpha1/openapi_generated.go

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

16 changes: 10 additions & 6 deletions apis/ops/v1alpha1/pgpool_ops_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ type PgpoolOpsRequestSpec struct {
Type PgpoolOpsRequestType `json:"type"`
// Specifies information necessary for vertical scaling
VerticalScaling *PgpoolVerticalScalingSpec `json:"verticalScaling,omitempty"`
// Specifies information necessary for custom configuration of Pgpool
Configuration *PgpoolCustomConfigurationSpec `json:"configuration,omitempty"`
// Specifies information necessary for restarting database
Restart *RestartSpec `json:"restart,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.
Expand All @@ -65,20 +67,22 @@ type PgpoolOpsRequestSpec struct {
Apply ApplyOption `json:"apply,omitempty"`
}

// +kubebuilder:validation:Enum=VerticalScaling;VolumeExpansion;Restart
// ENUM(VerticalScaling, Restart)
// +kubebuilder:validation:Enum=VerticalScaling;Reconfigure;Restart
// ENUM(VerticalScaling, Restart, Reconfigure)
type PgpoolOpsRequestType string

// PgpoolReplicaReadinessCriteria is the criteria for checking readiness of a Pgpool pod
// after updating, horizontal scaling etc.
type PgpoolReplicaReadinessCriteria struct{}

// PgpoolVerticalScalingSpec contains the vertical scaling information of a Pgpool cluster
type PgpoolVerticalScalingSpec struct {
// Resource spec for nodes
Node *PodResources `json:"node,omitempty"`
}

type PgpoolCustomConfigurationSpec struct {
ConfigSecret *core.LocalObjectReference `json:"configSecret,omitempty"`
ApplyConfig map[string]string `json:"applyConfig,omitempty"`
RemoveCustomConfig bool `json:"removeCustomConfig,omitempty"`
}

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

// PgpoolOpsRequestList is a list of PgpoolOpsRequests
Expand Down
5 changes: 5 additions & 0 deletions apis/ops/v1alpha1/pgpool_ops_types_enum.go

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

49 changes: 33 additions & 16 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.

17 changes: 16 additions & 1 deletion crds/ops.kubedb.com_pgpoolopsrequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ spec:
- IfReady
- Always
type: string
configuration:
properties:
applyConfig:
additionalProperties:
type: string
type: object
configSecret:
properties:
name:
type: string
type: object
x-kubernetes-map-type: atomic
removeCustomConfig:
type: boolean
type: object
databaseRef:
properties:
name:
Expand All @@ -61,7 +76,7 @@ spec:
type:
enum:
- VerticalScaling
- VolumeExpansion
- Reconfigure
- Restart
type: string
verticalScaling:
Expand Down

0 comments on commit 063e5bd

Please sign in to comment.