From 6ed5aaa8937f29d20907e162b50fa17549bbc654 Mon Sep 17 00:00:00 2001 From: pritamdas99 Date: Thu, 1 Aug 2024 15:30:45 +0600 Subject: [PATCH] Add reconfigure ops api Signed-off-by: pritamdas99 --- apis/ops/v1alpha1/openapi_generated.go | 53 +++++++++++++++++++++- apis/ops/v1alpha1/solr_ops_types.go | 27 ++++++++++- apis/ops/v1alpha1/solr_ops_types_enum.go | 5 ++ apis/ops/v1alpha1/zz_generated.deepcopy.go | 33 ++++++++++++++ crds/ops.kubedb.com_solropsrequests.yaml | 17 +++++++ 5 files changed, 132 insertions(+), 3 deletions(-) diff --git a/apis/ops/v1alpha1/openapi_generated.go b/apis/ops/v1alpha1/openapi_generated.go index 2a7e2b4de5..14c7b5d0ee 100644 --- a/apis/ops/v1alpha1/openapi_generated.go +++ b/apis/ops/v1alpha1/openapi_generated.go @@ -666,6 +666,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/ops/v1alpha1.SinglestoreOpsRequestSpec": schema_apimachinery_apis_ops_v1alpha1_SinglestoreOpsRequestSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.SinglestoreVerticalScalingSpec": schema_apimachinery_apis_ops_v1alpha1_SinglestoreVerticalScalingSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.SinglestoreVolumeExpansionSpec": schema_apimachinery_apis_ops_v1alpha1_SinglestoreVolumeExpansionSpec(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.SolrCustomConfigurationSpec": schema_apimachinery_apis_ops_v1alpha1_SolrCustomConfigurationSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.SolrOpsRequest": schema_apimachinery_apis_ops_v1alpha1_SolrOpsRequest(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.SolrOpsRequestList": schema_apimachinery_apis_ops_v1alpha1_SolrOpsRequestList(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.SolrOpsRequestSpec": schema_apimachinery_apis_ops_v1alpha1_SolrOpsRequestSpec(ref), @@ -32284,6 +32285,50 @@ func schema_apimachinery_apis_ops_v1alpha1_SinglestoreVolumeExpansionSpec(ref co } } +func schema_apimachinery_apis_ops_v1alpha1_SolrCustomConfigurationSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SolrCustomConfigurationSpec is the spec for Reconfiguring the rabbitmq Settings", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "configSecret": { + SchemaProps: spec.SchemaProps{ + Description: "ConfigSecret is an optional field to provide custom configuration file for database.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "applyConfig": { + SchemaProps: spec.SchemaProps{ + Description: "ApplyConfig is an optional field to provide rabbitmq configuration. Provided configuration will be applied to config files stored in ConfigSecret. If the ConfigSecret is missing, the operator will create a new k8s secret by the following naming convention: {db-name}-user-config . Expected input format:\n\tapplyConfig:\n\t\trabbitmq.conf: |\n\t\t\tkey=value", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "removeCustomConfig": { + SchemaProps: spec.SchemaProps{ + Description: "If set to \"true\", the user provided configuration will be removed. The rabbitmq cluster will start will default configuration that is generated by the operator.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + func schema_apimachinery_apis_ops_v1alpha1_SolrOpsRequest(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -32425,6 +32470,12 @@ func schema_apimachinery_apis_ops_v1alpha1_SolrOpsRequestSpec(ref common.Referen Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.RestartSpec"), }, }, + "configuration": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies information necessary for custom configuration of rabbitmq", + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.SolrCustomConfigurationSpec"), + }, + }, "timeout": { SchemaProps: spec.SchemaProps{ Description: "Timeout for each step of the ops request in second. If a step doesn't finish within the specified timeout, the ops request will result in failure.", @@ -32443,7 +32494,7 @@ func schema_apimachinery_apis_ops_v1alpha1_SolrOpsRequestSpec(ref common.Referen }, }, Dependencies: []string{ - "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.Duration", "kubedb.dev/apimachinery/apis/ops/v1alpha1.RestartSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.SolrUpdateVersionSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.SolrVerticalScalingSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.SolrVolumeExpansionSpec"}, + "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.Duration", "kubedb.dev/apimachinery/apis/ops/v1alpha1.RestartSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.SolrCustomConfigurationSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.SolrUpdateVersionSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.SolrVerticalScalingSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.SolrVolumeExpansionSpec"}, } } diff --git a/apis/ops/v1alpha1/solr_ops_types.go b/apis/ops/v1alpha1/solr_ops_types.go index fdbb91b3b8..c8f10a3b83 100644 --- a/apis/ops/v1alpha1/solr_ops_types.go +++ b/apis/ops/v1alpha1/solr_ops_types.go @@ -49,8 +49,8 @@ type SolrOpsRequest struct { Status OpsRequestStatus `json:"status,omitempty"` } -// +kubebuilder:validation:Enum=UpdateVersion;VerticalScaling;VolumeExpansion;Restart -// ENUM(UpdateVersion, VerticalScaling, VolumeExpansion, Restart) +// +kubebuilder:validation:Enum=UpdateVersion;VerticalScaling;VolumeExpansion;Reconfigure;Restart +// ENUM(UpdateVersion, VerticalScaling, VolumeExpansion, Restart, Reconfigure) type SolrOpsRequestType string // DruidOpsRequestSpec is the spec for DruidOpsRequest @@ -67,6 +67,8 @@ type SolrOpsRequestSpec struct { VolumeExpansion *SolrVolumeExpansionSpec `json:"volumeExpansion,omitempty"` // Specifies information necessary for restarting database Restart *RestartSpec `json:"restart,omitempty"` + // Specifies information necessary for custom configuration of rabbitmq + Configuration *SolrCustomConfigurationSpec `json:"configuration,omitempty"` // Timeout for each step of the ops request in second. If a step doesn't finish within the specified timeout, the ops request will result in failure. Timeout *metav1.Duration `json:"timeout,omitempty"` // ApplyOption is to control the execution of OpsRequest depending on the database state. @@ -102,6 +104,27 @@ type SolrUpdateVersionSpec struct { TargetVersion string `json:"targetVersion,omitempty"` } +// SolrCustomConfigurationSpec is the spec for Reconfiguring the rabbitmq Settings +type SolrCustomConfigurationSpec struct { + // ConfigSecret is an optional field to provide custom configuration file for database. + // +optional + ConfigSecret *core.LocalObjectReference `json:"configSecret,omitempty"` + // ApplyConfig is an optional field to provide rabbitmq configuration. + // Provided configuration will be applied to config files stored in ConfigSecret. + // If the ConfigSecret is missing, the operator will create a new k8s secret by the + // following naming convention: {db-name}-user-config . + // Expected input format: + // applyConfig: + // rabbitmq.conf: | + // key=value + // +optional + ApplyConfig map[string]string `json:"applyConfig,omitempty"` + // If set to "true", the user provided configuration will be removed. + // The rabbitmq cluster will start will default configuration that is generated by the operator. + // +optional + RemoveCustomConfig bool `json:"removeCustomConfig,omitempty"` +} + // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // SolrOpsRequestList is a list of DruidOpsRequests diff --git a/apis/ops/v1alpha1/solr_ops_types_enum.go b/apis/ops/v1alpha1/solr_ops_types_enum.go index 68111bdbee..cb9c5766a3 100644 --- a/apis/ops/v1alpha1/solr_ops_types_enum.go +++ b/apis/ops/v1alpha1/solr_ops_types_enum.go @@ -20,6 +20,8 @@ const ( SolrOpsRequestTypeVolumeExpansion SolrOpsRequestType = "VolumeExpansion" // SolrOpsRequestTypeRestart is a SolrOpsRequestType of type Restart. SolrOpsRequestTypeRestart SolrOpsRequestType = "Restart" + // SolrOpsRequestTypeReconfigure is a SolrOpsRequestType of type Reconfigure. + SolrOpsRequestTypeReconfigure SolrOpsRequestType = "Reconfigure" ) var ErrInvalidSolrOpsRequestType = fmt.Errorf("not a valid SolrOpsRequestType, try [%s]", strings.Join(_SolrOpsRequestTypeNames, ", ")) @@ -29,6 +31,7 @@ var _SolrOpsRequestTypeNames = []string{ string(SolrOpsRequestTypeVerticalScaling), string(SolrOpsRequestTypeVolumeExpansion), string(SolrOpsRequestTypeRestart), + string(SolrOpsRequestTypeReconfigure), } // SolrOpsRequestTypeNames returns a list of possible string values of SolrOpsRequestType. @@ -45,6 +48,7 @@ func SolrOpsRequestTypeValues() []SolrOpsRequestType { SolrOpsRequestTypeVerticalScaling, SolrOpsRequestTypeVolumeExpansion, SolrOpsRequestTypeRestart, + SolrOpsRequestTypeReconfigure, } } @@ -65,6 +69,7 @@ var _SolrOpsRequestTypeValue = map[string]SolrOpsRequestType{ "VerticalScaling": SolrOpsRequestTypeVerticalScaling, "VolumeExpansion": SolrOpsRequestTypeVolumeExpansion, "Restart": SolrOpsRequestTypeRestart, + "Reconfigure": SolrOpsRequestTypeReconfigure, } // ParseSolrOpsRequestType attempts to convert a string to a SolrOpsRequestType. diff --git a/apis/ops/v1alpha1/zz_generated.deepcopy.go b/apis/ops/v1alpha1/zz_generated.deepcopy.go index 46e36395e0..572bf734d0 100644 --- a/apis/ops/v1alpha1/zz_generated.deepcopy.go +++ b/apis/ops/v1alpha1/zz_generated.deepcopy.go @@ -5198,6 +5198,34 @@ func (in *SinglestoreVolumeExpansionSpec) DeepCopy() *SinglestoreVolumeExpansion return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SolrCustomConfigurationSpec) DeepCopyInto(out *SolrCustomConfigurationSpec) { + *out = *in + if in.ConfigSecret != nil { + in, out := &in.ConfigSecret, &out.ConfigSecret + *out = new(corev1.LocalObjectReference) + **out = **in + } + if in.ApplyConfig != nil { + in, out := &in.ApplyConfig, &out.ApplyConfig + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SolrCustomConfigurationSpec. +func (in *SolrCustomConfigurationSpec) DeepCopy() *SolrCustomConfigurationSpec { + if in == nil { + return nil + } + out := new(SolrCustomConfigurationSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SolrOpsRequest) DeepCopyInto(out *SolrOpsRequest) { *out = *in @@ -5283,6 +5311,11 @@ func (in *SolrOpsRequestSpec) DeepCopyInto(out *SolrOpsRequestSpec) { *out = new(RestartSpec) **out = **in } + if in.Configuration != nil { + in, out := &in.Configuration, &out.Configuration + *out = new(SolrCustomConfigurationSpec) + (*in).DeepCopyInto(*out) + } if in.Timeout != nil { in, out := &in.Timeout, &out.Timeout *out = new(v1.Duration) diff --git a/crds/ops.kubedb.com_solropsrequests.yaml b/crds/ops.kubedb.com_solropsrequests.yaml index 6ffb1b376e..daa371cc5b 100644 --- a/crds/ops.kubedb.com_solropsrequests.yaml +++ b/crds/ops.kubedb.com_solropsrequests.yaml @@ -48,6 +48,22 @@ spec: - IfReady - Always type: string + configuration: + properties: + applyConfig: + additionalProperties: + type: string + type: object + configSecret: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + removeCustomConfig: + type: boolean + type: object databaseRef: properties: name: @@ -64,6 +80,7 @@ spec: - UpdateVersion - VerticalScaling - VolumeExpansion + - Reconfigure - Restart type: string updateVersion: