diff --git a/changelogs/unreleased/5211-cleverhu b/changelogs/unreleased/5211-cleverhu deleted file mode 100644 index 1ed39117cf..0000000000 --- a/changelogs/unreleased/5211-cleverhu +++ /dev/null @@ -1 +0,0 @@ -fix run preHook and postHook on completed pods \ No newline at end of file diff --git a/pkg/podexec/pod_command_executor.go b/pkg/podexec/pod_command_executor.go index b268d77a39..569fca4e58 100644 --- a/pkg/podexec/pod_command_executor.go +++ b/pkg/podexec/pod_command_executor.go @@ -123,12 +123,6 @@ 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) - return nil - } - hookLog.Info("running exec hook") req := e.restClient.Post(). diff --git a/pkg/podexec/pod_command_executor_test.go b/pkg/podexec/pod_command_executor_test.go index bdd960a592..3f6937192e 100644 --- a/pkg/podexec/pod_command_executor_test.go +++ b/pkg/podexec/pod_command_executor_test.go @@ -262,37 +262,6 @@ func TestEnsureContainerExists(t *testing.T) { assert.NoError(t, err) } -func TestPodCompeted(t *testing.T) { - pod := &corev1api.Pod{ - Spec: corev1api.PodSpec{ - Containers: []corev1api.Container{ - { - Name: "foo", - }, - }, - }, - Status: corev1api.PodStatus{ - Phase: corev1api.PodSucceeded, - }, - } - - obj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(pod) - require.NoError(t, err) - - clientConfig := &rest.Config{} - poster := &mockPoster{} - defer poster.AssertExpectations(t) - podCommandExecutor := NewPodCommandExecutor(clientConfig, poster).(*defaultPodCommandExecutor) - - hook := v1.ExecHook{ - Container: "foo", - Command: []string{"some", "command"}, - } - - err = podCommandExecutor.ExecutePodCommand(velerotest.NewLogger(), obj, "namespace", "name", "hookName", &hook) - require.NoError(t, err) -} - type mockStreamExecutorFactory struct { mock.Mock }