Skip to content

add migraiton sql for skip_audit_log_database#22487

Merged
wy65701436 merged 1 commit into
goharbor:mainfrom
wy65701436:set-audit-log
Oct 23, 2025
Merged

add migraiton sql for skip_audit_log_database#22487
wy65701436 merged 1 commit into
goharbor:mainfrom
wy65701436:set-audit-log

Conversation

@wy65701436

Copy link
Copy Markdown
Contributor

give the value of skip_audit_log_database bases on the real usage.

  1. If audit logs exist in the system (either in audit_log or audit_log_ext tables), set skip_audit_log_database to false
  2. If no audit logs exist but the tables show evidence of previous usage set skip_audit_log_database to false

Thank you for contributing to Harbor!

Comprehensive Summary of your change

Issue being fixed

Fixes #(issue)

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

@wy65701436
wy65701436 requested a review from a team as a code owner October 22, 2025 11:21
@wy65701436 wy65701436 added the release-note/update Update or Fix label Oct 22, 2025
@codecov

codecov Bot commented Oct 22, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.84%. Comparing base (c8c11b4) to head (b5b52c9).
⚠️ Report is 578 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main   #22487       +/-   ##
===========================================
+ Coverage   45.36%   65.84%   +20.47%     
===========================================
  Files         244     1073      +829     
  Lines       13333   116105   +102772     
  Branches     2719     2931      +212     
===========================================
+ Hits         6049    76450    +70401     
- Misses       6983    35414    +28431     
- Partials      301     4241     +3940     
Flag Coverage Δ
unittests 65.84% <ø> (+20.47%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 987 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Vad1mo

Vad1mo commented Oct 22, 2025

Copy link
Copy Markdown
Member

Why is this magic happening in the DB schema migration script and not simply via config flags?

When do you think this will be set? All existing users have audit logs.
Only new deployments have no auditlogs

@MinerYang MinerYang 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.

lgtm

Comment thread make/migrations/postgresql/0180_2.15.0_schema.up.sql
@wy65701436

Copy link
Copy Markdown
Contributor Author

Why is this magic happening in the DB schema migration script and not simply via config flags?

When do you think this will be set? All existing users have audit logs. Only new deployments have no auditlogs

Why is this magic happening in the DB schema migration script and not simply via config flags?

When do you think this will be set? All existing users have audit logs. Only new deployments have no auditlogs

This PR sets a value for skip_audit_log_database to handle the scenario where the database is used as the audit log storage.

Previously, we introduced a new env to control whether to skip using the database for audit logs. However, this change could break existing setups when upgrading from older Harbor versions that already use the database.

This PR is the second step in that change — ensuring the new environment variable only takes effect for fresh installations. During upgrades, if the existing setup uses the database for audit logs, give a value to index it and then behavior will be preserved.

give the value of skip_audit_log_database bases on the real usage.

1. If audit logs exist in the system (either in audit_log or audit_log_ext tables),
   set skip_audit_log_database to false
2. If no audit logs exist but the tables show evidence of previous usage
   set skip_audit_log_database to false

Signed-off-by: wang yan <[email protected]>
@wy65701436
wy65701436 enabled auto-merge (squash) October 23, 2025 06:42
@wy65701436
wy65701436 merged commit c878bbf into goharbor:main Oct 23, 2025
12 checks passed
OrlinVasilev pushed a commit to OrlinVasilev/harbor that referenced this pull request Oct 29, 2025
give the value of skip_audit_log_database bases on the real usage.

1. If audit logs exist in the system (either in audit_log or audit_log_ext tables),
   set skip_audit_log_database to false
2. If no audit logs exist but the tables show evidence of previous usage
   set skip_audit_log_database to false

Signed-off-by: wang yan <[email protected]>
Co-authored-by: wang yan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/update Update or Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants