Skip to content

fix: Honour Explicit PostgreSQL min_conns=0 with Presence Flag - #586

Draft
Vad1mo with Copilot wants to merge 3 commits into
mainfrom
copilot/implement-min-conns-flag
Draft

fix: Honour Explicit PostgreSQL min_conns=0 with Presence Flag#586
Vad1mo with Copilot wants to merge 3 commits into
mainfrom
copilot/implement-min-conns-flag

Conversation

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Allow Harbor to distinguish unset min_conns from explicitly configured 0 without converting MinConns to a pointer type. This keeps default fallback behavior (2) for unset values while honoring explicit 0 and rejecting explicit negatives.

  • Model presence tracking

    • Added MinConnsSet bool \json:"-"`tomodels.PostGreSQL` to represent configuration presence independently from numeric value.
  • Pool application semantics

    • dbpool.applyPoolConfig now applies:
      • MinConnsSet == falseDefaultMinConns (2)
      • MinConnsSet == true + MinConns >= 0 → use configured value (including 0)
      • MinConnsSet == true + MinConns < 0 → return validation error
    • dbpool.New now propagates this startup/config error.
  • Config ingestion paths

    • Standard Harbor config paths (pkg/config/manager.go, lib/config/systemconfig.go) now set MinConnsSet: true when materializing DB config.
    • Exporter Viper path now uses viper.IsSet("database.min_conns") so explicit HARBOR_DATABASE_MIN_CONNS=0 is not treated as unset.
if !cfg.MinConnsSet {
	poolCfg.MinConns = DefaultMinConns
} else if cfg.MinConns < 0 {
	return fmt.Errorf("dbpool: invalid min_conns %d: must be greater than or equal to 0", cfg.MinConns)
} else {
	poolCfg.MinConns = cfg.MinConns
}

Related Issues

Type of Change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: / fix!:)
  • Documentation (docs:)
  • Refactoring (refactor:)
  • CI/CD or build changes (ci: / build:)
  • Upstream Harbor cherry-pick (upstream:)
  • Dependencies update (chore:)
  • Tests (test:)

Release Notes

PostgreSQL min_conns now correctly honors explicit 0 (disable prewarmed connections) while preserving Harbor’s fallback default (2) when unset. Explicit negative values now fail fast with a clear configuration error.

Testing

  • Unit tests added/updated
  • Manual testing performed

Checklist

  • PR title follows Conventional Commits format
  • Commits are signed off (git commit -s)
  • No new warnings introduced

@gitar-bot

gitar-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

Gitar is working

Gitar

Copilot AI and others added 2 commits August 7, 2026 13:54
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
Copilot AI requested a review from Vad1mo August 7, 2026 13:59
@Vad1mo
Vad1mo requested a balanced review from Copilot August 7, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 thread src/lib/dbpool/pool.go
Comment on lines +106 to 107
if !cfg.MinConnsSet {
poolCfg.MinConns = DefaultMinConns
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Preview images for this PR are available in 8gears.container-registry.com/8gcr-pr with tag pr-586.

  • 8gears.container-registry.com/8gcr-pr/harbor-core:pr-586
  • 8gears.container-registry.com/8gcr-pr/harbor-jobservice:pr-586
  • 8gears.container-registry.com/8gcr-pr/harbor-registryctl:pr-586
  • 8gears.container-registry.com/8gcr-pr/harbor-exporter:pr-586
  • 8gears.container-registry.com/8gcr-pr/harbor-portal:pr-586
  • 8gears.container-registry.com/8gcr-pr/harbor-registry:pr-586
  • 8gears.container-registry.com/8gcr-pr/trivy-adapter:pr-586

Verify a preview image:

cosign verify \
  --certificate-identity-regexp="https://github.com/container-registry/harbor-next/.github/workflows/pr-ci.yml@.*" \
  --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
  8gears.container-registry.com/8gcr-pr/harbor-core:pr-586

Verify SBOM attestation:

cosign verify-attestation \
  --certificate-identity-regexp="https://github.com/container-registry/harbor-next/.github/workflows/pr-ci.yml@.*" \
  --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
  --type spdxjson \
  8gears.container-registry.com/8gcr-pr/harbor-core:pr-586

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants