Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

br: a more straight forward operator interface #5710

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

RidRisR
Copy link
Contributor

@RidRisR RidRisR commented Aug 15, 2024

What problem does this PR solve?

Closes #5699

  1. Use a more straight forward operator interface to replace the old one.
  2. support pause and resume pitr task

What is changed and how does it work?

Now, the crd to control log backup would loops like

  backupMode: log
  logSubcommand: log-start/log-stop/log-pause
  logTruncateUntil: "xxxxxxxxx"

(If no subcommand is provided, the default value is log-start)

If the task is not created before:
It could transfer to running state using log-start

If the task is running:
It could transfer to paused state using log-pause
It could transfer to stop state using log-stop

If the task is paused:
It could transfer to running state using log-start
It could transfer to stop state using log-stop

If the task is stopped:
This is the end state and can't transfer state again

As long as the task is created, user could set logTruncateUntil and truncate would be sync after subcommand is done

截屏2024-09-02 17 50 46

Code changes

  • Has Go code change
  • Has CI related scripts change

Tests

  • Unit test
  • E2E test
  • Manual test
  • No code

Side effects

  • Breaking backward compatibility
  • Other side effects:

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release Notes

Please refer to Release Notes Language Style Guide before writing the release note.

1. Use a more straight forward operator interface to replace the old one.
Now, the crd to control log backup would loops like
`spec:
  backupMode: log
  logSubcommand: `log-start`/`log-stop`/`log-pause`
  logTruncateUntil: "xxxxxxxxx"
`
(If no subcommand is provided, the default value is `log-start`)

2. Support pause and resume pitr task
Now, users could pause and resume pitr task by using `log-pause` and `log-start`

@sre-bot
Copy link
Contributor

sre-bot commented Aug 15, 2024

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot bot added the size/XXL label Aug 15, 2024
@codecov-commenter
Copy link

codecov-commenter commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 6.00000% with 47 lines in your changes missing coverage. Please review.

Project coverage is 61.42%. Comparing base (9ef26f8) to head (7ee8579).
Report is 22 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5710      +/-   ##
==========================================
- Coverage   61.47%   61.42%   -0.05%     
==========================================
  Files         235      235              
  Lines       30653    30854     +201     
==========================================
+ Hits        18843    18952     +109     
- Misses       9920     9991      +71     
- Partials     1890     1911      +21     
Flag Coverage Δ
unittest 61.42% <6.00%> (-0.05%) ⬇️

@RidRisR RidRisR marked this pull request as ready for review August 29, 2024 09:35
@ti-chi-bot ti-chi-bot bot requested a review from shonge August 29, 2024 09:35
@ti-chi-bot ti-chi-bot bot removed the needs-rebase label Aug 30, 2024
@RidRisR RidRisR changed the title Subcommand br: a more straight forward operator interface Aug 30, 2024
@BornChanger BornChanger requested review from csuzhangxc and WangLe1321 and removed request for howardlau1999 and shonge August 30, 2024 10:24
pkg/apis/pingcap/v1alpha1/types.go Show resolved Hide resolved
pkg/controller/backup/backup_controller.go Outdated Show resolved Hide resolved
cmd/backup-manager/app/backup/backup.go Outdated Show resolved Hide resolved
pkg/apis/pingcap/v1alpha1/backup.go Outdated Show resolved Hide resolved
pkg/apis/pingcap/v1alpha1/backup.go Outdated Show resolved Hide resolved
pkg/apis/pingcap/v1alpha1/backup.go Outdated Show resolved Hide resolved
pkg/controller/backup/backup_controller.go Outdated Show resolved Hide resolved
pkg/apis/pingcap/v1alpha1/backup.go Outdated Show resolved Hide resolved
pkg/apis/pingcap/v1alpha1/backup.go Outdated Show resolved Hide resolved
pkg/apis/pingcap/v1alpha1/backup.go Outdated Show resolved Hide resolved
@BornChanger
Copy link
Contributor

BornChanger commented Sep 17, 2024

For the state machine figure, please also add the scenarios where the state change due to gc-ttl. @RidRisR

@RidRisR
Copy link
Contributor Author

RidRisR commented Sep 25, 2024

For the state machine figure, please also add the scenarios where the state change due to gc-ttl. @RidRisR

we can't modify advancer time out setting now. therefore, the gc-ttl will only time out after 24 hours, it seems too long for a test.

cmd/backup-manager/app/backup/manager.go Show resolved Hide resolved
pkg/apis/pingcap/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/apis/pingcap/v1alpha1/types.go Show resolved Hide resolved
Comment on lines 330 to 344
switch backup.Spec.LogSubcommand {
case "":
fallthrough
case LogStartCommand:
if IsLogBackupAlreadyPaused(backup) {
subCommand = LogResumeCommand
} else {
subCommand = LogStartCommand
}
case LogStopCommand:
subCommand = LogStopCommand
case LogPauseCommand:
subCommand = LogPauseCommand
default:
return LogUnknownCommand
Copy link
Member

Choose a reason for hiding this comment

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

if set LogSubcommand as "", what the subcommand will be used, log-unkown or log-start.

Copy link
Contributor Author

@RidRisR RidRisR Sep 25, 2024

Choose a reason for hiding this comment

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

Let me make it more clear:

  1. Actually we don't need the "" as a subcommand. The only reason we keep it is for compatible with the old version interface.
    The old usage is demonstrated here: br: add log backup, include start, truncate, stop #4682
    TL;DR
    In the old version, we use tthe following CRD to start a new task. Therefore, LogSubcommand == "" means LogStartCommand:
Spec:
# empty field
  1. I add LogUnknownCommand for handling unexpected input from users, but now we use +kubebuilder:validation:Enum instead. This field is useless now. I keep it just for a double insurance.

  2. Now I refactored the code in the new commit, I suppose it could be more clear now.

@ti-chi-bot ti-chi-bot bot added the lgtm label Sep 29, 2024
Copy link
Contributor

ti-chi-bot bot commented Sep 29, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: WangLe1321

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Sep 29, 2024
@ti-chi-bot ti-chi-bot bot removed the lgtm label Sep 29, 2024
Copy link
Contributor

ti-chi-bot bot commented Sep 29, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-29 03:04:06.077631345 +0000 UTC m=+151201.497844358: ☑️ agreed by WangLe1321.
  • 2024-09-29 03:04:42.955361523 +0000 UTC m=+151238.375574539: ✖️🔁 reset by ti-chi-bot[bot].

Copy link
Contributor

ti-chi-bot bot commented Sep 29, 2024

New changes are detected. LGTM label has been removed.

Copy link
Contributor

ti-chi-bot bot commented Sep 29, 2024

@RidRisR: Your PR was out of date, I have automatically updated it for you.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@csuzhangxc
Copy link
Member

/run-pull-e2e-kind-br

2 similar comments
@csuzhangxc
Copy link
Member

/run-pull-e2e-kind-br

@csuzhangxc
Copy link
Member

/run-pull-e2e-kind-br

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.

pitr: add support to log backup subcommand of status/pause/resume
6 participants