Skip to content

simplify controller logic by adding status helper methods to MantleBackup and Restore#166

Merged
molpako merged 1 commit into
mainfrom
refactor/move-helper-to-api-pkg
Jun 18, 2025
Merged

simplify controller logic by adding status helper methods to MantleBackup and Restore#166
molpako merged 1 commit into
mainfrom
refactor/move-helper-to-api-pkg

Conversation

@molpako

@molpako molpako commented Jun 13, 2025

Copy link
Copy Markdown
Contributor

simplify controller logic by adding status helper methods to MantleBackup and Restore.

@molpako molpako marked this pull request as ready for review June 13, 2025 09:12
@molpako molpako requested a review from Copilot June 13, 2025 09:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR simplifies controller and test logic by replacing direct checks on status conditions with newly added helper methods (IsReady and IsSynced) in MantleBackup and MantleRestore. The changes remove redundant meta package usage from tests and controllers and update error checks to use the helper methods.

  • Replaces meta.IsStatusConditionTrue calls with IsReady/IsSynced.
  • Removes obsolete meta imports in several files.
  • Updates tests and controllers to use the new helper methods.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/e2e/singlek8s/util.go Updated backup readiness check using backup.IsReady()
test/e2e/singlek8s/restore_test.go Changed restore condition assertion to use restore.IsReady()
test/e2e/multik8s/testutil/util.go Replaced meta-based condition checks with IsReady()/IsSynced() and refined error handling
test/e2e/multik8s/misc_test.go Updated multiple backup and restore condition assertions to use helper methods
test/e2e/multik8s/full_backup_test.go Updated backup readiness check with IsReady()
internal/testutil/resources.go Transitioned from meta calls to helper methods for backup conditions
internal/controller/replication.go Simplified condition check in replication logic using IsReady()
internal/controller/mantlerestore_controller.go Replaced restore condition check with IsReady()
internal/controller/mantlebackup_controller_test.go Updated tests to use IsReady() and IsSynced() for backup conditions
internal/controller/mantlebackup_controller.go Replaced condition checks with IsReady()/IsSynced() in replication and cleanup logic
api/v1/mantlerestore_types.go Added IsReady() helper method for MantleRestore
api/v1/mantlebackup_types.go Introduced IsReady() and IsSynced() helper methods for MantleBackup
Comments suppressed due to low confidence (2)

test/e2e/multik8s/testutil/util.go:497

  • [nitpick] Consider refining the error message in the surrounding context to include the actual status of the backup (or additional diagnostic information) to aid in troubleshooting when the backup is not ready.
if !mb.IsReady() {

api/v1/mantlebackup_types.go:90

  • [nitpick] Add a documentation comment for IsReady() to clearly explain which condition it checks and the significance of the ReadyToUse status for API consumers.
func (m *MantleBackup) IsReady() bool {

@molpako molpako requested review from peng225 and toshipp June 13, 2025 10:02
@peng225

peng225 commented Jun 16, 2025

Copy link
Copy Markdown
Contributor

@molpako
Since @satoru-takeuchi is the code owner of Mantle, could you ask him to review this PR?

@molpako molpako marked this pull request as draft June 16, 2025 05:30
@molpako molpako marked this pull request as ready for review June 16, 2025 05:30
@molpako molpako requested a review from satoru-takeuchi June 16, 2025 05:30
@peng225

peng225 commented Jun 16, 2025

Copy link
Copy Markdown
Contributor

@molpako Also, you need only 1 reviewer. I removed @toshipp and me from the reviewers.

@peng225

peng225 commented Jun 16, 2025

Copy link
Copy Markdown
Contributor

I removed @toshipp and me from the reviewers.

Something is wrong with GitHub and I cannot remove the reviewers...
Anyway, you can merge this PR after @satoru-takeuchi reviewed it.

@satoru-takeuchi satoru-takeuchi 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.

Just one minor nit.

}

// isCreatedWhenMantleControllerWasSecondary returns true iff the MantleBackup
// isCreatedWhenMantleControllerWasSecondary returns true if the MantleBackup

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.

'iff' is not a typo. It's intentional. It means "if and only if". Please keep it as is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"iff" will remain as written. Thanks for clarifying its meaning.

…ckup and Restore

Signed-off-by: Kyori Sakao <sakaok@cybozu.co.jp>
@molpako molpako force-pushed the refactor/move-helper-to-api-pkg branch from 13b947a to 164cf99 Compare June 18, 2025 07:38
@molpako molpako requested a review from satoru-takeuchi June 18, 2025 07:38
@molpako molpako merged commit 98d9926 into main Jun 18, 2025
11 checks passed
@molpako molpako deleted the refactor/move-helper-to-api-pkg branch June 18, 2025 08:23
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.

4 participants