Skip to content

Commit

Permalink
Merge pull request #120 from FabianKramm/main
Browse files Browse the repository at this point in the history
fix: fixed an issue where pods wouldn't get deleted correctly
  • Loading branch information
FabianKramm authored Aug 19, 2021
2 parents a942941 + 7c73500 commit 751fe6e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/controllers/resources/pods/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,10 @@ func (s *syncer) NewList() client.ObjectList {

func (s *syncer) ForwardCreate(ctx context.Context, vObj client.Object, log loghelper.Logger) (ctrl.Result, error) {
vPod := vObj.(*corev1.Pod)
pPod, err := s.translatePod(vPod)
if err != nil {
return ctrl.Result{}, err
}

if vPod.DeletionTimestamp != nil {
// delete pod immediately
log.Infof("delete pod %s/%s immediately, because it is being deleted & there is no physical pod", vPod.Namespace, vPod.Name)
err = s.virtualClient.Delete(ctx, vPod, &client.DeleteOptions{
err := s.virtualClient.Delete(ctx, vPod, &client.DeleteOptions{
GracePeriodSeconds: &zero,
})
if kerrors.IsNotFound(err) {
Expand All @@ -145,6 +140,11 @@ func (s *syncer) ForwardCreate(ctx context.Context, vObj client.Object, log logh
return ctrl.Result{}, err
}

pPod, err := s.translatePod(vPod)
if err != nil {
return ctrl.Result{}, err
}

// ensure node selector
if s.nodeSelector != nil {
// 2 cases:
Expand Down

0 comments on commit 751fe6e

Please sign in to comment.