PV Recycling API
This commit is contained in:
@@ -1243,11 +1243,14 @@ func deepCopy_api_PersistentVolumeSpec(in PersistentVolumeSpec, out *PersistentV
|
||||
} else {
|
||||
out.ClaimRef = nil
|
||||
}
|
||||
out.PersistentVolumeReclaimPolicy = in.PersistentVolumeReclaimPolicy
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_api_PersistentVolumeStatus(in PersistentVolumeStatus, out *PersistentVolumeStatus, c *conversion.Cloner) error {
|
||||
out.Phase = in.Phase
|
||||
out.Message = in.Message
|
||||
out.Reason = in.Reason
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@@ -234,8 +234,11 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
|
||||
},
|
||||
func(pv *api.PersistentVolume, c fuzz.Continue) {
|
||||
c.FuzzNoCustom(pv) // fuzz self without calling this function again
|
||||
types := []api.PersistentVolumePhase{api.VolumePending, api.VolumeBound, api.VolumeReleased, api.VolumeAvailable}
|
||||
types := []api.PersistentVolumePhase{api.VolumeAvailable, api.VolumePending, api.VolumeBound, api.VolumeReleased, api.VolumeFailed}
|
||||
pv.Status.Phase = types[c.Rand.Intn(len(types))]
|
||||
pv.Status.Message = c.RandString()
|
||||
reclamationPolicies := []api.PersistentVolumeReclaimPolicy{api.PersistentVolumeReclaimRecycle, api.PersistentVolumeReclaimRetain}
|
||||
pv.Spec.PersistentVolumeReclaimPolicy = reclamationPolicies[c.Rand.Intn(len(reclamationPolicies))]
|
||||
},
|
||||
func(pvc *api.PersistentVolumeClaim, c fuzz.Continue) {
|
||||
c.FuzzNoCustom(pvc) // fuzz self without calling this function again
|
||||
|
@@ -263,11 +263,33 @@ type PersistentVolumeSpec struct {
|
||||
// ClaimRef is expected to be non-nil when bound.
|
||||
// claim.VolumeName is the authoritative bind between PV and PVC.
|
||||
ClaimRef *ObjectReference `json:"claimRef,omitempty"`
|
||||
// Optional: what happens to a persistent volume when released from its claim.
|
||||
PersistentVolumeReclaimPolicy PersistentVolumeReclaimPolicy `json:"persistentVolumeReclaimPolicy,omitempty" description:"what happens to a volume when released from its claim; Valid options are Retain (default) and Recycle. Recyling must be supported by the volume plugin underlying this persistent volume."`
|
||||
}
|
||||
|
||||
// PersistentVolumeReclaimPolicy describes a policy for end-of-life maintenance of persistent volumes
|
||||
type PersistentVolumeReclaimPolicy string
|
||||
|
||||
const (
|
||||
// PersistentVolumeReclaimRecycle means the volume will be recycled back into the pool of unbound persistent volumes on release from its claim.
|
||||
// The volume plugin must support Recycling.
|
||||
PersistentVolumeReclaimRecycle PersistentVolumeReclaimPolicy = "Recycle"
|
||||
// PersistentVolumeReclaimDelete means the volume will be deleted from Kubernetes on release from its claim.
|
||||
// The volume plugin must support Deletion.
|
||||
// TODO: implement w/ DeletableVolumePlugin
|
||||
// PersistentVolumeReclaimDelete PersistentVolumeReclaimPolicy = "Delete"
|
||||
// PersistentVolumeReclaimRetain means the volume will left in its current phase (Released) for manual reclamation by the administrator.
|
||||
// The default policy is Retain.
|
||||
PersistentVolumeReclaimRetain PersistentVolumeReclaimPolicy = "Retain"
|
||||
)
|
||||
|
||||
type PersistentVolumeStatus struct {
|
||||
// Phase indicates if a volume is available, bound to a claim, or released by a claim
|
||||
Phase PersistentVolumePhase `json:"phase,omitempty"`
|
||||
// A human-readable message indicating details about why the volume is in this state.
|
||||
Message string `json:"message,omitempty"`
|
||||
// Reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI
|
||||
Reason string `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
type PersistentVolumeList struct {
|
||||
@@ -331,12 +353,16 @@ const (
|
||||
// used for PersistentVolumes that are not available
|
||||
VolumePending PersistentVolumePhase = "Pending"
|
||||
// used for PersistentVolumes that are not yet bound
|
||||
// Available volumes are held by the binder and matched to PersistentVolumeClaims
|
||||
VolumeAvailable PersistentVolumePhase = "Available"
|
||||
// used for PersistentVolumes that are bound
|
||||
VolumeBound PersistentVolumePhase = "Bound"
|
||||
// used for PersistentVolumes where the bound PersistentVolumeClaim was deleted
|
||||
// released volumes must be recycled before becoming available again
|
||||
// this phase is used by the persistent volume claim binder to signal to another process to reclaim the resource
|
||||
VolumeReleased PersistentVolumePhase = "Released"
|
||||
// used for PersistentVolumes that failed to be correctly recycled or deleted after being released from a claim
|
||||
VolumeFailed PersistentVolumePhase = "Failed"
|
||||
)
|
||||
|
||||
type PersistentVolumeClaimPhase string
|
||||
|
@@ -1358,6 +1358,7 @@ func convert_api_PersistentVolumeSpec_To_v1_PersistentVolumeSpec(in *api.Persist
|
||||
} else {
|
||||
out.ClaimRef = nil
|
||||
}
|
||||
out.PersistentVolumeReclaimPolicy = PersistentVolumeReclaimPolicy(in.PersistentVolumeReclaimPolicy)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1366,6 +1367,8 @@ func convert_api_PersistentVolumeStatus_To_v1_PersistentVolumeStatus(in *api.Per
|
||||
defaulting.(func(*api.PersistentVolumeStatus))(in)
|
||||
}
|
||||
out.Phase = PersistentVolumePhase(in.Phase)
|
||||
out.Message = in.Message
|
||||
out.Reason = in.Reason
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3633,6 +3636,7 @@ func convert_v1_PersistentVolumeSpec_To_api_PersistentVolumeSpec(in *PersistentV
|
||||
} else {
|
||||
out.ClaimRef = nil
|
||||
}
|
||||
out.PersistentVolumeReclaimPolicy = api.PersistentVolumeReclaimPolicy(in.PersistentVolumeReclaimPolicy)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3641,6 +3645,8 @@ func convert_v1_PersistentVolumeStatus_To_api_PersistentVolumeStatus(in *Persist
|
||||
defaulting.(func(*PersistentVolumeStatus))(in)
|
||||
}
|
||||
out.Phase = api.PersistentVolumePhase(in.Phase)
|
||||
out.Message = in.Message
|
||||
out.Reason = in.Reason
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@@ -1174,11 +1174,14 @@ func deepCopy_v1_PersistentVolumeSpec(in PersistentVolumeSpec, out *PersistentVo
|
||||
} else {
|
||||
out.ClaimRef = nil
|
||||
}
|
||||
out.PersistentVolumeReclaimPolicy = in.PersistentVolumeReclaimPolicy
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_v1_PersistentVolumeStatus(in PersistentVolumeStatus, out *PersistentVolumeStatus, c *conversion.Cloner) error {
|
||||
out.Phase = in.Phase
|
||||
out.Message = in.Message
|
||||
out.Reason = in.Reason
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@@ -113,6 +113,9 @@ func addDefaultingFuncs() {
|
||||
if obj.Status.Phase == "" {
|
||||
obj.Status.Phase = VolumePending
|
||||
}
|
||||
if obj.Spec.PersistentVolumeReclaimPolicy == "" {
|
||||
obj.Spec.PersistentVolumeReclaimPolicy = PersistentVolumeReclaimRetain
|
||||
}
|
||||
},
|
||||
func(obj *PersistentVolumeClaim) {
|
||||
if obj.Status.Phase == "" {
|
||||
|
@@ -258,6 +258,9 @@ func TestSetDefaultPersistentVolume(t *testing.T) {
|
||||
if pv2.Status.Phase != versioned.VolumePending {
|
||||
t.Errorf("Expected volume phase %v, got %v", versioned.VolumePending, pv2.Status.Phase)
|
||||
}
|
||||
if pv2.Spec.PersistentVolumeReclaimPolicy != versioned.PersistentVolumeReclaimRetain {
|
||||
t.Errorf("Expected pv reclaim policy %v, got %v", versioned.PersistentVolumeReclaimRetain, pv2.Spec.PersistentVolumeReclaimPolicy)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDefaultPersistentVolumeClaim(t *testing.T) {
|
||||
|
@@ -280,11 +280,33 @@ type PersistentVolumeSpec struct {
|
||||
// ClaimRef is expected to be non-nil when bound.
|
||||
// claim.VolumeName is the authoritative bind between PV and PVC.
|
||||
ClaimRef *ObjectReference `json:"claimRef,omitempty" description:"when bound, a reference to the bound claim"`
|
||||
// Optional: what happens to a persistent volume when released from its claim.
|
||||
PersistentVolumeReclaimPolicy PersistentVolumeReclaimPolicy `json:"persistentVolumeReclaimPolicy,omitempty" description:"what happens to a volume when released from its claim; Valid options are Retain (default) and Recycle. Recyling must be supported by the volume plugin underlying this persistent volume."`
|
||||
}
|
||||
|
||||
// PersistentVolumeReclaimPolicy describes a policy for end-of-life maintenance of persistent volumes
|
||||
type PersistentVolumeReclaimPolicy string
|
||||
|
||||
const (
|
||||
// PersistentVolumeReclaimRecycle means the volume will be recycled back into the pool of unbound persistent volumes on release from its claim.
|
||||
// The volume plugin must support Recycling.
|
||||
PersistentVolumeReclaimRecycle PersistentVolumeReclaimPolicy = "Recycle"
|
||||
// PersistentVolumeReclaimDelete means the volume will be deleted from Kubernetes on release from its claim.
|
||||
// The volume plugin must support Deletion.
|
||||
// TODO: implement w/ DeletableVolumePlugin
|
||||
// PersistentVolumeReclaimDelete PersistentVolumeReclaimPolicy = "Delete"
|
||||
// PersistentVolumeReclaimRetain means the volume will left in its current phase (Released) for manual reclamation by the administrator.
|
||||
// The default policy is Retain.
|
||||
PersistentVolumeReclaimRetain PersistentVolumeReclaimPolicy = "Retain"
|
||||
)
|
||||
|
||||
type PersistentVolumeStatus struct {
|
||||
// Phase indicates if a volume is available, bound to a claim, or released by a claim
|
||||
Phase PersistentVolumePhase `json:"phase,omitempty" description:"the current phase of a persistent volume"`
|
||||
// A human-readable message indicating details about why the volume is in this state.
|
||||
Message string `json:"message,omitempty" description:"human-readable message indicating details about why the volume is in this state"`
|
||||
// Reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI
|
||||
Reason string `json:"reason,omitempty" description:"(brief) reason the volume is not is not available"`
|
||||
}
|
||||
|
||||
type PersistentVolumeList struct {
|
||||
@@ -348,12 +370,16 @@ const (
|
||||
// used for PersistentVolumes that are not available
|
||||
VolumePending PersistentVolumePhase = "Pending"
|
||||
// used for PersistentVolumes that are not yet bound
|
||||
// Available volumes are held by the binder and matched to PersistentVolumeClaims
|
||||
VolumeAvailable PersistentVolumePhase = "Available"
|
||||
// used for PersistentVolumes that are bound
|
||||
VolumeBound PersistentVolumePhase = "Bound"
|
||||
// used for PersistentVolumes where the bound PersistentVolumeClaim was deleted
|
||||
// released volumes must be recycled before becoming available again
|
||||
// this phase is used by the persistent volume claim binder to signal to another process to reclaim the resource
|
||||
VolumeReleased PersistentVolumePhase = "Released"
|
||||
// used for PersistentVolumes that failed to be correctly recycled or deleted after being released from a claim
|
||||
VolumeFailed PersistentVolumePhase = "Failed"
|
||||
)
|
||||
|
||||
type PersistentVolumeClaimPhase string
|
||||
|
@@ -1216,6 +1216,7 @@ func convert_api_PersistentVolumeSpec_To_v1beta3_PersistentVolumeSpec(in *api.Pe
|
||||
} else {
|
||||
out.ClaimRef = nil
|
||||
}
|
||||
out.PersistentVolumeReclaimPolicy = PersistentVolumeReclaimPolicy(in.PersistentVolumeReclaimPolicy)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1224,6 +1225,8 @@ func convert_api_PersistentVolumeStatus_To_v1beta3_PersistentVolumeStatus(in *ap
|
||||
defaulting.(func(*api.PersistentVolumeStatus))(in)
|
||||
}
|
||||
out.Phase = PersistentVolumePhase(in.Phase)
|
||||
out.Message = in.Message
|
||||
out.Reason = in.Reason
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3305,6 +3308,7 @@ func convert_v1beta3_PersistentVolumeSpec_To_api_PersistentVolumeSpec(in *Persis
|
||||
} else {
|
||||
out.ClaimRef = nil
|
||||
}
|
||||
out.PersistentVolumeReclaimPolicy = api.PersistentVolumeReclaimPolicy(in.PersistentVolumeReclaimPolicy)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3313,6 +3317,8 @@ func convert_v1beta3_PersistentVolumeStatus_To_api_PersistentVolumeStatus(in *Pe
|
||||
defaulting.(func(*PersistentVolumeStatus))(in)
|
||||
}
|
||||
out.Phase = api.PersistentVolumePhase(in.Phase)
|
||||
out.Message = in.Message
|
||||
out.Reason = in.Reason
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@@ -1178,11 +1178,14 @@ func deepCopy_v1beta3_PersistentVolumeSpec(in PersistentVolumeSpec, out *Persist
|
||||
} else {
|
||||
out.ClaimRef = nil
|
||||
}
|
||||
out.PersistentVolumeReclaimPolicy = in.PersistentVolumeReclaimPolicy
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopy_v1beta3_PersistentVolumeStatus(in PersistentVolumeStatus, out *PersistentVolumeStatus, c *conversion.Cloner) error {
|
||||
out.Phase = in.Phase
|
||||
out.Message = in.Message
|
||||
out.Reason = in.Reason
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@@ -117,6 +117,9 @@ func addDefaultingFuncs() {
|
||||
if obj.Status.Phase == "" {
|
||||
obj.Status.Phase = VolumePending
|
||||
}
|
||||
if obj.Spec.PersistentVolumeReclaimPolicy == "" {
|
||||
obj.Spec.PersistentVolumeReclaimPolicy = PersistentVolumeReclaimRetain
|
||||
}
|
||||
},
|
||||
func(obj *PersistentVolumeClaim) {
|
||||
if obj.Status.Phase == "" {
|
||||
|
@@ -195,6 +195,9 @@ func TestSetDefaultPersistentVolume(t *testing.T) {
|
||||
if pv2.Status.Phase != versioned.VolumePending {
|
||||
t.Errorf("Expected volume phase %v, got %v", versioned.VolumePending, pv2.Status.Phase)
|
||||
}
|
||||
if pv2.Spec.PersistentVolumeReclaimPolicy != versioned.PersistentVolumeReclaimRetain {
|
||||
t.Errorf("Expected pv reclaim policy %v, got %v", versioned.PersistentVolumeReclaimRetain, pv2.Spec.PersistentVolumeReclaimPolicy)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDefaultPersistentVolumeClaim(t *testing.T) {
|
||||
|
@@ -280,11 +280,33 @@ type PersistentVolumeSpec struct {
|
||||
// ClaimRef is expected to be non-nil when bound.
|
||||
// claim.VolumeName is the authoritative bind between PV and PVC.
|
||||
ClaimRef *ObjectReference `json:"claimRef,omitempty" description:"when bound, a reference to the bound claim"`
|
||||
// Optional: what happens to a persistent volume when released from its claim.
|
||||
PersistentVolumeReclaimPolicy PersistentVolumeReclaimPolicy `json:"persistentVolumeReclaimPolicy,omitempty" description:"what happens to a volume when released from its claim; Valid options are Retain (default) and Recycle. Recyling must be supported by the volume plugin underlying this persistent volume."`
|
||||
}
|
||||
|
||||
// PersistentVolumeReclaimPolicy describes a policy for end-of-life maintenance of persistent volumes
|
||||
type PersistentVolumeReclaimPolicy string
|
||||
|
||||
const (
|
||||
// PersistentVolumeReclaimRecycle means the volume will be recycled back into the pool of unbound persistent volumes on release from its claim.
|
||||
// The volume plugin must support Recycling.
|
||||
PersistentVolumeReclaimRecycle PersistentVolumeReclaimPolicy = "Recycle"
|
||||
// PersistentVolumeReclaimDelete means the volume will be deleted from Kubernetes on release from its claim.
|
||||
// The volume plugin must support Deletion.
|
||||
// TODO: implement w/ DeletableVolumePlugin
|
||||
// PersistentVolumeReclaimDelete PersistentVolumeReclaimPolicy = "Delete"
|
||||
// PersistentVolumeReclaimRetain means the volume will left in its current phase (Released) for manual reclamation by the administrator.
|
||||
// The default policy is Retain.
|
||||
PersistentVolumeReclaimRetain PersistentVolumeReclaimPolicy = "Retain"
|
||||
)
|
||||
|
||||
type PersistentVolumeStatus struct {
|
||||
// Phase indicates if a volume is available, bound to a claim, or released by a claim
|
||||
Phase PersistentVolumePhase `json:"phase,omitempty" description:"the current phase of a persistent volume"`
|
||||
// A human-readable message indicating details about why the volume is in this state.
|
||||
Message string `json:"message,omitempty" description:"human-readable message indicating details about why the volume is in this state"`
|
||||
// Reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI
|
||||
Reason string `json:"reason,omitempty" description:"(brief) reason the volume is not is not available"`
|
||||
}
|
||||
|
||||
type PersistentVolumeList struct {
|
||||
@@ -348,12 +370,16 @@ const (
|
||||
// used for PersistentVolumes that are not available
|
||||
VolumePending PersistentVolumePhase = "Pending"
|
||||
// used for PersistentVolumes that are not yet bound
|
||||
// Available volumes are held by the binder and matched to PersistentVolumeClaims
|
||||
VolumeAvailable PersistentVolumePhase = "Available"
|
||||
// used for PersistentVolumes that are bound
|
||||
VolumeBound PersistentVolumePhase = "Bound"
|
||||
// used for PersistentVolumes where the bound PersistentVolumeClaim was deleted
|
||||
// released volumes must be recycled before becoming available again
|
||||
// this phase is used by the persistent volume claim binder to signal to another process to reclaim the resource
|
||||
VolumeReleased PersistentVolumePhase = "Released"
|
||||
// used for PersistentVolumes that failed to be correctly recycled or deleted after being released from a claim
|
||||
VolumeFailed PersistentVolumePhase = "Failed"
|
||||
)
|
||||
|
||||
type PersistentVolumeClaimPhase string
|
||||
|
Reference in New Issue
Block a user