Skip to content

Commit

Permalink
cdi for tmp-pvc
Browse files Browse the repository at this point in the history
Signed-off-by: Valeriy Khorunzhin <[email protected]>
  • Loading branch information
Valeriy Khorunzhin committed Jan 15, 2025
1 parent e6b9414 commit a8c81a4
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,16 @@ index 4c153257a..e21e40312 100644
} else {
diff --git a/pkg/patcheddatavolume/patched_datavolume.go b/pkg/patcheddatavolume/patched_datavolume.go
new file mode 100644
index 000000000..7f5112e87
index 000000000..29fc38c97
--- /dev/null
+++ b/pkg/patcheddatavolume/patched_datavolume.go
@@ -0,0 +1,120 @@
@@ -0,0 +1,124 @@
+package patcheddatavolume
+
+import (
+ "context"
+ "fmt"
+ "strings"
+
+ corev1 "k8s.io/api/core/v1"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -139,6 +140,8 @@ index 000000000..7f5112e87
+
+ QuotaNotExceededReason string = "QuotaNotExceeded"
+ QuotaExceededReason string = "QuotaExceeded"
+
+ RunningConditionErrorReason string = "Error"
+)
+
+func FindConditionByType(conditionType cdiv1.DataVolumeConditionType, conditions []cdiv1.DataVolumeCondition) *cdiv1.DataVolumeCondition {
Expand All @@ -162,7 +165,8 @@ index 000000000..7f5112e87
+ case boundCondition != nil && boundCondition.Reason == common.ErrExceededQuota:
+ conditions = updateCondition(conditions, QoutaNotExceededConditionType, corev1.ConditionFalse, fmt.Sprintf("Exceeded quota: %q", boundCondition.Message), QuotaExceededReason)
+ case runningCondition != nil:
+ if runningCondition.Reason == common.ErrExceededQuota {
+ if runningCondition.Reason == common.ErrExceededQuota ||
+ runningCondition.Reason == RunningConditionErrorReason && strings.Contains(runningCondition.Message, "exceeded quota") {
+ conditions = updateCondition(conditions, QoutaNotExceededConditionType, corev1.ConditionFalse, fmt.Sprintf("Exceeded quota: %q", runningCondition.Message), QuotaExceededReason)
+ } else if runningCondition.Status == corev1.ConditionTrue {
+ conditions = updateCondition(conditions, QoutaNotExceededConditionType, corev1.ConditionTrue, "", QuotaNotExceededReason)
Expand Down

0 comments on commit a8c81a4

Please sign in to comment.