Skip to content

Commit

Permalink
fix: Orphan Volume judgment logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lbbniu committed Jun 13, 2023
1 parent eca3bbd commit 617a864
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/recommendation/recommender/volumes/recommend.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ func (vr *VolumesRecommender) Recommend(ctx *framework.RecommendationContext) er
isOrphanVolume := true
for _, pod := range ctx.Pods {
for _, volumeClaim := range pod.Spec.Volumes {
if volumeClaim.PersistentVolumeClaim != nil && volumeClaim.PersistentVolumeClaim.ClaimName == ctx.Object.GetName() {
isOrphanVolume = false
if volumeClaim.PersistentVolumeClaim == nil {
continue
}
for _, pvc := range ctx.PVCs {
if volumeClaim.PersistentVolumeClaim.ClaimName == pvc.Name {
isOrphanVolume = false
}
}
}
}
Expand Down

0 comments on commit 617a864

Please sign in to comment.