Selector in VolumeGroupSnapshotSource API should be optional
This commit is contained in:
@@ -52,8 +52,8 @@ type VolumeGroupSnapshotSource struct {
|
|||||||
// is created, the existing group snapshots won't be modified.
|
// is created, the existing group snapshots won't be modified.
|
||||||
// Once a VolumeGroupSnapshotContent is created and the sidecar starts to process
|
// Once a VolumeGroupSnapshotContent is created and the sidecar starts to process
|
||||||
// it, the volume list will not change with retries.
|
// it, the volume list will not change with retries.
|
||||||
// Required.
|
// +optional
|
||||||
Selector metav1.LabelSelector `json:"selector" protobuf:"bytes,1,opt,name=selector"`
|
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,1,opt,name=selector"`
|
||||||
|
|
||||||
// VolumeGroupSnapshotContentName specifies the name of a pre-existing VolumeGroupSnapshotContent
|
// VolumeGroupSnapshotContentName specifies the name of a pre-existing VolumeGroupSnapshotContent
|
||||||
// object representing an existing volume group snapshot.
|
// object representing an existing volume group snapshot.
|
||||||
|
@@ -24,6 +24,7 @@ package v1alpha1
|
|||||||
import (
|
import (
|
||||||
v1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
|
v1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -337,7 +338,11 @@ func (in *VolumeGroupSnapshotList) DeepCopyObject() runtime.Object {
|
|||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *VolumeGroupSnapshotSource) DeepCopyInto(out *VolumeGroupSnapshotSource) {
|
func (in *VolumeGroupSnapshotSource) DeepCopyInto(out *VolumeGroupSnapshotSource) {
|
||||||
*out = *in
|
*out = *in
|
||||||
in.Selector.DeepCopyInto(&out.Selector)
|
if in.Selector != nil {
|
||||||
|
in, out := &in.Selector, &out.Selector
|
||||||
|
*out = new(metav1.LabelSelector)
|
||||||
|
(*in).DeepCopyInto(*out)
|
||||||
|
}
|
||||||
if in.VolumeGroupSnapshotContentName != nil {
|
if in.VolumeGroupSnapshotContentName != nil {
|
||||||
in, out := &in.VolumeGroupSnapshotContentName, &out.VolumeGroupSnapshotContentName
|
in, out := &in.VolumeGroupSnapshotContentName, &out.VolumeGroupSnapshotContentName
|
||||||
*out = new(string)
|
*out = new(string)
|
||||||
|
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
|
|||||||
kind: CustomResourceDefinition
|
kind: CustomResourceDefinition
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/814"
|
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/995"
|
||||||
controller-gen.kubebuilder.io/version: v0.12.0
|
controller-gen.kubebuilder.io/version: v0.12.0
|
||||||
creationTimestamp: null
|
creationTimestamp: null
|
||||||
name: volumegroupsnapshots.groupsnapshot.storage.k8s.io
|
name: volumegroupsnapshots.groupsnapshot.storage.k8s.io
|
||||||
@@ -78,7 +78,6 @@ spec:
|
|||||||
is created, the existing group snapshots won't be modified.
|
is created, the existing group snapshots won't be modified.
|
||||||
Once a VolumeGroupSnapshotContent is created and the sidecar
|
Once a VolumeGroupSnapshotContent is created and the sidecar
|
||||||
starts to process it, the volume list will not change with retries.
|
starts to process it, the volume list will not change with retries.
|
||||||
Required.
|
|
||||||
properties:
|
properties:
|
||||||
matchExpressions:
|
matchExpressions:
|
||||||
description: matchExpressions is a list of label selector
|
description: matchExpressions is a list of label selector
|
||||||
@@ -129,8 +128,6 @@ spec:
|
|||||||
if the volume group snapshot already exists and only needs a
|
if the volume group snapshot already exists and only needs a
|
||||||
representation in Kubernetes. This field is immutable.
|
representation in Kubernetes. This field is immutable.
|
||||||
type: string
|
type: string
|
||||||
required:
|
|
||||||
- selector
|
|
||||||
type: object
|
type: object
|
||||||
volumeGroupSnapshotClassName:
|
volumeGroupSnapshotClassName:
|
||||||
description: VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass
|
description: VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass
|
||||||
|
@@ -295,8 +295,8 @@ func (ctrl *csiSnapshotCommonController) syncGroupSnapshot(groupSnapshot *crdv1a
|
|||||||
}
|
}
|
||||||
// Keep this check in the controller since the validation webhook may not have been deployed.
|
// Keep this check in the controller since the validation webhook may not have been deployed.
|
||||||
klog.V(5).Infof("syncGroupSnapshot[%s]: validate group snapshot to make sure source has been correctly specified", utils.GroupSnapshotKey(groupSnapshot))
|
klog.V(5).Infof("syncGroupSnapshot[%s]: validate group snapshot to make sure source has been correctly specified", utils.GroupSnapshotKey(groupSnapshot))
|
||||||
if (&groupSnapshot.Spec.Source.Selector == nil && groupSnapshot.Spec.Source.VolumeGroupSnapshotContentName == nil) ||
|
if (groupSnapshot.Spec.Source.Selector == nil && groupSnapshot.Spec.Source.VolumeGroupSnapshotContentName == nil) ||
|
||||||
(&groupSnapshot.Spec.Source.Selector != nil && groupSnapshot.Spec.Source.VolumeGroupSnapshotContentName != nil) {
|
(groupSnapshot.Spec.Source.Selector != nil && groupSnapshot.Spec.Source.VolumeGroupSnapshotContentName != nil) {
|
||||||
err := fmt.Errorf("Exactly one of Selector and VolumeGroupSnapshotContentName should be specified")
|
err := fmt.Errorf("Exactly one of Selector and VolumeGroupSnapshotContentName should be specified")
|
||||||
klog.Errorf("syncGroupSnapshot[%s]: validation error, %s", utils.GroupSnapshotKey(groupSnapshot), err.Error())
|
klog.Errorf("syncGroupSnapshot[%s]: validation error, %s", utils.GroupSnapshotKey(groupSnapshot), err.Error())
|
||||||
ctrl.updateGroupSnapshotErrorStatusWithEvent(groupSnapshot, true, v1.EventTypeWarning, "GroupSnapshotValidationError", err.Error())
|
ctrl.updateGroupSnapshotErrorStatusWithEvent(groupSnapshot, true, v1.EventTypeWarning, "GroupSnapshotValidationError", err.Error())
|
||||||
|
@@ -90,7 +90,7 @@ func TestAdmitVolumeGroupSnapshotV1Alpha1(t *testing.T) {
|
|||||||
volumeGroupSnapshot: &volumegroupsnapshotv1alpha1.VolumeGroupSnapshot{
|
volumeGroupSnapshot: &volumegroupsnapshotv1alpha1.VolumeGroupSnapshot{
|
||||||
Spec: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSpec{
|
Spec: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSpec{
|
||||||
Source: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSource{
|
Source: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSource{
|
||||||
Selector: selector,
|
Selector: &selector,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -172,13 +172,13 @@ func TestAdmitVolumeGroupSnapshotV1Alpha1(t *testing.T) {
|
|||||||
Spec: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSpec{
|
Spec: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSpec{
|
||||||
Source: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSource{
|
Source: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSource{
|
||||||
VolumeGroupSnapshotContentName: &contentname,
|
VolumeGroupSnapshotContentName: &contentname,
|
||||||
Selector: selector,
|
Selector: &selector,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
shouldAdmit: false,
|
shouldAdmit: false,
|
||||||
operation: v1.Update,
|
operation: v1.Update,
|
||||||
msg: fmt.Sprintf("Spec.Source.Selector is immutable but was changed from %v to %v", selector, metav1.LabelSelector{}),
|
msg: fmt.Sprintf("Spec.Source.Selector is immutable but was changed from %v to %v", &selector, "nil"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// will be handled by schema validation
|
// will be handled by schema validation
|
||||||
@@ -187,7 +187,7 @@ func TestAdmitVolumeGroupSnapshotV1Alpha1(t *testing.T) {
|
|||||||
Spec: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSpec{
|
Spec: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSpec{
|
||||||
Source: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSource{
|
Source: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSource{
|
||||||
VolumeGroupSnapshotContentName: &contentname,
|
VolumeGroupSnapshotContentName: &contentname,
|
||||||
Selector: selector,
|
Selector: &selector,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -195,7 +195,7 @@ func TestAdmitVolumeGroupSnapshotV1Alpha1(t *testing.T) {
|
|||||||
Spec: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSpec{
|
Spec: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSpec{
|
||||||
Source: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSource{
|
Source: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotSource{
|
||||||
VolumeGroupSnapshotContentName: &contentname,
|
VolumeGroupSnapshotContentName: &contentname,
|
||||||
Selector: selector,
|
Selector: &selector,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -52,8 +52,8 @@ type VolumeGroupSnapshotSource struct {
|
|||||||
// is created, the existing group snapshots won't be modified.
|
// is created, the existing group snapshots won't be modified.
|
||||||
// Once a VolumeGroupSnapshotContent is created and the sidecar starts to process
|
// Once a VolumeGroupSnapshotContent is created and the sidecar starts to process
|
||||||
// it, the volume list will not change with retries.
|
// it, the volume list will not change with retries.
|
||||||
// Required.
|
// +optional
|
||||||
Selector metav1.LabelSelector `json:"selector" protobuf:"bytes,1,opt,name=selector"`
|
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,1,opt,name=selector"`
|
||||||
|
|
||||||
// VolumeGroupSnapshotContentName specifies the name of a pre-existing VolumeGroupSnapshotContent
|
// VolumeGroupSnapshotContentName specifies the name of a pre-existing VolumeGroupSnapshotContent
|
||||||
// object representing an existing volume group snapshot.
|
// object representing an existing volume group snapshot.
|
||||||
|
@@ -24,6 +24,7 @@ package v1alpha1
|
|||||||
import (
|
import (
|
||||||
v1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
|
v1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -337,7 +338,11 @@ func (in *VolumeGroupSnapshotList) DeepCopyObject() runtime.Object {
|
|||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *VolumeGroupSnapshotSource) DeepCopyInto(out *VolumeGroupSnapshotSource) {
|
func (in *VolumeGroupSnapshotSource) DeepCopyInto(out *VolumeGroupSnapshotSource) {
|
||||||
*out = *in
|
*out = *in
|
||||||
in.Selector.DeepCopyInto(&out.Selector)
|
if in.Selector != nil {
|
||||||
|
in, out := &in.Selector, &out.Selector
|
||||||
|
*out = new(metav1.LabelSelector)
|
||||||
|
(*in).DeepCopyInto(*out)
|
||||||
|
}
|
||||||
if in.VolumeGroupSnapshotContentName != nil {
|
if in.VolumeGroupSnapshotContentName != nil {
|
||||||
in, out := &in.VolumeGroupSnapshotContentName, &out.VolumeGroupSnapshotContentName
|
in, out := &in.VolumeGroupSnapshotContentName, &out.VolumeGroupSnapshotContentName
|
||||||
*out = new(string)
|
*out = new(string)
|
||||||
|
Reference in New Issue
Block a user