mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 03:08:15 +00:00
Fix PVC.Status.Capacity and AccessModes after binding
Also, fix unit tests to have the same claim and volume sizes in most of the tests where we don't test matching based on size and test for a specific size when we do actually test the matching.
This commit is contained in:
@@ -694,6 +694,17 @@ func withLabelSelector(labels map[string]string, claims []*api.PersistentVolumeC
|
||||
return claims
|
||||
}
|
||||
|
||||
// withExpectedCapacity sets the claim.Spec.Capacity of the first claim in the
|
||||
// array to given value and returns the array. Meant to be used to compose
|
||||
// claims specified inline in a test.
|
||||
func withExpectedCapacity(capacity string, claims []*api.PersistentVolumeClaim) []*api.PersistentVolumeClaim {
|
||||
claims[0].Status.Capacity = api.ResourceList{
|
||||
api.ResourceName(api.ResourceStorage): resource.MustParse(capacity),
|
||||
}
|
||||
|
||||
return claims
|
||||
}
|
||||
|
||||
// withMessage saves given message into volume.Status.Message of the first
|
||||
// volume in the array and returns the array. Meant to be used to compose
|
||||
// volumes specified inline in a test.
|
||||
@@ -741,6 +752,15 @@ func newClaim(name, claimUID, capacity, boundToVolume string, phase api.Persiste
|
||||
claim.Annotations[a] = "yes"
|
||||
}
|
||||
}
|
||||
|
||||
// Bound claims must have proper Status.
|
||||
if phase == api.ClaimBound {
|
||||
claim.Status.AccessModes = claim.Spec.AccessModes
|
||||
// For most of the tests it's enough to copy claim's requested capacity,
|
||||
// individual tests can adjust it using withExpectedCapacity()
|
||||
claim.Status.Capacity = claim.Spec.Resources.Requests
|
||||
}
|
||||
|
||||
return &claim
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user