Skip to content

Commit

Permalink
feat: expose core db connection settings
Browse files Browse the repository at this point in the history
Allow to change core.spec.database.maxIdleConnections and
core.spec.database.maxOpenConnections in harborcluster.
  • Loading branch information
Eric Liu committed Jul 7, 2023
1 parent b600049 commit e97bb91
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apis/goharbor.io/v1beta1/harbor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,16 @@ type CoreComponentSpec struct {

// +kubebuilder:validation:Optional
Metrics *harbormetav1.MetricsSpec `json:"metrics,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default=50
MaxIdleConnections *int32 `json:"maxIdleConnections,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default=1000
MaxOpenConnections *int32 `json:"maxOpenConnections,omitempty"`
}

type JobServiceComponentSpec struct {
Expand Down
10 changes: 10 additions & 0 deletions apis/goharbor.io/v1beta1/zz_generated.deepcopy.go

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

2 changes: 2 additions & 0 deletions controllers/goharbor/harbor/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ func (r *Reconciler) GetCore(ctx context.Context, harbor *goharborv1.Harbor) (*g
CSRFKeyRef: csrfRef,
Database: goharborv1.CoreDatabaseSpec{
PostgresConnectionWithParameters: *storage,
MaxIdleConnections: harbor.Spec.Core.MaxIdleConnections,
MaxOpenConnections: harbor.Spec.Core.MaxOpenConnections,
EncryptionKeyRef: encryptionKeyRef,
},
ExternalEndpoint: harbor.Spec.ExternalURL,
Expand Down
6 changes: 6 additions & 0 deletions controllers/goharbor/harbor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ func setupValidHarbor(ctx context.Context, ns string) (Resource, client.ObjectKe
Scheme: "http",
Host: "the.dns",
}
var (
maxIdleConnections int32 = 50
maxOpenConnections int32 = 100
)

harbor := &goharborv1.Harbor{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -168,6 +172,8 @@ func setupValidHarbor(ctx context.Context, ns string) (Resource, client.ObjectKe
TokenIssuer: cmmeta.ObjectReference{
Name: tokenIssuerName,
},
MaxIdleConnections: &maxIdleConnections,
MaxOpenConnections: &maxOpenConnections,
},
Database: &goharborv1.HarborDatabaseSpec{
PostgresCredentials: database.PostgresCredentials,
Expand Down
20 changes: 20 additions & 0 deletions manifests/cluster/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9940,6 +9940,16 @@ spec:
type: object
x-kubernetes-map-type: atomic
type: array
maxIdleConnections:
default: 50
format: int32
minimum: 0
type: integer
maxOpenConnections:
default: 1000
format: int32
minimum: 0
type: integer
metrics:
properties:
enabled:
Expand Down Expand Up @@ -15801,6 +15811,16 @@ spec:
type: object
x-kubernetes-map-type: atomic
type: array
maxIdleConnections:
default: 50
format: int32
minimum: 0
type: integer
maxOpenConnections:
default: 1000
format: int32
minimum: 0
type: integer
metrics:
properties:
enabled:
Expand Down
20 changes: 20 additions & 0 deletions manifests/harbor/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9940,6 +9940,16 @@ spec:
type: object
x-kubernetes-map-type: atomic
type: array
maxIdleConnections:
default: 50
format: int32
minimum: 0
type: integer
maxOpenConnections:
default: 1000
format: int32
minimum: 0
type: integer
metrics:
properties:
enabled:
Expand Down Expand Up @@ -15801,6 +15811,16 @@ spec:
type: object
x-kubernetes-map-type: atomic
type: array
maxIdleConnections:
default: 50
format: int32
minimum: 0
type: integer
maxOpenConnections:
default: 1000
format: int32
minimum: 0
type: integer
metrics:
properties:
enabled:
Expand Down

0 comments on commit e97bb91

Please sign in to comment.