Skip to content

Commit

Permalink
pod crashed when creaing init pod, new pod will always fail
Browse files Browse the repository at this point in the history
Signed-off-by: styshoo <styshoo1986@gmail.com>
  • Loading branch information
styshoo committed Jan 20, 2025
1 parent 88d21e2 commit bea5825
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/provisioner-localpv/app/helper_hostpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app

import (
"context"
"k8s.io/apimachinery/pkg/labels"
"math"
"path/filepath"
"regexp"
Expand All @@ -14,6 +13,7 @@ import (
errors "github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/klog/v2"

"github.com/openebs/dynamic-localpv-provisioner/pkg/kubernetes/api/core/v1/container"
Expand Down Expand Up @@ -308,6 +308,7 @@ func (p *Provisioner) launchPod(ctx context.Context, config podConfig) (*corev1.
matchLabels := map[string]string{
"openebs.io/pvc-name": config.pOpts.name,
"openebs.io/pvc-namespace": p.namespace,
"openebs.io/helper-type": "hostpath-" + config.podName,
}
podList, err := p.kubeClient.CoreV1().Pods(p.namespace).List(ctx, metav1.ListOptions{
LabelSelector: labels.Set(matchLabels).String(),
Expand All @@ -316,6 +317,8 @@ func (p *Provisioner) launchPod(ctx context.Context, config podConfig) (*corev1.
return nil, err
}
if podList.Items != nil && len(podList.Items) != 0 {
klog.Infof("existing helper podList length: %d", len(podList.Items))
klog.Infof("existing helper pod: %v", podList.Items[0])
return &podList.Items[0], nil
}

Expand Down

0 comments on commit bea5825

Please sign in to comment.