DRA: remove "source" indirection from v1 Pod API

This makes the API nicer:

    resourceClaims:
    - name: with-template
      resourceClaimTemplateName: test-inline-claim-template
    - name: with-claim
      resourceClaimName: test-shared-claim

Previously, this was:

    resourceClaims:
    - name: with-template
      source:
        resourceClaimTemplateName: test-inline-claim-template
    - name: with-claim
      source:
        resourceClaimName: test-shared-claim

A more long-term benefit is that other, future alternatives
might not make sense under the "source" umbrella.

This is a breaking change. It's justified because DRA is still
alpha and will have several other API breaks in 1.31.
This commit is contained in:
Patrick Ohly
2024-05-24 15:24:24 +02:00
parent bb95d084a2
commit bde9b64cdf
209 changed files with 117866 additions and 2126 deletions

View File

@@ -297,7 +297,7 @@ func (ec *Controller) podNeedsWork(pod *v1.Pod) (bool, string) {
}
claim, err := ec.claimLister.ResourceClaims(pod.Namespace).Get(*claimName)
if apierrors.IsNotFound(err) {
if podClaim.Source.ResourceClaimTemplateName != nil {
if podClaim.ResourceClaimTemplateName != nil {
return true, "must create ResourceClaim from template"
}
// User needs to create claim.
@@ -592,7 +592,7 @@ func (ec *Controller) handleClaim(ctx context.Context, pod *v1.Pod, podClaim v1.
}
}
templateName := podClaim.Source.ResourceClaimTemplateName
templateName := podClaim.ResourceClaimTemplateName
if templateName == nil {
// Nothing to do.
return nil

View File

@@ -647,10 +647,8 @@ func reserveClaim(claim *resourcev1alpha2.ResourceClaim, pod *v1.Pod) *resourcev
func makePodResourceClaim(name, templateName string) *v1.PodResourceClaim {
return &v1.PodResourceClaim{
Name: name,
Source: v1.ClaimSource{
ResourceClaimTemplateName: &templateName,
},
Name: name,
ResourceClaimTemplateName: &templateName,
}
}