Skip to content

Commit a391266

Browse files
committed
calculate usage on istag creates
1 parent 158ae03 commit a391266

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

pkg/quota/image/imagestreamtag_evaluator.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ func NewImageStreamTagEvaluator(istNamespacer osclient.ImageStreamTagsNamespacer
4848
}
4949

5050
return &generic.GenericEvaluator{
51-
Name: imageStreamTagEvaluatorName,
52-
InternalGroupKind: imageapi.Kind("ImageStreamTag"),
53-
InternalOperationResources: map[admission.Operation][]kapi.ResourceName{admission.Update: computeResources},
54-
MatchedResourceNames: computeResources,
55-
MatchesScopeFunc: matchesScopeFunc,
56-
UsageFunc: makeImageStreamTagAdmissionUsageFunc(isNamespacer),
57-
GetFuncByNamespace: getFuncByNamespace,
51+
Name: imageStreamTagEvaluatorName,
52+
InternalGroupKind: imageapi.Kind("ImageStreamTag"),
53+
InternalOperationResources: map[admission.Operation][]kapi.ResourceName{
54+
admission.Update: computeResources,
55+
admission.Create: computeResources,
56+
},
57+
MatchedResourceNames: computeResources,
58+
MatchesScopeFunc: matchesScopeFunc,
59+
UsageFunc: makeImageStreamTagAdmissionUsageFunc(isNamespacer),
60+
GetFuncByNamespace: getFuncByNamespace,
5861
ListFuncByNamespace: func(namespace string, options kapi.ListOptions) (runtime.Object, error) {
5962
return &imageapi.ImageStreamTagList{}, nil
6063
},

test/cmd/quota.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ trap os::test::junit::reconcile_output EXIT
44

55
os::test::junit::declare_suite_start "cmd/quota"
66

7+
os::test::junit::declare_suite_start "cmd/quota/clusterquota"
8+
79
os::cmd::expect_success 'oc new-project foo --as=deads'
810
os::cmd::expect_success 'oc label namespace/foo owner=deads'
911
os::cmd::expect_success 'oc create clusterquota for-deads --project-label-selector=owner=deads --hard=secrets=10'
@@ -20,5 +22,17 @@ os::cmd::try_until_text 'oc describe appliedclusterresourcequota/for-deads-by-an
2022
os::cmd::expect_success 'oc delete project foo'
2123
os::cmd::expect_success 'oc delete project bar'
2224

23-
echo "quota: ok"
25+
echo "clusterquota: ok"
26+
os::test::junit::declare_suite_end
27+
28+
os::test::junit::declare_suite_start "cmd/quota/imagestreams"
29+
30+
os::cmd::expect_success 'oc new-project foo-2 --as=deads'
31+
os::cmd::expect_success 'oc create quota -n foo-2 is-quota --hard openshift.io/imagestreams=1'
32+
os::cmd::try_until_success 'oc tag -n foo-2 openshift/hello-openshift myis2:v2'
33+
os::cmd::expect_failure_and_text 'oc tag -n foo-2 busybox mybox:v1' "Exceeded quota"
34+
35+
echo "imagestreams: ok"
36+
os::test::junit::declare_suite_end
37+
2438
os::test::junit::declare_suite_end

0 commit comments

Comments
 (0)