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

Add WaitForReady flag to check container readiness state before exec a hook #6918

Merged
merged 1 commit into from
Oct 15, 2023

Conversation

Ripolin
Copy link
Contributor

@Ripolin Ripolin commented Oct 4, 2023

Thank you for contributing to Velero!

Before running a post restore hook, Velero test the targeted container to check if it's running or not. To me it should be better to check if targeted container is ready to run restore commands.

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Created a changelog file or added /kind changelog-not-required as a comment on this pull request.
  • Updated the corresponding documentation in site/content/docs/main.

Copy link
Member

@kaovilai kaovilai left a comment

Choose a reason for hiding this comment

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

Need changelog file

Created a changelog file or added /kind changelog-not-required as a comment on this pull request.

@kaovilai
Copy link
Member

kaovilai commented Oct 5, 2023

I think it is possible for someone to have a workload such that it isn't ready until the hook runs to do something such as adding data.

Perhaps a new kind of hook could be reasonable.. prehookready? thoughts?

@kaovilai
Copy link
Member

kaovilai commented Oct 5, 2023

ie. this change can break an existing workload that is only ready by manually running a script when prehook is run on restore.

@sseago
Copy link
Collaborator

sseago commented Oct 5, 2023

@kaovilai @Ripolin or perhaps instead of a new hook type, a new bool field added to ExecRestoreHook -- something like WaitForReady and then the logic could wait for running vs. ready depending on this field.

https://github.com/vmware-tanzu/velero/blob/main/pkg/apis/velero/v1/restore_types.go#L194

@shubham-pampattiwar
Copy link
Collaborator

Having something like WaitForReady in ExecRestoreHook API would make sense I believe.

@Ripolin
Copy link
Contributor Author

Ripolin commented Oct 6, 2023

Having something like WaitForReady in ExecRestoreHook API would make sense I believe.

Like that 1e211ae ?

@sseago
Copy link
Collaborator

sseago commented Oct 6, 2023

@Ripolin Yes, I was thinking something like that. A couple things, though:

  1. We'd need to update the restore hooks documentation to show this new field: https://github.com/vmware-tanzu/velero/blob/main/site/content/docs/main/restore-hooks.md#exec-restore-hooks
  2. Also, note that restore hooks can be specified using annotations, so we'd probably want to handle this field there as well.

@sseago
Copy link
Collaborator

sseago commented Oct 6, 2023

Since there can be multiple restore hooks, it looks like setting WaitForReady to true for only one hook has same effect as setting it for all -- since velero will wait until the container is ready for all hooks to run. I think this is probably fine as long as it's documented -- @shubham-pampattiwar what do you think?

@Ripolin
Copy link
Contributor Author

Ripolin commented Oct 8, 2023

@Ripolin Yes, I was thinking something like that. A couple things, though:

  1. We'd need to update the restore hooks documentation to show this new field: https://github.com/vmware-tanzu/velero/blob/main/site/content/docs/main/restore-hooks.md#exec-restore-hooks
  2. Also, note that restore hooks can be specified using annotations, so we'd probably want to handle this field there as well.

Done both

@shubham-pampattiwar
Copy link
Collaborator

@sseago yes I agree, the new behavior needs to be documented.

site/content/docs/main/restore-hooks.md Show resolved Hide resolved
pkg/apis/velero/v1/restore_types.go Outdated Show resolved Hide resolved
site/content/docs/main/restore-hooks.md Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Merging #6918 (e5af7f5) into main (ad114f8) will increase coverage by 0.01%.
The diff coverage is 89.65%.

@@            Coverage Diff             @@
##             main    #6918      +/-   ##
==========================================
+ Coverage   60.78%   60.80%   +0.01%     
==========================================
  Files         250      250              
  Lines       26629    26649      +20     
==========================================
+ Hits        16187    16204      +17     
- Misses       9293     9295       +2     
- Partials     1149     1150       +1     
Files Coverage Δ
internal/hook/wait_exec_hook_handler.go 73.09% <100.00%> (+1.32%) ⬆️
internal/hook/item_hook_handler.go 86.94% <83.33%> (-0.45%) ⬇️

changelogs/unreleased/6918-Ripolin Outdated Show resolved Hide resolved
internal/hook/item_hook_handler.go Outdated Show resolved Hide resolved
@blackpiglet
Copy link
Contributor

@Ripolin
Could you help to squash the commits?

@Ripolin
Copy link
Contributor Author

Ripolin commented Oct 12, 2023

@Ripolin Could you help to squash the commits?

Squash and rebase done !

@Ripolin Ripolin changed the title Check container is ready and not running before exec a hook Add WaitForReady flag to check container readiness state before exec a hook Oct 12, 2023
@blackpiglet blackpiglet merged commit b4fb2d9 into vmware-tanzu:main Oct 15, 2023
24 checks passed
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.

6 participants