@@ -193,6 +193,24 @@ var _ = ginkgo.Describe("[sig-node] DRA [Feature:DynamicResourceAllocation]", fu
193
193
b .testPod (ctx , f .ClientSet , pod )
194
194
})
195
195
196
+ ginkgo .It ("runs a pod without a generated resource claim" , func (ctx context.Context ) {
197
+ pod , _ /* template */ := b .podInline (resourcev1alpha2 .AllocationModeWaitForFirstConsumer )
198
+ created := b .create (ctx , pod )
199
+ pod = created [0 ].(* v1.Pod )
200
+
201
+ // Normally, this pod would be stuck because the
202
+ // ResourceClaim cannot be created without the
203
+ // template. We allow it to run by communicating
204
+ // through the status that the ResourceClaim is not
205
+ // needed.
206
+ pod .Status .ResourceClaimStatuses = []v1.PodResourceClaimStatus {
207
+ {Name : pod .Spec .ResourceClaims [0 ].Name , ResourceClaimName : nil },
208
+ }
209
+ _ , err := f .ClientSet .CoreV1 ().Pods (pod .Namespace ).UpdateStatus (ctx , pod , metav1.UpdateOptions {})
210
+ framework .ExpectNoError (err )
211
+ framework .ExpectNoError (e2epod .WaitForPodRunningInNamespace (ctx , f .ClientSet , pod ))
212
+ })
213
+
196
214
// claimTests tries out several different combinations of pods with
197
215
// claims, both inline and external.
198
216
claimTests := func (allocationMode resourcev1alpha2.AllocationMode ) {
@@ -832,27 +850,31 @@ func (b *builder) podExternalMultiple() *v1.Pod {
832
850
}
833
851
834
852
// create takes a bunch of objects and calls their Create function.
835
- func (b * builder ) create (ctx context.Context , objs ... klog.KMetadata ) {
853
+ func (b * builder ) create (ctx context.Context , objs ... klog.KMetadata ) []klog.KMetadata {
854
+ var createdObjs []klog.KMetadata
836
855
for _ , obj := range objs {
837
856
ginkgo .By (fmt .Sprintf ("creating %T %s" , obj , obj .GetName ()), func () {
838
857
var err error
858
+ var createdObj klog.KMetadata
839
859
switch obj := obj .(type ) {
840
860
case * resourcev1alpha2.ResourceClass :
841
- _ , err = b .f .ClientSet .ResourceV1alpha2 ().ResourceClasses ().Create (ctx , obj , metav1.CreateOptions {})
861
+ createdObj , err = b .f .ClientSet .ResourceV1alpha2 ().ResourceClasses ().Create (ctx , obj , metav1.CreateOptions {})
842
862
case * v1.Pod :
843
- _ , err = b .f .ClientSet .CoreV1 ().Pods (b .f .Namespace .Name ).Create (ctx , obj , metav1.CreateOptions {})
863
+ createdObj , err = b .f .ClientSet .CoreV1 ().Pods (b .f .Namespace .Name ).Create (ctx , obj , metav1.CreateOptions {})
844
864
case * v1.ConfigMap :
845
865
_ , err = b .f .ClientSet .CoreV1 ().ConfigMaps (b .f .Namespace .Name ).Create (ctx , obj , metav1.CreateOptions {})
846
866
case * resourcev1alpha2.ResourceClaim :
847
- _ , err = b .f .ClientSet .ResourceV1alpha2 ().ResourceClaims (b .f .Namespace .Name ).Create (ctx , obj , metav1.CreateOptions {})
867
+ createdObj , err = b .f .ClientSet .ResourceV1alpha2 ().ResourceClaims (b .f .Namespace .Name ).Create (ctx , obj , metav1.CreateOptions {})
848
868
case * resourcev1alpha2.ResourceClaimTemplate :
849
- _ , err = b .f .ClientSet .ResourceV1alpha2 ().ResourceClaimTemplates (b .f .Namespace .Name ).Create (ctx , obj , metav1.CreateOptions {})
869
+ createdObj , err = b .f .ClientSet .ResourceV1alpha2 ().ResourceClaimTemplates (b .f .Namespace .Name ).Create (ctx , obj , metav1.CreateOptions {})
850
870
default :
851
871
framework .Fail (fmt .Sprintf ("internal error, unsupported type %T" , obj ), 1 )
852
872
}
853
873
framework .ExpectNoErrorWithOffset (1 , err , "create %T" , obj )
874
+ createdObjs = append (createdObjs , createdObj )
854
875
})
855
876
}
877
+ return createdObjs
856
878
}
857
879
858
880
// testPod runs pod and checks if container logs contain expected environment variables
0 commit comments