Draft
fix: Honour Explicit PostgreSQL min_conns=0 with Presence Flag#586
Conversation
Co-authored-by: Vad1mo <1492007+Vad1mo@users.noreply.github.com>
Co-authored-by: Vad1mo <1492007+Vad1mo@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add presence flag for PostgreSQL min_conns configuration
fix: Honour Explicit PostgreSQL min_conns=0 with Presence Flag
Aug 7, 2026
5 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Adds presence tracking so PostgreSQL min_conns=0 is honored while unset values retain the default of 2.
Changes:
- Adds and propagates
MinConnsSet. - Validates negative values and propagates errors.
- Adds unit tests for unset, zero, and negative values.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/common/models/database.go |
Adds the presence flag. |
src/lib/dbpool/pool.go |
Applies presence-aware pool configuration. |
src/lib/dbpool/pool_test.go |
Tests pool semantics and validation. |
src/pkg/config/manager.go |
Marks manager-provided values as set. |
src/pkg/config/manager_test.go |
Tests manager presence tracking. |
src/lib/config/systemconfig.go |
Marks system configuration values as set. |
src/cmd/exporter/main.go |
Detects exporter configuration presence. |
src/cmd/exporter/main_test.go |
Tests exporter unset and explicit-zero paths. |
src/go.mod |
Reclassifies OpenAPI dependencies as indirect. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+106
to
107
| if !cfg.MinConnsSet { | ||
| poolCfg.MinConns = DefaultMinConns |
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
|
Preview images for this PR are available in
Verify a preview image: Verify SBOM attestation: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow Harbor to distinguish unset
min_connsfrom explicitly configured0without convertingMinConnsto a pointer type. This keeps default fallback behavior (2) for unset values while honoring explicit0and rejecting explicit negatives.Model presence tracking
MinConnsSet bool \json:"-"`tomodels.PostGreSQL` to represent configuration presence independently from numeric value.Pool application semantics
dbpool.applyPoolConfignow applies:MinConnsSet == false→DefaultMinConns(2)MinConnsSet == true+MinConns >= 0→ use configured value (including0)MinConnsSet == true+MinConns < 0→ return validation errordbpool.Newnow propagates this startup/config error.Config ingestion paths
pkg/config/manager.go,lib/config/systemconfig.go) now setMinConnsSet: truewhen materializing DB config.viper.IsSet("database.min_conns")so explicitHARBOR_DATABASE_MIN_CONNS=0is not treated as unset.Related Issues
Type of Change
fix:)feat:)feat!:/fix!:)docs:)refactor:)ci:/build:)upstream:)chore:)test:)Release Notes
PostgreSQL
min_connsnow correctly honors explicit0(disable prewarmed connections) while preserving Harbor’s fallback default (2) when unset. Explicit negative values now fail fast with a clear configuration error.Testing
Checklist
git commit -s)