Refactor snapshot error to utils.go

This commit is contained in:
Raunak Pradip Shah
2023-03-01 11:29:13 +05:30
parent 9ce31d0bf8
commit 69b054d1ed
33 changed files with 137 additions and 243 deletions

17
client/apis/utils.go Normal file
View File

@@ -0,0 +1,17 @@
package apis
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// VolumeSnapshotError describes an error encountered during snapshot creation.
type VolumeSnapshotError struct {
// time is the timestamp when the error was encountered.
// +optional
Time *metav1.Time `json:"time,omitempty" protobuf:"bytes,1,opt,name=time"`
// message is a string detailing the encountered error during snapshot
// creation if specified.
// NOTE: message may be logged, and it should not contain sensitive
// information.
// +optional
Message *string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
}

View File

@@ -19,6 +19,8 @@ package v1alpha1
import (
core_v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/kubernetes-csi/external-snapshotter/client/v6/apis"
)
// VolumeGroupSnapshotSpec defines the desired state of VolumeGroupSnapshot
@@ -74,7 +76,7 @@ type VolumeGroupSnapshotStatus struct {
// The snapshot controller will keep retrying when an error occurs during the
// group snapshot creation. Upon success, this error field will be cleared.
// +optional
Error *VolumeGroupSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeGroupSnapshotError"`
Error *apis.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"`
// VolumeSnapshotRefList is the list of volume snapshot references for this
// group snapshot.
@@ -269,7 +271,7 @@ type VolumeGroupSnapshotContentStatus struct {
// Error is the last observed error during group snapshot creation, if any.
// Upon success after retry, this error field will be cleared.
// +optional
Error *VolumeGroupSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeGroupSnapshotError"`
Error *apis.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"`
// VolumeSnapshotContentRefList is the list of volume snapshot content references
// for this group snapshot.
@@ -295,17 +297,3 @@ type VolumeGroupSnapshotContentSource struct {
// +optional
VolumeGroupSnapshotHandle *string `json:"volumeGroupSnapshotHandle,omitempty" protobuf:"bytes,2,opt,name=volumeGroupSnapshotHandle"`
}
// VolumeGroupSnapshotError describes an error encountered during group snapshot creation.
type VolumeGroupSnapshotError struct {
// Time is the timestamp when the error was encountered.
// +optional
Time *metav1.Time `json:"time,omitempty" protobuf:"bytes,1,opt,name=time"`
// Message is a string detailing the encountered error during snapshot
// creation if specified.
// NOTE: message may be logged, and it should not contain sensitive
// information.
// +optional
Message *string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
}

View File

@@ -22,6 +22,7 @@ limitations under the License.
package v1alpha1
import (
apis "github.com/kubernetes-csi/external-snapshotter/client/v6/apis"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
@@ -256,7 +257,7 @@ func (in *VolumeGroupSnapshotContentStatus) DeepCopyInto(out *VolumeGroupSnapsho
}
if in.Error != nil {
in, out := &in.Error, &out.Error
*out = new(VolumeGroupSnapshotError)
*out = new(apis.VolumeSnapshotError)
(*in).DeepCopyInto(*out)
}
if in.VolumeSnapshotContentRefList != nil {
@@ -277,31 +278,6 @@ func (in *VolumeGroupSnapshotContentStatus) DeepCopy() *VolumeGroupSnapshotConte
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *VolumeGroupSnapshotError) DeepCopyInto(out *VolumeGroupSnapshotError) {
*out = *in
if in.Time != nil {
in, out := &in.Time, &out.Time
*out = (*in).DeepCopy()
}
if in.Message != nil {
in, out := &in.Message, &out.Message
*out = new(string)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeGroupSnapshotError.
func (in *VolumeGroupSnapshotError) DeepCopy() *VolumeGroupSnapshotError {
if in == nil {
return nil
}
out := new(VolumeGroupSnapshotError)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *VolumeGroupSnapshotList) DeepCopyInto(out *VolumeGroupSnapshotList) {
*out = *in
@@ -380,7 +356,7 @@ func (in *VolumeGroupSnapshotStatus) DeepCopyInto(out *VolumeGroupSnapshotStatus
}
if in.Error != nil {
in, out := &in.Error, &out.Error
*out = new(VolumeGroupSnapshotError)
*out = new(apis.VolumeSnapshotError)
(*in).DeepCopyInto(*out)
}
if in.VolumeSnapshotRefList != nil {

View File

@@ -21,6 +21,8 @@ import (
core_v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/kubernetes-csi/external-snapshotter/client/v6/apis"
)
// +genclient
@@ -182,7 +184,7 @@ type VolumeSnapshotStatus struct {
// The snapshot controller will keep retrying when an error occurs during the
// snapshot creation. Upon success, this error field will be cleared.
// +optional
Error *VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,5,opt,name=error,casttype=VolumeSnapshotError"`
Error *apis.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,5,opt,name=error,casttype=VolumeSnapshotError"`
// VolumeGroupSnapshotName is the name of the VolumeGroupSnapshot of which this
// VolumeSnapshot is a part of.
@@ -419,7 +421,7 @@ type VolumeSnapshotContentStatus struct {
// error is the last observed error during snapshot creation, if any.
// Upon success after retry, this error field will be cleared.
// +optional
Error *VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,5,opt,name=error,casttype=VolumeSnapshotError"`
Error *apis.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,5,opt,name=error,casttype=VolumeSnapshotError"`
// VolumeGroupSnapshotContentName is the name of the VolumeGroupSnapshotContent of
// which this VolumeSnapshotContent is a part of.
@@ -440,17 +442,3 @@ const (
// state on release from its volume snapshot.
VolumeSnapshotContentRetain DeletionPolicy = "Retain"
)
// VolumeSnapshotError describes an error encountered during snapshot creation.
type VolumeSnapshotError struct {
// time is the timestamp when the error was encountered.
// +optional
Time *metav1.Time `json:"time,omitempty" protobuf:"bytes,1,opt,name=time"`
// message is a string detailing the encountered error during snapshot
// creation if specified.
// NOTE: message may be logged, and it should not contain sensitive
// information.
// +optional
Message *string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
}

View File

@@ -22,6 +22,7 @@ limitations under the License.
package v1
import (
apis "github.com/kubernetes-csi/external-snapshotter/client/v6/apis"
corev1 "k8s.io/api/core/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)
@@ -268,7 +269,7 @@ func (in *VolumeSnapshotContentStatus) DeepCopyInto(out *VolumeSnapshotContentSt
}
if in.Error != nil {
in, out := &in.Error, &out.Error
*out = new(VolumeSnapshotError)
*out = new(apis.VolumeSnapshotError)
(*in).DeepCopyInto(*out)
}
if in.VolumeGroupSnapshotContentName != nil {
@@ -289,31 +290,6 @@ func (in *VolumeSnapshotContentStatus) DeepCopy() *VolumeSnapshotContentStatus {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *VolumeSnapshotError) DeepCopyInto(out *VolumeSnapshotError) {
*out = *in
if in.Time != nil {
in, out := &in.Time, &out.Time
*out = (*in).DeepCopy()
}
if in.Message != nil {
in, out := &in.Message, &out.Message
*out = new(string)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotError.
func (in *VolumeSnapshotError) DeepCopy() *VolumeSnapshotError {
if in == nil {
return nil
}
out := new(VolumeSnapshotError)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *VolumeSnapshotList) DeepCopyInto(out *VolumeSnapshotList) {
*out = *in
@@ -419,7 +395,7 @@ func (in *VolumeSnapshotStatus) DeepCopyInto(out *VolumeSnapshotStatus) {
}
if in.Error != nil {
in, out := &in.Error, &out.Error
*out = new(VolumeSnapshotError)
*out = new(apis.VolumeSnapshotError)
(*in).DeepCopyInto(*out)
}
if in.VolumeGroupSnapshotName != nil {

View File

@@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/814"
creationTimestamp: null
name: volumegroupsnapshotclasses.groupsnapshot.storage.k8s.io
spec:

View File

@@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/814"
creationTimestamp: null
name: volumegroupsnapshotcontents.groupsnapshot.storage.k8s.io
spec:

View File

@@ -4,6 +4,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/814"
creationTimestamp: null
name: volumegroupsnapshots.groupsnapshot.storage.k8s.io
spec: