Skip to content

Commit

Permalink
Add TransferLeadershipInterval and ```TransferLeadershipTimeout…
Browse files Browse the repository at this point in the history
…``` for Postgres (#1001)

Signed-off-by: Rakibul-Hossain <[email protected]>
  • Loading branch information
Rakibul Hossain authored Dec 6, 2022
1 parent b8f88e7 commit d498e8e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
12 changes: 12 additions & 0 deletions apis/kubedb/v1alpha2/openapi_generated.go

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

6 changes: 6 additions & 0 deletions apis/kubedb/v1alpha2/postgres_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ func (p *Postgres) SetDefaults(postgresVersion *catalog.PostgresVersion, topolog
MaximumLagBeforeFailover: 64 * 1024 * 1024,
}
}
if p.Spec.LeaderElection.TransferLeadershipInterval == nil {
p.Spec.LeaderElection.TransferLeadershipInterval = &metav1.Duration{Duration: 1 * time.Second}
}
if p.Spec.LeaderElection.TransferLeadershipTimeout == nil {
p.Spec.LeaderElection.TransferLeadershipTimeout = &metav1.Duration{Duration: 120 * time.Second}
}
apis.SetDefaultResourceLimits(&p.Spec.Coordinator.Resources, CoordinatorDefaultResources)

if p.Spec.PodTemplate.Spec.ServiceAccountName == "" {
Expand Down
12 changes: 12 additions & 0 deletions apis/kubedb/v1alpha2/postgres_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ type PostgreLeaderElectionConfig struct {
// +kubebuilder:default=1
// +optional
HeartbeatTick int32 `json:"heartbeatTick,omitempty"`

// TransferLeadershipInterval retry interval for transfer leadership
// to the healthiest node
// +kubebuilder:default="1000ms"
// +optional
TransferLeadershipInterval *metav1.Duration `json:"transferLeadershipInterval,omitempty"`

// TransferLeadershipTimeout retry timeout for transfer leadership
// to the healthiest node
// +kubebuilder:default="120s"
// +optional
TransferLeadershipTimeout *metav1.Duration `json:"transferLeadershipTimeout,omitempty"`
}

// +kubebuilder:validation:Enum=server;archiver;metrics-exporter
Expand Down
12 changes: 11 additions & 1 deletion apis/kubedb/v1alpha2/zz_generated.deepcopy.go

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

6 changes: 6 additions & 0 deletions crds/kubedb.com_postgreses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,12 @@ spec:
retryPeriodSeconds:
format: int32
type: integer
transferLeadershipInterval:
default: 1000ms
type: string
transferLeadershipTimeout:
default: 120s
type: string
type: object
monitor:
properties:
Expand Down
8 changes: 8 additions & 0 deletions openapi/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -32334,6 +32334,14 @@
"description": "RetryPeriod is the duration in second the LeaderElector clients should wait between tries of actions. Normally, LeaseDuration / 3. Default 2 Deprecated",
"type": "integer",
"format": "int32"
},
"transferLeadershipInterval": {
"description": "TransferLeadershipInterval retry interval for transfer leadership to the healthiest node",
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Duration"
},
"transferLeadershipTimeout": {
"description": "TransferLeadershipTimeout retry timeout for transfer leadership to the healthiest node",
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Duration"
}
}
},
Expand Down

0 comments on commit d498e8e

Please sign in to comment.