Skip to content

postgres database finalizer#1750

Draft
limak9182 wants to merge 4 commits intofeature/database-controllersfrom
feature/postgres-database-finalizer
Draft

postgres database finalizer#1750
limak9182 wants to merge 4 commits intofeature/database-controllersfrom
feature/postgres-database-finalizer

Conversation

@limak9182
Copy link

Description

What does this PR have in it?

Key Changes

Highlight the updates in specific files

Testing and Verification

How did you test these changes? What automated tests are added?

Related Issues

Jira tickets, GitHub issues, Support tickets...

PR Checklist

  • Code changes adhere to the project's coding standards.
  • Relevant unit and integration tests are included.
  • Documentation has been updated accordingly.
  • All tests pass locally.
  • The PR description follows the project's guidelines.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

@limak9182 limak9182 changed the title Feature/postgres database finalizer postgres database finalizer Mar 5, 2026
return r.updateStatus(ctx, postgresDB, conditionType, conditionStatus, reason, message, phase)
}

// Finalizer logic: clean up managed users and databases from CNPG when PostgresDatabase is deleted
Copy link
Collaborator

Choose a reason for hiding this comment

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

according to the ERD we should also have a way to say if database should be retained or removed. We already reflected this in DatabaseDefinition struct. If deleted we should remove it, but in case of retained we should probably keep cnpg Database CR available

}

// Finalizer logic: clean up managed users and databases from CNPG when PostgresDatabase is deleted
if !postgresDB.ObjectMeta.DeletionTimestamp.IsZero() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we have a higher finalizer function that wraps it for the sake of readability? we could then also simplify status management

return fmt.Errorf("failed to list CNPG Databases for cleanup: %w", err)
}

for i := range cnpgDBList.Items {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can do for _, db := range cnpgDBList.Items without using index to get the db

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants