-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Check pod status before hook #5211
Check pod status before hook #5211
Conversation
1c07235
to
b9c9f8d
Compare
This is my first pr and I am following |
Please add a changlog according to this document: https://velero.io/docs/v1.5/code-standards/#adding-a-changelog |
b9c9f8d
to
b1b5a54
Compare
7a0055e
to
c122415
Compare
@blackpiglet i have add the unit test for the case, please take a look. |
c122415
to
1dc0387
Compare
1dc0387
to
3a43a20
Compare
@blackpiglet i have add the changlog and the unit test, do you have any spare time to review? Thank you! |
@cleverhu
|
3a43a20
to
041f61d
Compare
Signed-off-by: cleverhu <[email protected]>
041f61d
to
ae3785c
Compare
@reasonerjt PTAL |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
What's the status? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Not stale, because the issue still needs to be fixed. |
@@ -123,6 +123,12 @@ func (e *defaultPodCommandExecutor) ExecutePodCommand(log logrus.FieldLogger, it | |||
"hookTimeout": localHook.Timeout, | |||
}, | |||
) | |||
|
|||
if pod.Status.Phase == corev1api.PodSucceeded || pod.Status.Phase == corev1api.PodFailed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late response, but after going through the code again, I think we may need to change the condition check from current status into something like this:
if pod.Status.Phase != corev1api.PodRunning {
...
}
Furthermore, after this PR is put on hold for a while, this cannot be merged directly. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Not stale, because the issue still needs to be fixed. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Still not stale, because the issue still needs to be fixed. |
@ywk253100 I think your review is missing here |
@ywk253100 Did you take a look at #6811 which implements this slightly differently? In particular, it logs an error when trying to run a hook on a Failed Pod, so this doesn't go unnoticed. I think having a Failed Pod is typically something which the user didn't intend, so the fact that we cannot run the hook there is also something which the user didn't intend and should be treated as an error in the backup process. |
This reverts commit 9b1cffc.
@@ -123,6 +123,12 @@ func (e *defaultPodCommandExecutor) ExecutePodCommand(log logrus.FieldLogger, it | |||
"hookTimeout": localHook.Timeout, | |||
}, | |||
) | |||
|
|||
if pod.Status.Phase == corev1api.PodSucceeded || pod.Status.Phase == corev1api.PodFailed { | |||
hookLog.Infof("Pod entered phase %s before some post-backup exec hooks ran", pod.Status.Phase) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code path also applies to pre-hooks as far as I can tell.
@@ -262,6 +262,37 @@ func TestEnsureContainerExists(t *testing.T) { | |||
assert.NoError(t, err) | |||
} | |||
|
|||
func TestPodCompeted(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
Signed-off-by: cleverhu <[email protected]> Co-authored-by: cleverhu <[email protected]>
Signed-off-by: cleverhu <[email protected]> Co-authored-by: cleverhu <[email protected]>
Thank you for contributing to Velero!
Please add a summary of your change
Skip exec pod command when pod's phase is succeeded or failed.
Does your change fix a particular issue?
Fixes #5137
Please indicate you've done the following:
/kind changelog-not-required
as a comment on this pull request.site/content/docs/main
.