Skip to content

Commit 36adde2

Browse files
fix bugs
Signed-off-by: stoneshi-yunify <stoneshi@kubesphere.io>
1 parent b8a8f12 commit 36adde2

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/webhook/pod.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,9 @@ func (a *Admitter) pvcMatch(ctx context.Context, pod *corev1.Pod, pvc *corev1.Pe
331331
}
332332

333333
if pvcMatcher.StorageClass != nil && pvc.Spec.StorageClassName != nil {
334+
if *pvc.Spec.StorageClassName == "" {
335+
return false, nil
336+
}
334337
sc := &v1.StorageClass{}
335338
err = a.client.Get(ctx, types.NamespacedName{Name: *pvc.Spec.StorageClassName}, sc)
336339
if err != nil {
@@ -357,6 +360,9 @@ func (a *Admitter) pvcMatch(ctx context.Context, pod *corev1.Pod, pvc *corev1.Pe
357360

358361
wsName, ok := ns.Labels["kubesphere.io/workspace"]
359362
if ok && pvcMatcher.Workspace != nil {
363+
if wsName == "" {
364+
return false, nil
365+
}
360366
ws := &tenantv1alpha1.Workspace{}
361367
err = a.client.Get(ctx, types.NamespacedName{Name: wsName}, ws)
362368
if err != nil {

0 commit comments

Comments
 (0)