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.

Signed-off-by: Eric Liu <shuaiyi@google.com>
  • Loading branch information
Eric Liu authored and LiuShuaiyi committed Jul 31, 2023
1 parent 8c7a4a6 commit e161c71
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 (

Check failure on line 140 in controllers/goharbor/harbor_test.go

View workflow job for this annotation

GitHub Actions / golang: lint

declarations should never be cuddled (wsl)
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 e161c71

Please sign in to comment.