Skip to content

Commit

Permalink
feat: expose core db connection settings (#1056)
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.

Signed-off-by: Eric Liu <shuaiyi@google.com>
Co-authored-by: Eric Liu <shuaiyi@google.com>
  • Loading branch information
LiuShuaiyi and Eric Liu authored Aug 8, 2023
1 parent f06cd9e commit 4f460cb
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 @@ -138,6 +138,10 @@ func setupValidHarbor(ctx context.Context, ns string) (Resource, client.ObjectKe
Host: "the.dns",
}

var maxIdleConnections int32 = 50

var maxOpenConnections int32 = 100

harbor := &goharborv1.Harbor{
ObjectMeta: metav1.ObjectMeta{
Name: name,
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 @@ -10025,6 +10025,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 @@ -15986,6 +15996,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 @@ -10025,6 +10025,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 @@ -15986,6 +15996,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 4f460cb

Please sign in to comment.