Skip to content

Commit

Permalink
Fix deletion of the pod created by blueprint without namespace (#2106)
Browse files Browse the repository at this point in the history
* fix deletion of the pod created by BP without NS

* Update pkg/kube/pod_controller.go

Co-authored-by: Pavan Navarathna <6504783+pavannd1@users.noreply.github.com>

---------

Co-authored-by: Pavan Navarathna <6504783+pavannd1@users.noreply.github.com>
  • Loading branch information
AKhoria and pavannd1 authored Jun 14, 2023
1 parent 69af1af commit f90d50a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/kube/pod_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ func (p *podController) StopPod(ctx context.Context, stopTimeout time.Duration,
defer cancel()
}

if err := p.pcp.deletePod(ctx, p.podOptions.Namespace, p.podName, metav1.DeleteOptions{GracePeriodSeconds: &gracePeriodSeconds}); err != nil {
log.WithError(err).Print("Failed to delete pod", field.M{"PodName": p.podName, "Namespace": p.podOptions.Namespace})
if err := p.pcp.deletePod(ctx, p.pod.Namespace, p.podName, metav1.DeleteOptions{GracePeriodSeconds: &gracePeriodSeconds}); err != nil {
log.WithError(err).Print("Failed to delete pod", field.M{"PodName": p.podName, "Namespace": p.pod.Namespace})
return err
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/kube/pod_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ func (s *PodControllerTestSuite) TestPodControllerStopPod(c *C) {
"Pod deletion error": func(pcp *fakePodControllerProcessor, pc PodController) {
pcp.createPodRet = &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: podControllerPodName,
Name: podControllerPodName,
Namespace: podControllerNS,
},
}
err := pc.StartPod(ctx)
Expand All @@ -245,7 +246,8 @@ func (s *PodControllerTestSuite) TestPodControllerStopPod(c *C) {
"Pod successfully deleted": func(pcp *fakePodControllerProcessor, pc PodController) {
pcp.createPodRet = &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: podControllerPodName,
Name: podControllerPodName,
Namespace: podControllerNS,
},
}
err := pc.StartPod(ctx)
Expand All @@ -270,8 +272,7 @@ func (s *PodControllerTestSuite) TestPodControllerStopPod(c *C) {
}

pc := NewPodController(cli, &PodOptions{
Namespace: podControllerNS,
Name: podControllerPodName,
Name: podControllerPodName,
}, WithPodControllerProcessor(pcp))

tc(pcp, pc)
Expand Down

0 comments on commit f90d50a

Please sign in to comment.