From fd6ae456fb485a96ac6d4c604143bc87f7db5b04 Mon Sep 17 00:00:00 2001 From: Eric Cao Date: Mon, 23 Sep 2024 14:13:22 -0700 Subject: [PATCH] Include state info to content library resource status Content Library storage migration support introduces the state info on the Content Library API, which shows the current library state. The library state may change to `Maintenance` when the library is being storage migrated to a different datastore, in which case some library content operations may not work (NotAllowedInCurrentState error will be thrown on relevant operations, i.e. item delete, item import from URL, VM publishing, etc.). This change exposes the state info on the content library status for visibility. Testing Done: all make targets pass. --- api/v1alpha1/contentlibrary_types.go | 23 +++++++++++++++++++++++ api/v1alpha1/zz_generated.deepcopy.go | 20 ++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/api/v1alpha1/contentlibrary_types.go b/api/v1alpha1/contentlibrary_types.go index 8f6833b..e20c7ac 100644 --- a/api/v1alpha1/contentlibrary_types.go +++ b/api/v1alpha1/contentlibrary_types.go @@ -31,6 +31,19 @@ const ( StorageBackingTypeOther StorageBackingType = "Other" ) +// State is a constant type that indicates the current state of a content library in vCenter. +type State string + +const ( + // StateActive indicates the library state when the library is fully functional, this is the default library state + // when a library is created. + StateActive State = "Active" + + // StateMaintenance indicates the library state when the library is in migration. Content from the library may not + // be accessible and operations mutating library content will be disallowed in this state. + StateMaintenance State = "Maintenance" +) + // StorageBacking describes the default storage backing which is available for the library. type StorageBacking struct { // Type indicates the type of storage where the content would be stored. @@ -86,6 +99,12 @@ type PublishInfo struct { URL string `json:"URL"` } +// StateInfo provides the information about the state of a content library. +type StateInfo struct { + // State indicates the state of this library. + State State `json:"state"` +} + // ContentLibrarySpec defines the desired state of a ContentLibrary. type ContentLibrarySpec struct { // UUID is the identifier which uniquely identifies the library in vCenter. This field is immutable. @@ -146,6 +165,10 @@ type ContentLibraryStatus struct { // +optional SecurityPolicyID string `json:"securityPolicyID,omitempty"` + // StateInfo provides the state information of this library. + // +optional + StateInfo *StateInfo `json:"stateInfo,omitempty"` + // ServerGUID indicates the unique identifier of the vCenter server where the library exists. // +optional ServerGUID string `json:"serverGUID,omitempty"` diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index f29c83c..4f4f35c 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -619,6 +619,11 @@ func (in *ContentLibraryStatus) DeepCopyInto(out *ContentLibraryStatus) { *out = new(SubscriptionInfo) **out = **in } + if in.StateInfo != nil { + in, out := &in.StateInfo, &out.StateInfo + *out = new(StateInfo) + **out = **in + } in.CreationTime.DeepCopyInto(&out.CreationTime) in.LastModifiedTime.DeepCopyInto(&out.LastModifiedTime) in.LastSyncTime.DeepCopyInto(&out.LastSyncTime) @@ -727,6 +732,21 @@ func (in *PublishInfo) DeepCopy() *PublishInfo { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StateInfo) DeepCopyInto(out *StateInfo) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StateInfo. +func (in *StateInfo) DeepCopy() *StateInfo { + if in == nil { + return nil + } + out := new(StateInfo) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StorageBacking) DeepCopyInto(out *StorageBacking) { *out = *in