Skip to content

Commit

Permalink
Fixed typo and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Lintong Jiang committed Oct 19, 2021
1 parent d9897b1 commit a412ce0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pkg/syncer/admissionhandler/validatepvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

const (
ExpandVolumeWithSnapshotErrorMessage = "Expanding volume with snapshots is not allowed"
DeleteVoluemWithSnapshotErrorMessage = "Deleting volume with snapshots is not allowed"
DeleteVolumeWithSnapshotErrorMessage = "Deleting volume with snapshots is not allowed"
)

// validatePVC helps validate AdmissionReview requests for PersistentVolumeClaim.
Expand Down Expand Up @@ -58,7 +58,7 @@ func validatePVC(ctx context.Context, ar *admissionv1.AdmissionReview) *admissio
oldReq := oldPVC.Spec.Resources.Requests[corev1.ResourceStorage]

if !isRWOVolumeRequest(oldPVC.Spec.AccessModes) {
log.Infof("the access mode of PVC is not ReadWriteOnce. skipping validation.")
log.Info("the access mode of PVC is not ReadWriteOnce. skipping validation.")
return &admissionv1.AdmissionResponse{
// skip validation if the pvc is not RWO
Allowed: true,
Expand Down Expand Up @@ -87,8 +87,8 @@ func validatePVC(ctx context.Context, ar *admissionv1.AdmissionReview) *admissio
}
}

if reclaimPolicy == corev1.PersistentVolumeReclaimRetain {
log.Infof("the reclaim policy of PVC is Retain. skipping validation.")
if reclaimPolicy != corev1.PersistentVolumeReclaimDelete {
log.Info("the reclaim policy of PVC is not Delete. skipping validation.")
return &admissionv1.AdmissionResponse{
// skip validation if the reclaim policy of PVC is not Delete
Allowed: true,
Expand All @@ -113,7 +113,7 @@ func validatePVC(ctx context.Context, ar *admissionv1.AdmissionReview) *admissio
}
} else if req.Operation == admissionv1.Delete {
result = &metav1.Status{
Reason: DeleteVoluemWithSnapshotErrorMessage,
Reason: DeleteVolumeWithSnapshotErrorMessage,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/syncer/admissionhandler/validatepvc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestValidatePVC(t *testing.T) {
expectedResponse: &admissionv1.AdmissionResponse{
Allowed: false,
Result: &metav1.Status{
Reason: DeleteVoluemWithSnapshotErrorMessage,
Reason: DeleteVolumeWithSnapshotErrorMessage,
},
},
},
Expand Down

0 comments on commit a412ce0

Please sign in to comment.