Skip to content

Commit

Permalink
Merge pull request #110 from razo7/force-delete-pod
Browse files Browse the repository at this point in the history
Delete Pods with Zero Grace Period
  • Loading branch information
openshift-merge-bot[bot] authored Dec 12, 2023
2 parents c81afe0 + e2cc229 commit 4290829
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion controllers/fenceagentsremediation_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const (
vaName1 = "va-test-1"
vaName2 = "va-test-2"

forced client.GracePeriodSeconds = 0
// intervals
timeoutDeletion = 2 * time.Second // this timeout is used after all the other steps have finished successfully
timeoutFinalizer = 1 * time.Second
Expand Down Expand Up @@ -285,7 +286,7 @@ func cleanupTestedResources(va1, va2 *storagev1.VolumeAttachment, pod *corev1.Po
podTest := &corev1.Pod{}
if err := k8sClient.Get(context.Background(), client.ObjectKeyFromObject(pod), podTest); err == nil {
log.Info("Cleanup: clean pod", "pod name", podTest.Name)
Expect(k8sClient.Delete(context.Background(), podTest)).To(Succeed())
Expect(k8sClient.Delete(context.Background(), podTest, forced)).To(Succeed())
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/e2e/far_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
testContainerName = "test-container"
testPodName = "test-pod"

forced client.GracePeriodSeconds = 0
//TODO: try to minimize timeout
// eventually parameters
timeoutLogs = 3 * time.Minute
Expand Down Expand Up @@ -268,7 +269,7 @@ func deleteFAR(far *v1alpha1.FenceAgentsRemediation) {
func cleanupTestedResources(pod *corev1.Pod) {
newPod := &corev1.Pod{}
if err := k8sClient.Get(context.Background(), client.ObjectKeyFromObject(pod), newPod); err == nil {
Expect(k8sClient.Delete(context.Background(), newPod)).To(Succeed())
Expect(k8sClient.Delete(context.Background(), newPod, forced)).To(Succeed())
log.Info("cleanup: Pod has not been deleted by remediation", "pod name", pod.Name)
}
}
Expand Down

0 comments on commit 4290829

Please sign in to comment.