Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose core db connection settings #1056

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this set here and not in HarborDatabaseSpec?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is passed to Core and eventually Harbor core deployment to configure the max connections between core pods and the db, ultimately goes to https://sourcegraph.com/github.com/goharbor/harbor@cbb211e6702517fddcc8b9a7341e8a3479211ca7/-/blob/src/common/dao/pgsql.go?L99.

This is different from the configuring DB's server-side max connections.

Therefore I think this should be in harbor_types instead of in HarborDatabaseSpec. Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood after explanation on Slack as well - thank you!


// +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
Loading