diff --git a/apis/kubedb/v1alpha1/conversion.go b/apis/kubedb/v1alpha1/conversion.go index b5a0a2b13f..f08f5ed43f 100644 --- a/apis/kubedb/v1alpha1/conversion.go +++ b/apis/kubedb/v1alpha1/conversion.go @@ -134,7 +134,7 @@ func Convert_v1alpha1_ElasticsearchSpec_To_v1alpha2_ElasticsearchSpec(in *Elasti } out.MaxUnavailable = (*intstr.IntOrString)(unsafe.Pointer(in.MaxUnavailable)) // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -280,7 +280,7 @@ func Convert_v1alpha1_EtcdSpec_To_v1alpha2_EtcdSpec(in *EtcdSpec, out *v1alpha2. }) } // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.DeletionPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.DeletionPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -365,7 +365,7 @@ func Convert_v1alpha1_MariaDBSpec_To_v1alpha2_MariaDBSpec(in *MariaDBSpec, out * }) } // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -434,7 +434,7 @@ func Convert_v1alpha1_MemcachedSpec_To_v1alpha2_MemcachedSpec(in *MemcachedSpec, }) } // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -537,7 +537,7 @@ func Convert_v1alpha1_MongoDBSpec_To_v1alpha2_MongoDBSpec(in *MongoDBSpec, out * }) } // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -722,7 +722,7 @@ func Convert_v1alpha1_MySQLSpec_To_v1alpha2_MySQLSpec(in *MySQLSpec, out *v1alph }) } // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -834,7 +834,7 @@ func Convert_v1alpha1_PerconaXtraDBSpec_To_v1alpha2_PerconaXtraDBSpec(in *Percon }) } // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -932,7 +932,7 @@ func Convert_v1alpha1_PostgresSpec_To_v1alpha2_PostgresSpec(in *PostgresSpec, ou }) } // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -1005,7 +1005,7 @@ func Convert_v1alpha1_RedisSpec_To_v1alpha2_RedisSpec(in *RedisSpec, out *v1alph }) } // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } diff --git a/apis/kubedb/v1alpha1/zz_generated.conversion.go b/apis/kubedb/v1alpha1/zz_generated.conversion.go index 5202c5cc83..9157509f6d 100644 --- a/apis/kubedb/v1alpha1/zz_generated.conversion.go +++ b/apis/kubedb/v1alpha1/zz_generated.conversion.go @@ -738,7 +738,7 @@ func autoConvert_v1alpha1_ElasticsearchSpec_To_v1alpha2_ElasticsearchSpec(in *El // WARNING: in.ServiceTemplate requires manual conversion: does not exist in peer-type out.MaxUnavailable = (*intstr.IntOrString)(unsafe.Pointer(in.MaxUnavailable)) // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -896,7 +896,7 @@ func autoConvert_v1alpha1_EtcdSpec_To_v1alpha2_EtcdSpec(in *EtcdSpec, out *v1alp out.PodTemplate = in.PodTemplate // WARNING: in.ServiceTemplate requires manual conversion: does not exist in peer-type // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.DeletionPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.DeletionPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -1048,7 +1048,7 @@ func autoConvert_v1alpha1_MariaDBSpec_To_v1alpha2_MariaDBSpec(in *MariaDBSpec, o out.PodTemplate = in.PodTemplate // WARNING: in.ServiceTemplate requires manual conversion: does not exist in peer-type // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -1202,7 +1202,7 @@ func autoConvert_v1alpha1_MemcachedSpec_To_v1alpha2_MemcachedSpec(in *MemcachedS out.PodTemplate = in.PodTemplate // WARNING: in.ServiceTemplate requires manual conversion: does not exist in peer-type // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -1484,7 +1484,7 @@ func autoConvert_v1alpha1_MongoDBSpec_To_v1alpha2_MongoDBSpec(in *MongoDBSpec, o out.PodTemplate = (*offshootapiapiv1.PodTemplateSpec)(unsafe.Pointer(in.PodTemplate)) // WARNING: in.ServiceTemplate requires manual conversion: does not exist in peer-type // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -1679,7 +1679,7 @@ func autoConvert_v1alpha1_MySQLSpec_To_v1alpha2_MySQLSpec(in *MySQLSpec, out *v1 out.PodTemplate = in.PodTemplate // WARNING: in.ServiceTemplate requires manual conversion: does not exist in peer-type // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -1870,7 +1870,7 @@ func autoConvert_v1alpha1_PerconaXtraDBSpec_To_v1alpha2_PerconaXtraDBSpec(in *Pe out.PodTemplate = in.PodTemplate // WARNING: in.ServiceTemplate requires manual conversion: does not exist in peer-type // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -2028,7 +2028,7 @@ func autoConvert_v1alpha1_PostgresSpec_To_v1alpha2_PostgresSpec(in *PostgresSpec // WARNING: in.ServiceTemplate requires manual conversion: does not exist in peer-type // WARNING: in.ReplicaServiceTemplate requires manual conversion: does not exist in peer-type // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } @@ -2224,7 +2224,7 @@ func autoConvert_v1alpha1_RedisSpec_To_v1alpha2_RedisSpec(in *RedisSpec, out *v1 out.PodTemplate = in.PodTemplate // WARNING: in.ServiceTemplate requires manual conversion: does not exist in peer-type // WARNING: in.UpdateStrategy requires manual conversion: does not exist in peer-type - out.TerminationPolicy = v1alpha2.TerminationPolicy(in.TerminationPolicy) + out.TerminationPolicy = v1alpha2.DeletionPolicy(in.TerminationPolicy) return nil } diff --git a/apis/kubedb/v1alpha2/cassandra_helpers.go b/apis/kubedb/v1alpha2/cassandra_helpers.go index c9774862ae..95e1e2418c 100644 --- a/apis/kubedb/v1alpha2/cassandra_helpers.go +++ b/apis/kubedb/v1alpha2/cassandra_helpers.go @@ -269,7 +269,7 @@ func (r *Cassandra) ResourceSingular() string { func (r *Cassandra) SetDefaults() { if r.Spec.DeletionPolicy == "" { - r.Spec.DeletionPolicy = TerminationPolicyDelete + r.Spec.DeletionPolicy = DeletionPolicyDelete } var casVersion catalog.CassandraVersion diff --git a/apis/kubedb/v1alpha2/cassandra_types.go b/apis/kubedb/v1alpha2/cassandra_types.go index 0ff02c71cd..8a4d06c5a8 100644 --- a/apis/kubedb/v1alpha2/cassandra_types.go +++ b/apis/kubedb/v1alpha2/cassandra_types.go @@ -97,7 +97,7 @@ type CassandraSpec struct { // DeletionPolicy controls the delete operation for database // +optional - DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` + DeletionPolicy DeletionPolicy `json:"deletionPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional diff --git a/apis/kubedb/v1alpha2/cassandra_webhook.go b/apis/kubedb/v1alpha2/cassandra_webhook.go index a948bfa7d1..8488cefec4 100644 --- a/apis/kubedb/v1alpha2/cassandra_webhook.go +++ b/apis/kubedb/v1alpha2/cassandra_webhook.go @@ -69,7 +69,7 @@ func (r *Cassandra) ValidateDelete() (admission.Warnings, error) { cassandralog.Info("validate delete", "name", r.Name) var allErr field.ErrorList - if r.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { + if r.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("deletionPolicy"), r.Name, "Can not delete as terminationPolicy is set to \"DoNotTerminate\"")) diff --git a/apis/kubedb/v1alpha2/clickhouse_helpers.go b/apis/kubedb/v1alpha2/clickhouse_helpers.go index 2715e6d165..6dfabdd6ff 100644 --- a/apis/kubedb/v1alpha2/clickhouse_helpers.go +++ b/apis/kubedb/v1alpha2/clickhouse_helpers.go @@ -370,7 +370,7 @@ func (c *ClickHouse) SetDefaults() { c.Spec.Replicas = pointer.Int32P(1) } if c.Spec.DeletionPolicy == "" { - c.Spec.DeletionPolicy = TerminationPolicyDelete + c.Spec.DeletionPolicy = DeletionPolicyDelete } if c.Spec.StorageType == "" { c.Spec.StorageType = StorageTypeDurable diff --git a/apis/kubedb/v1alpha2/clickhouse_types.go b/apis/kubedb/v1alpha2/clickhouse_types.go index cd91574bf6..1dfa0f93cd 100644 --- a/apis/kubedb/v1alpha2/clickhouse_types.go +++ b/apis/kubedb/v1alpha2/clickhouse_types.go @@ -101,7 +101,7 @@ type ClickHouseSpec struct { // DeletionPolicy controls the delete operation for database // +optional - DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` + DeletionPolicy DeletionPolicy `json:"deletionPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional diff --git a/apis/kubedb/v1alpha2/clickhouse_webhook.go b/apis/kubedb/v1alpha2/clickhouse_webhook.go index 7dece77de7..a839f7750c 100644 --- a/apis/kubedb/v1alpha2/clickhouse_webhook.go +++ b/apis/kubedb/v1alpha2/clickhouse_webhook.go @@ -69,7 +69,7 @@ func (c *ClickHouse) ValidateDelete() (admission.Warnings, error) { clickhouselog.Info("validate delete", "name", c.Name) var allErr field.ErrorList - if c.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { + if c.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("teminationPolicy"), c.Name, "Can not delete as terminationPolicy is set to \"DoNotTerminate\"")) diff --git a/apis/kubedb/v1alpha2/conversion.go b/apis/kubedb/v1alpha2/conversion.go index 983900d418..ee2e4ae2d1 100644 --- a/apis/kubedb/v1alpha2/conversion.go +++ b/apis/kubedb/v1alpha2/conversion.go @@ -183,7 +183,7 @@ func Convert_v1_MariaDBSpec_To_v1alpha2_MariaDBSpec(in *v1.MariaDBSpec, out *Mar out.RequireSSL = in.RequireSSL out.TLS = (*clientgoapiv1.TLSConfig)(unsafe.Pointer(in.TLS)) out.Halted = in.Halted - out.TerminationPolicy = TerminationPolicy(in.DeletionPolicy) + out.TerminationPolicy = DeletionPolicy(in.DeletionPolicy) out.AllowedSchemas = (*AllowedConsumers)(unsafe.Pointer(in.AllowedSchemas)) out.HealthChecker = in.HealthChecker out.Archiver = (*Archiver)(unsafe.Pointer(in.Archiver)) @@ -264,7 +264,7 @@ func Convert_v1_PostgresSpec_To_v1alpha2_PostgresSpec(in *v1.PostgresSpec, out * out.ServiceTemplates = *(*[]NamedServiceTemplateSpec)(unsafe.Pointer(&in.ServiceTemplates)) out.TLS = (*clientgoapiv1.TLSConfig)(unsafe.Pointer(in.TLS)) out.Halted = in.Halted - out.TerminationPolicy = TerminationPolicy(in.DeletionPolicy) + out.TerminationPolicy = DeletionPolicy(in.DeletionPolicy) out.EnforceFsGroup = in.EnforceFsGroup out.AllowedSchemas = (*AllowedConsumers)(unsafe.Pointer(in.AllowedSchemas)) out.HealthChecker = in.HealthChecker @@ -369,7 +369,7 @@ func Convert_v1_MySQLSpec_To_v1alpha2_MySQLSpec(in *v1.MySQLSpec, out *MySQLSpec out.RequireSSL = in.RequireSSL out.TLS = (*clientgoapiv1.TLSConfig)(unsafe.Pointer(in.TLS)) out.Halted = in.Halted - out.TerminationPolicy = TerminationPolicy(in.DeletionPolicy) + out.TerminationPolicy = DeletionPolicy(in.DeletionPolicy) out.UseAddressType = AddressType(in.UseAddressType) out.AllowedSchemas = (*AllowedConsumers)(unsafe.Pointer(in.AllowedSchemas)) out.AllowedReadReplicas = (*AllowedConsumers)(unsafe.Pointer(in.AllowedReadReplicas)) @@ -611,7 +611,7 @@ func Convert_v1_MongoDBSpec_To_v1alpha2_MongoDBSpec(in *v1.MongoDBSpec, out *Mon out.TLS = (*clientgoapiv1.TLSConfig)(unsafe.Pointer(in.TLS)) out.KeyFileSecret = (*corev1.LocalObjectReference)(unsafe.Pointer(in.KeyFileSecret)) out.Halted = in.Halted - out.TerminationPolicy = TerminationPolicy(in.DeletionPolicy) + out.TerminationPolicy = DeletionPolicy(in.DeletionPolicy) out.StorageEngine = StorageEngine(in.StorageEngine) out.AllowedSchemas = (*AllowedConsumers)(unsafe.Pointer(in.AllowedSchemas)) if in.Arbiter != nil { @@ -761,7 +761,7 @@ func Convert_v1_RedisSpec_To_v1alpha2_RedisSpec(in *v1.RedisSpec, out *RedisSpec out.ServiceTemplates = *(*[]NamedServiceTemplateSpec)(unsafe.Pointer(&in.ServiceTemplates)) out.TLS = (*clientgoapiv1.TLSConfig)(unsafe.Pointer(in.TLS)) out.Halted = in.Halted - out.TerminationPolicy = TerminationPolicy(in.DeletionPolicy) + out.TerminationPolicy = DeletionPolicy(in.DeletionPolicy) out.AllowedSchemas = (*AllowedConsumers)(unsafe.Pointer(in.AllowedSchemas)) out.HealthChecker = in.HealthChecker return nil @@ -829,7 +829,7 @@ func Convert_v1_PerconaXtraDBSpec_To_v1alpha2_PerconaXtraDBSpec(in *v1.PerconaXt out.RequireSSL = in.RequireSSL out.TLS = (*clientgoapiv1.TLSConfig)(unsafe.Pointer(in.TLS)) out.Halted = in.Halted - out.TerminationPolicy = TerminationPolicy(in.DeletionPolicy) + out.TerminationPolicy = DeletionPolicy(in.DeletionPolicy) out.AllowedSchemas = (*AllowedConsumers)(unsafe.Pointer(in.AllowedSchemas)) out.HealthChecker = in.HealthChecker out.SystemUserSecrets = (*SystemUserSecretsSpec)(unsafe.Pointer(in.SystemUserSecrets)) @@ -958,7 +958,7 @@ func Convert_v1_ElasticsearchSpec_To_v1alpha2_ElasticsearchSpec(in *v1.Elasticse out.InternalUsers = *(*map[string]ElasticsearchUserSpec)(unsafe.Pointer(&in.InternalUsers)) out.RolesMapping = *(*map[string]ElasticsearchRoleMapSpec)(unsafe.Pointer(&in.RolesMapping)) out.Halted = in.Halted - out.TerminationPolicy = TerminationPolicy(in.DeletionPolicy) + out.TerminationPolicy = DeletionPolicy(in.DeletionPolicy) out.KernelSettings = (*KernelSettings)(unsafe.Pointer(in.KernelSettings)) out.HeapSizePercentage = (*int32)(unsafe.Pointer(in.HeapSizePercentage)) out.HealthChecker = in.HealthChecker @@ -977,7 +977,7 @@ func Convert_v1_MemcachedSpec_To_v1alpha2_MemcachedSpec(in *v1.MemcachedSpec, ou out.ServiceTemplates = *(*[]NamedServiceTemplateSpec)(unsafe.Pointer(&in.ServiceTemplates)) out.TLS = (*clientgoapiv1.TLSConfig)(unsafe.Pointer(in.TLS)) out.Halted = in.Halted - out.TerminationPolicy = TerminationPolicy(in.DeletionPolicy) + out.TerminationPolicy = DeletionPolicy(in.DeletionPolicy) out.HealthChecker = in.HealthChecker return nil } @@ -1025,7 +1025,7 @@ func Convert_v1_PgBouncerSpec_To_v1alpha2_PgBouncerSpec(in *v1.PgBouncerSpec, ou out.Monitor = (*monitoringagentapiapiv1.AgentSpec)(unsafe.Pointer(in.Monitor)) out.SSLMode = PgBouncerSSLMode(in.SSLMode) out.TLS = (*clientgoapiv1.TLSConfig)(unsafe.Pointer(in.TLS)) - out.TerminationPolicy = PgBouncerTerminationPolicy(in.DeletionPolicy) + out.TerminationPolicy = DeletionPolicy(in.DeletionPolicy) out.HealthChecker = in.HealthChecker return nil } @@ -1069,7 +1069,7 @@ func Convert_v1_ProxySQLSpec_To_v1alpha2_ProxySQLSpec(in *v1.ProxySQLSpec, out * } out.ServiceTemplates = *(*[]NamedServiceTemplateSpec)(unsafe.Pointer(&in.ServiceTemplates)) out.TLS = (*clientgoapiv1.TLSConfig)(unsafe.Pointer(in.TLS)) - out.TerminationPolicy = TerminationPolicy(in.DeletionPolicy) + out.TerminationPolicy = DeletionPolicy(in.DeletionPolicy) out.HealthChecker = in.HealthChecker return nil } @@ -1113,7 +1113,7 @@ func Convert_v1_RedisSentinelSpec_To_v1alpha2_RedisSentinelSpec(in *v1.RedisSent out.DisableAuth = in.DisableAuth out.Halted = in.Halted out.Monitor = (*monitoringagentapiapiv1.AgentSpec)(unsafe.Pointer(in.Monitor)) - out.TerminationPolicy = TerminationPolicy(in.DeletionPolicy) + out.TerminationPolicy = DeletionPolicy(in.DeletionPolicy) out.HealthChecker = in.HealthChecker return nil } diff --git a/apis/kubedb/v1alpha2/druid_helpers.go b/apis/kubedb/v1alpha2/druid_helpers.go index f8c2d4f4e5..db03e2582c 100644 --- a/apis/kubedb/v1alpha2/druid_helpers.go +++ b/apis/kubedb/v1alpha2/druid_helpers.go @@ -431,7 +431,7 @@ func (d *Druid) GetCertSecretName(alias DruidCertificateAlias) string { func (d *Druid) SetDefaults() { if d.Spec.DeletionPolicy == "" { - d.Spec.DeletionPolicy = TerminationPolicyDelete + d.Spec.DeletionPolicy = DeletionPolicyDelete } if d.Spec.EnableSSL { diff --git a/apis/kubedb/v1alpha2/druid_types.go b/apis/kubedb/v1alpha2/druid_types.go index d572d1155b..3ffd2dedee 100644 --- a/apis/kubedb/v1alpha2/druid_types.go +++ b/apis/kubedb/v1alpha2/druid_types.go @@ -115,7 +115,7 @@ type DruidSpec struct { // DeletionPolicy controls the delete operation for database // +optional - DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` + DeletionPolicy DeletionPolicy `json:"deletionPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional diff --git a/apis/kubedb/v1alpha2/elasticsearch_helpers.go b/apis/kubedb/v1alpha2/elasticsearch_helpers.go index 9cf6ac4460..bc22cd8103 100644 --- a/apis/kubedb/v1alpha2/elasticsearch_helpers.go +++ b/apis/kubedb/v1alpha2/elasticsearch_helpers.go @@ -436,7 +436,7 @@ func (e *Elasticsearch) SetDefaults(esVersion *catalog.ElasticsearchVersion, top } if e.Spec.TerminationPolicy == "" { - e.Spec.TerminationPolicy = TerminationPolicyDelete + e.Spec.TerminationPolicy = DeletionPolicyDelete } if e.Spec.PodTemplate.Spec.ServiceAccountName == "" { diff --git a/apis/kubedb/v1alpha2/elasticsearch_types.go b/apis/kubedb/v1alpha2/elasticsearch_types.go index 89c557aade..284112397c 100644 --- a/apis/kubedb/v1alpha2/elasticsearch_types.go +++ b/apis/kubedb/v1alpha2/elasticsearch_types.go @@ -156,7 +156,7 @@ type ElasticsearchSpec struct { // TerminationPolicy controls the delete operation for database // +optional - TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"` + TerminationPolicy DeletionPolicy `json:"terminationPolicy,omitempty"` // KernelSettings contains the additional kernel settings. // +optional diff --git a/apis/kubedb/v1alpha2/etcd_helpers.go b/apis/kubedb/v1alpha2/etcd_helpers.go index d0708704c2..6caa1697f2 100644 --- a/apis/kubedb/v1alpha2/etcd_helpers.go +++ b/apis/kubedb/v1alpha2/etcd_helpers.go @@ -182,7 +182,7 @@ func (e *Etcd) SetDefaults() { e.Spec.StorageType = StorageTypeDurable } if e.Spec.DeletionPolicy == "" { - e.Spec.DeletionPolicy = TerminationPolicyDelete + e.Spec.DeletionPolicy = DeletionPolicyDelete } e.Spec.Monitor.SetDefaults() diff --git a/apis/kubedb/v1alpha2/etcd_types.go b/apis/kubedb/v1alpha2/etcd_types.go index cbf151b155..ecc916ba1b 100644 --- a/apis/kubedb/v1alpha2/etcd_types.go +++ b/apis/kubedb/v1alpha2/etcd_types.go @@ -92,7 +92,7 @@ type EtcdSpec struct { // DeletionPolicy controls the delete operation for database // +optional - DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` + DeletionPolicy DeletionPolicy `json:"deletionPolicy,omitempty"` } type TLSPolicy struct { diff --git a/apis/kubedb/v1alpha2/ferretdb_helpers.go b/apis/kubedb/v1alpha2/ferretdb_helpers.go index 0e5f17c6c7..b88bb0459b 100644 --- a/apis/kubedb/v1alpha2/ferretdb_helpers.go +++ b/apis/kubedb/v1alpha2/ferretdb_helpers.go @@ -181,7 +181,7 @@ func (f *FerretDB) SetDefaults() { } if f.Spec.DeletionPolicy == "" { - f.Spec.DeletionPolicy = TerminationPolicyWipeOut + f.Spec.DeletionPolicy = DeletionPolicyWipeOut } if f.Spec.SSLMode == "" { diff --git a/apis/kubedb/v1alpha2/ferretdb_types.go b/apis/kubedb/v1alpha2/ferretdb_types.go index cdfd9e2760..c99cf28dc9 100644 --- a/apis/kubedb/v1alpha2/ferretdb_types.go +++ b/apis/kubedb/v1alpha2/ferretdb_types.go @@ -92,7 +92,7 @@ type FerretDBSpec struct { // DeletionPolicy controls the delete operation for database // +optional - DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` + DeletionPolicy DeletionPolicy `json:"deletionPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional diff --git a/apis/kubedb/v1alpha2/ferretdb_webhook.go b/apis/kubedb/v1alpha2/ferretdb_webhook.go index 883f5b3b62..e9f9255315 100644 --- a/apis/kubedb/v1alpha2/ferretdb_webhook.go +++ b/apis/kubedb/v1alpha2/ferretdb_webhook.go @@ -92,7 +92,7 @@ func (f *FerretDB) ValidateDelete() (admission.Warnings, error) { ferretdblog.Info("validate delete", "name", f.Name) var allErr field.ErrorList - if f.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { + if f.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), f.Name, "Can not delete as terminationPolicy is set to \"DoNotTerminate\"")) @@ -154,7 +154,7 @@ func (f *FerretDB) ValidateCreateOrUpdate() field.ErrorList { } // Termination policy related - if f.Spec.DeletionPolicy == TerminationPolicyHalt { + if f.Spec.DeletionPolicy == DeletionPolicyHalt { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), f.Name, `'spec.terminationPolicy' value 'Halt' is not supported yet for FerretDB`)) diff --git a/apis/kubedb/v1alpha2/kafka_helpers.go b/apis/kubedb/v1alpha2/kafka_helpers.go index 95d5ebf413..094e8cf8fd 100644 --- a/apis/kubedb/v1alpha2/kafka_helpers.go +++ b/apis/kubedb/v1alpha2/kafka_helpers.go @@ -300,15 +300,15 @@ func (k *Kafka) SetHealthCheckerDefaults() { func (k *Kafka) SetDefaults() { if k.Spec.Halted { - if k.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { + if k.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { klog.Errorf(`Can't halt, since deletion policy is 'DoNotTerminate'`) return } - k.Spec.DeletionPolicy = TerminationPolicyHalt + k.Spec.DeletionPolicy = DeletionPolicyHalt } if k.Spec.DeletionPolicy == "" { - k.Spec.DeletionPolicy = TerminationPolicyDelete + k.Spec.DeletionPolicy = DeletionPolicyDelete } if k.Spec.StorageType == "" { diff --git a/apis/kubedb/v1alpha2/kafka_types.go b/apis/kubedb/v1alpha2/kafka_types.go index b4770a0bac..1fb23c5998 100644 --- a/apis/kubedb/v1alpha2/kafka_types.go +++ b/apis/kubedb/v1alpha2/kafka_types.go @@ -110,7 +110,7 @@ type KafkaSpec struct { // DeletionPolicy controls the delete operation for database // +optional - DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` + DeletionPolicy DeletionPolicy `json:"deletionPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional diff --git a/apis/kubedb/v1alpha2/kafka_webhook.go b/apis/kubedb/v1alpha2/kafka_webhook.go index b76005bb94..4204234190 100644 --- a/apis/kubedb/v1alpha2/kafka_webhook.go +++ b/apis/kubedb/v1alpha2/kafka_webhook.go @@ -81,7 +81,7 @@ func (k *Kafka) ValidateDelete() (admission.Warnings, error) { // TODO(user): fill in your validation logic upon object deletion. var allErr field.ErrorList - if k.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { + if k.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("teminationPolicy"), k.Name, "Can not delete as terminationPolicy is set to \"DoNotTerminate\"")) @@ -170,7 +170,7 @@ func (k *Kafka) ValidateCreateOrUpdate() error { } } - if k.Spec.Halted && k.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { + if k.Spec.Halted && k.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("halted"), k.Name, `can't halt if deletionPolicy is set to "DoNotTerminate"`)) @@ -207,7 +207,7 @@ func (k *Kafka) ValidateCreateOrUpdate() error { k.Name, "StorageType should be either durable or ephemeral")) } - if k.Spec.StorageType == StorageTypeEphemeral && k.Spec.DeletionPolicy == TerminationPolicyHalt { + if k.Spec.StorageType == StorageTypeEphemeral && k.Spec.DeletionPolicy == DeletionPolicyHalt { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("deletionPolicy"), k.Name, `'spec.deletionPolicy: Halt' can not be used for 'Ephemeral' storage`)) diff --git a/apis/kubedb/v1alpha2/mariadb_helpers.go b/apis/kubedb/v1alpha2/mariadb_helpers.go index a717e2ec8d..6943b0dde3 100644 --- a/apis/kubedb/v1alpha2/mariadb_helpers.go +++ b/apis/kubedb/v1alpha2/mariadb_helpers.go @@ -210,7 +210,7 @@ func (m *MariaDB) SetDefaults(mdVersion *v1alpha1.MariaDBVersion, topology *core m.Spec.StorageType = StorageTypeDurable } if m.Spec.TerminationPolicy == "" { - m.Spec.TerminationPolicy = TerminationPolicyDelete + m.Spec.TerminationPolicy = DeletionPolicyDelete } if m.Spec.PodTemplate.Spec.ServiceAccountName == "" { diff --git a/apis/kubedb/v1alpha2/mariadb_types.go b/apis/kubedb/v1alpha2/mariadb_types.go index ca7ecd6550..3ade7e877f 100644 --- a/apis/kubedb/v1alpha2/mariadb_types.go +++ b/apis/kubedb/v1alpha2/mariadb_types.go @@ -111,7 +111,7 @@ type MariaDBSpec struct { // TerminationPolicy controls the delete operation for database // +optional - TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"` + TerminationPolicy DeletionPolicy `json:"terminationPolicy,omitempty"` // Coordinator defines attributes of the coordinator container // +optional diff --git a/apis/kubedb/v1alpha2/memcached_helpers.go b/apis/kubedb/v1alpha2/memcached_helpers.go index f6839cea88..3925e2937a 100644 --- a/apis/kubedb/v1alpha2/memcached_helpers.go +++ b/apis/kubedb/v1alpha2/memcached_helpers.go @@ -187,7 +187,7 @@ func (m *Memcached) SetDefaults(mcVersion *catalog.MemcachedVersion) { m.setDefaultContainerSecurityContext(mcVersion, &m.Spec.PodTemplate) // perform defaulting if m.Spec.TerminationPolicy == "" { - m.Spec.TerminationPolicy = TerminationPolicyDelete + m.Spec.TerminationPolicy = DeletionPolicyDelete } if m.Spec.PodTemplate.Spec.ServiceAccountName == "" { m.Spec.PodTemplate.Spec.ServiceAccountName = m.OffshootName() diff --git a/apis/kubedb/v1alpha2/memcached_types.go b/apis/kubedb/v1alpha2/memcached_types.go index c4321b209d..e3077f1e2c 100644 --- a/apis/kubedb/v1alpha2/memcached_types.go +++ b/apis/kubedb/v1alpha2/memcached_types.go @@ -101,7 +101,7 @@ type MemcachedSpec struct { // TerminationPolicy controls the delete operation for database // +optional - TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"` + TerminationPolicy DeletionPolicy `json:"terminationPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional diff --git a/apis/kubedb/v1alpha2/mongodb_helpers.go b/apis/kubedb/v1alpha2/mongodb_helpers.go index 615121324e..7304b41b12 100644 --- a/apis/kubedb/v1alpha2/mongodb_helpers.go +++ b/apis/kubedb/v1alpha2/mongodb_helpers.go @@ -618,7 +618,7 @@ func (m *MongoDB) SetDefaults(mgVersion *v1alpha1.MongoDBVersion, topology *core m.Spec.StorageEngine = StorageEngineWiredTiger } if m.Spec.TerminationPolicy == "" { - m.Spec.TerminationPolicy = TerminationPolicyDelete + m.Spec.TerminationPolicy = DeletionPolicyDelete } if m.Spec.SSLMode == "" { diff --git a/apis/kubedb/v1alpha2/mongodb_types.go b/apis/kubedb/v1alpha2/mongodb_types.go index 3fdabe84ec..4382a4bb21 100644 --- a/apis/kubedb/v1alpha2/mongodb_types.go +++ b/apis/kubedb/v1alpha2/mongodb_types.go @@ -121,7 +121,7 @@ type MongoDBSpec struct { // TerminationPolicy controls the delete operation for database // +optional - TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"` + TerminationPolicy DeletionPolicy `json:"terminationPolicy,omitempty"` // StorageEngine can be wiredTiger (default) or inMemory // See available StorageEngine: https://docs.mongodb.com/manual/core/storage-engines/ diff --git a/apis/kubedb/v1alpha2/mssqlserver_helpers.go b/apis/kubedb/v1alpha2/mssqlserver_helpers.go index d374796098..08e7ed0575 100644 --- a/apis/kubedb/v1alpha2/mssqlserver_helpers.go +++ b/apis/kubedb/v1alpha2/mssqlserver_helpers.go @@ -326,16 +326,16 @@ func (m *MSSQLServer) SetDefaults() { m.Spec.StorageType = StorageTypeDurable } if m.Spec.DeletionPolicy == "" { - m.Spec.DeletionPolicy = TerminationPolicyDelete + m.Spec.DeletionPolicy = DeletionPolicyDelete } if m.IsStandalone() { if m.Spec.Replicas == nil { m.Spec.Replicas = pointer.Int32P(1) } - } else { - if m.Spec.LeaderElection == nil { - m.Spec.LeaderElection = &MSSQLServerLeaderElectionConfig{ + } else if m.IsAvailabilityGroup() { + if m.Spec.Topology.AvailabilityGroup.LeaderElection == nil { + m.Spec.Topology.AvailabilityGroup.LeaderElection = &MSSQLServerLeaderElectionConfig{ // The upper limit of election timeout is 50000ms (50s), which should only be used when deploying a // globally-distributed etcd cluster. A reasonable round-trip time for the continental United States is around 130-150ms, // and the time between US and Japan is around 350-400ms. If the network has uneven performance or regular packet @@ -350,11 +350,11 @@ func (m *MSSQLServer) SetDefaults() { HeartbeatTick: 1, } } - if m.Spec.LeaderElection.TransferLeadershipInterval == nil { - m.Spec.LeaderElection.TransferLeadershipInterval = &meta.Duration{Duration: 1 * time.Second} + if m.Spec.Topology.AvailabilityGroup.LeaderElection.TransferLeadershipInterval == nil { + m.Spec.Topology.AvailabilityGroup.LeaderElection.TransferLeadershipInterval = &meta.Duration{Duration: 1 * time.Second} } - if m.Spec.LeaderElection.TransferLeadershipTimeout == nil { - m.Spec.LeaderElection.TransferLeadershipTimeout = &meta.Duration{Duration: 60 * time.Second} + if m.Spec.Topology.AvailabilityGroup.LeaderElection.TransferLeadershipTimeout == nil { + m.Spec.Topology.AvailabilityGroup.LeaderElection.TransferLeadershipTimeout = &meta.Duration{Duration: 60 * time.Second} } } @@ -498,8 +498,6 @@ func (m *MSSQLServer) setDefaultContainerResourceLimits(podTemplate *ofst.PodTem } func (m *MSSQLServer) SetTLSDefaults() { - m.SetTLSDefaultsForInternalAuth() - if m.Spec.TLS == nil || m.Spec.TLS.IssuerRef == nil { return } @@ -546,34 +544,30 @@ func (m *MSSQLServer) SetTLSDefaults() { OrganizationalUnits: defaultClientOrgUnit, }, }) -} - -func (m *MSSQLServer) SetTLSDefaultsForInternalAuth() { - if m.Spec.InternalAuth == nil || m.Spec.InternalAuth.EndpointCert == nil || m.Spec.InternalAuth.EndpointCert.IssuerRef == nil { - return - } - // Endpoint-cert - defaultServerOrg := []string{kubedb.KubeDBOrganization} - defaultServerOrgUnit := []string{string(MSSQLServerEndpointCert)} - _, cert := kmapi.GetCertificate(m.Spec.InternalAuth.EndpointCert.Certificates, string(MSSQLServerEndpointCert)) - if cert != nil && cert.Subject != nil { - if cert.Subject.Organizations != nil { - defaultServerOrg = cert.Subject.Organizations - } - if cert.Subject.OrganizationalUnits != nil { - defaultServerOrgUnit = cert.Subject.OrganizationalUnits + if m.IsAvailabilityGroup() { + // Endpoint-cert + defaultEndpointOrg := []string{kubedb.KubeDBOrganization} + defaultEndpointOrgUnit := []string{string(MSSQLServerEndpointCert)} + _, cert = kmapi.GetCertificate(m.Spec.TLS.Certificates, string(MSSQLServerEndpointCert)) + if cert != nil && cert.Subject != nil { + if cert.Subject.Organizations != nil { + defaultEndpointOrg = cert.Subject.Organizations + } + if cert.Subject.OrganizationalUnits != nil { + defaultEndpointOrgUnit = cert.Subject.OrganizationalUnits + } } - } - m.Spec.InternalAuth.EndpointCert.Certificates = kmapi.SetMissingSpecForCertificate(m.Spec.InternalAuth.EndpointCert.Certificates, kmapi.CertificateSpec{ - Alias: string(MSSQLServerEndpointCert), - SecretName: m.GetCertSecretName(MSSQLServerEndpointCert), - Subject: &kmapi.X509Subject{ - Organizations: defaultServerOrg, - OrganizationalUnits: defaultServerOrgUnit, - }, - }) + m.Spec.TLS.Certificates = kmapi.SetMissingSpecForCertificate(m.Spec.TLS.Certificates, kmapi.CertificateSpec{ + Alias: string(MSSQLServerEndpointCert), + SecretName: m.GetCertSecretName(MSSQLServerEndpointCert), + Subject: &kmapi.X509Subject{ + Organizations: defaultEndpointOrg, + OrganizationalUnits: defaultEndpointOrgUnit, + }, + }) + } } func (m *MSSQLServer) ReplicasAreReady(lister pslister.PetSetLister) (bool, string, error) { diff --git a/apis/kubedb/v1alpha2/mssqlserver_types.go b/apis/kubedb/v1alpha2/mssqlserver_types.go index 2331a1f36c..19138e9bf7 100644 --- a/apis/kubedb/v1alpha2/mssqlserver_types.go +++ b/apis/kubedb/v1alpha2/mssqlserver_types.go @@ -95,11 +95,6 @@ type MSSQLServerSpec struct { // +optional ConfigSecret *core.LocalObjectReference `json:"configSecret,omitempty"` - // InternalAuth is used to authenticate endpoint - // +optional - // +nullable - InternalAuth *InternalAuthentication `json:"internalAuth,omitempty"` - // Init is used to initialize database // +optional Init *InitSpec `json:"init,omitempty"` @@ -121,15 +116,7 @@ type MSSQLServerSpec struct { // DeletionPolicy controls the delete operation for database // +optional - DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` - - // Coordinator defines attributes of the coordinator container - // +optional - Coordinator CoordinatorSpec `json:"coordinator,omitempty"` - - // Leader election configuration - // +optional - LeaderElection *MSSQLServerLeaderElectionConfig `json:"leaderElection,omitempty"` + DeletionPolicy DeletionPolicy `json:"deletionPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional @@ -145,12 +132,6 @@ type MSSQLServerSpec struct { Archiver *Archiver `json:"archiver,omitempty"` } -// InternalAuthentication provides different way of endpoint authentication -type InternalAuthentication struct { - // EndpointCert is used for endpoint authentication of MSSql Server - EndpointCert *kmapi.TLSConfig `json:"endpointCert"` -} - type SQLServerTLSConfig struct { kmapi.TLSConfig `json:",inline"` ClientTLS bool `json:"clientTLS"` @@ -171,6 +152,10 @@ type MSSQLServerAvailabilityGroupSpec struct { // AvailabilityDatabases is an array of databases to be included in the availability group // +optional Databases []string `json:"databases"` + + // Leader election configuration + // +optional + LeaderElection *MSSQLServerLeaderElectionConfig `json:"leaderElection,omitempty"` } // MSSQLServerStatus defines the observed state of MSSQLServer diff --git a/apis/kubedb/v1alpha2/mssqlserver_webhook.go b/apis/kubedb/v1alpha2/mssqlserver_webhook.go index a088f2b982..cbfb46c78d 100644 --- a/apis/kubedb/v1alpha2/mssqlserver_webhook.go +++ b/apis/kubedb/v1alpha2/mssqlserver_webhook.go @@ -95,7 +95,7 @@ func (m *MSSQLServer) ValidateDelete() (admission.Warnings, error) { mssqllog.Info("validate delete", "name", m.Name) var allErr field.ErrorList - if m.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { + if m.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), m.Name, "Can not delete as terminationPolicy is set to \"DoNotTerminate\"")) @@ -132,23 +132,6 @@ func (m *MSSQLServer) ValidateCreateOrUpdate() field.ErrorList { m.Name, "number of replicas can not be nil and can not be less than or equal to 0")) } - - if m.Spec.InternalAuth == nil { - allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("internalAuth"), - m.Name, "spec.internalAuth is missing")) - } else if m.Spec.InternalAuth.EndpointCert == nil { - allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("internalAuth").Child("endpointCert"), - m.Name, "spec.internalAuth.endpointCert is missing")) - } else { - if m.Spec.InternalAuth.EndpointCert.IssuerRef == nil { - allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("internalAuth").Child("endpointCert").Child("issuerRef"), - m.Name, "spec.internalAuth.endpointCert.issuerRef' is missing")) - } - if len(m.Spec.InternalAuth.EndpointCert.Certificates) > 1 { - allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("internalAuth").Child("endpointCert").Child("certificates"), - m.Name, "spec.internalAuth.endpointCert.certificates' can have only one certificate")) - } - } } if m.Spec.TLS == nil { @@ -291,7 +274,6 @@ func mssqlValidateVolumesMountPaths(podTemplate *ofst.PodTemplateSpec) error { var forbiddenMSSQLServerEnvVars = []string{ kubedb.EnvMSSQLSAUsername, kubedb.EnvMSSQLSAPassword, - kubedb.EnvAcceptEula, kubedb.EnvMSSQLEnableHADR, kubedb.EnvMSSQLAgentEnabled, kubedb.EnvMSSQLVersion, diff --git a/apis/kubedb/v1alpha2/mysql_helpers.go b/apis/kubedb/v1alpha2/mysql_helpers.go index cb749df94f..7ae173071e 100644 --- a/apis/kubedb/v1alpha2/mysql_helpers.go +++ b/apis/kubedb/v1alpha2/mysql_helpers.go @@ -264,7 +264,7 @@ func (m *MySQL) SetDefaults(myVersion *v1alpha1.MySQLVersion, topology *core_uti m.Spec.StorageType = StorageTypeDurable } if m.Spec.TerminationPolicy == "" { - m.Spec.TerminationPolicy = TerminationPolicyDelete + m.Spec.TerminationPolicy = DeletionPolicyDelete } if m.UsesGroupReplication() { diff --git a/apis/kubedb/v1alpha2/mysql_types.go b/apis/kubedb/v1alpha2/mysql_types.go index b023255f83..467bb78bc2 100644 --- a/apis/kubedb/v1alpha2/mysql_types.go +++ b/apis/kubedb/v1alpha2/mysql_types.go @@ -128,7 +128,7 @@ type MySQLSpec struct { // TerminationPolicy controls the delete operation for database // +optional - TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"` + TerminationPolicy DeletionPolicy `json:"terminationPolicy,omitempty"` // Indicated whether to use DNS or IP address to address pods in a db cluster. // If IP address is used, HostNetwork will be used. Defaults to DNS. diff --git a/apis/kubedb/v1alpha2/openapi_generated.go b/apis/kubedb/v1alpha2/openapi_generated.go index c587cbcc88..54fc1b032b 100644 --- a/apis/kubedb/v1alpha2/openapi_generated.go +++ b/apis/kubedb/v1alpha2/openapi_generated.go @@ -549,7 +549,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.FerretDBStatus": schema_apimachinery_apis_kubedb_v1alpha2_FerretDBStatus(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.GitRepo": schema_apimachinery_apis_kubedb_v1alpha2_GitRepo(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.InitSpec": schema_apimachinery_apis_kubedb_v1alpha2_InitSpec(ref), - "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.InternalAuthentication": schema_apimachinery_apis_kubedb_v1alpha2_InternalAuthentication(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.Kafka": schema_apimachinery_apis_kubedb_v1alpha2_Kafka(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.KafkaApp": schema_apimachinery_apis_kubedb_v1alpha2_KafkaApp(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.KafkaBrokerCapacity": schema_apimachinery_apis_kubedb_v1alpha2_KafkaBrokerCapacity(ref), @@ -28546,28 +28545,6 @@ func schema_apimachinery_apis_kubedb_v1alpha2_InitSpec(ref common.ReferenceCallb } } -func schema_apimachinery_apis_kubedb_v1alpha2_InternalAuthentication(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "InternalAuthentication provides different way of endpoint authentication", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "endpointCert": { - SchemaProps: spec.SchemaProps{ - Description: "EndpointCert is used for endpoint authentication of MSSql Server", - Ref: ref("kmodules.xyz/client-go/api/v1.TLSConfig"), - }, - }, - }, - Required: []string{"endpointCert"}, - }, - }, - Dependencies: []string{ - "kmodules.xyz/client-go/api/v1.TLSConfig"}, - } -} - func schema_apimachinery_apis_kubedb_v1alpha2_Kafka(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -29177,9 +29154,17 @@ func schema_apimachinery_apis_kubedb_v1alpha2_MSSQLServerAvailabilityGroupSpec(r }, }, }, + "leaderElection": { + SchemaProps: spec.SchemaProps{ + Description: "Leader election configuration", + Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MSSQLServerLeaderElectionConfig"), + }, + }, }, }, }, + Dependencies: []string{ + "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MSSQLServerLeaderElectionConfig"}, } } @@ -29334,12 +29319,6 @@ func schema_apimachinery_apis_kubedb_v1alpha2_MSSQLServerSpec(ref common.Referen Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), }, }, - "internalAuth": { - SchemaProps: spec.SchemaProps{ - Description: "InternalAuth is used to authenticate endpoint", - Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1alpha2.InternalAuthentication"), - }, - }, "init": { SchemaProps: spec.SchemaProps{ Description: "Init is used to initialize database", @@ -29386,19 +29365,6 @@ func schema_apimachinery_apis_kubedb_v1alpha2_MSSQLServerSpec(ref common.Referen Format: "", }, }, - "coordinator": { - SchemaProps: spec.SchemaProps{ - Description: "Coordinator defines attributes of the coordinator container", - Default: map[string]interface{}{}, - Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1alpha2.CoordinatorSpec"), - }, - }, - "leaderElection": { - SchemaProps: spec.SchemaProps{ - Description: "Leader election configuration", - Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MSSQLServerLeaderElectionConfig"), - }, - }, "healthChecker": { SchemaProps: spec.SchemaProps{ Description: "HealthChecker defines attributes of the health checker", @@ -29423,7 +29389,7 @@ func schema_apimachinery_apis_kubedb_v1alpha2_MSSQLServerSpec(ref common.Referen }, }, Dependencies: []string{ - "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PersistentVolumeClaimSpec", "kmodules.xyz/client-go/api/v1.HealthCheckSpec", "kmodules.xyz/monitoring-agent-api/api/v1.AgentSpec", "kmodules.xyz/offshoot-api/api/v2.PodTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.Archiver", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.CoordinatorSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.InitSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.InternalAuthentication", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MSSQLServerLeaderElectionConfig", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MSSQLServerTopology", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.NamedServiceTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SQLServerTLSConfig", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SecretReference"}, + "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PersistentVolumeClaimSpec", "kmodules.xyz/client-go/api/v1.HealthCheckSpec", "kmodules.xyz/monitoring-agent-api/api/v1.AgentSpec", "kmodules.xyz/offshoot-api/api/v2.PodTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.Archiver", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.InitSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MSSQLServerTopology", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.NamedServiceTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SQLServerTLSConfig", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SecretReference"}, } } diff --git a/apis/kubedb/v1alpha2/perconaxtradb_helpers.go b/apis/kubedb/v1alpha2/perconaxtradb_helpers.go index 52a9f67b91..4bbbcc6f00 100644 --- a/apis/kubedb/v1alpha2/perconaxtradb_helpers.go +++ b/apis/kubedb/v1alpha2/perconaxtradb_helpers.go @@ -219,7 +219,7 @@ func (p *PerconaXtraDB) SetDefaults(pVersion *v1alpha1.PerconaXtraDBVersion, top p.Spec.StorageType = StorageTypeDurable } if p.Spec.TerminationPolicy == "" { - p.Spec.TerminationPolicy = TerminationPolicyDelete + p.Spec.TerminationPolicy = DeletionPolicyDelete } if p.Spec.PodTemplate.Spec.ServiceAccountName == "" { diff --git a/apis/kubedb/v1alpha2/perconaxtradb_types.go b/apis/kubedb/v1alpha2/perconaxtradb_types.go index 021fd35d3d..fffafa5a17 100644 --- a/apis/kubedb/v1alpha2/perconaxtradb_types.go +++ b/apis/kubedb/v1alpha2/perconaxtradb_types.go @@ -105,7 +105,7 @@ type PerconaXtraDBSpec struct { // TerminationPolicy controls the delete operation for database // +optional - TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"` + TerminationPolicy DeletionPolicy `json:"terminationPolicy,omitempty"` // Coordinator defines attributes of the coordinator container // +optional diff --git a/apis/kubedb/v1alpha2/pgbouncer_helpers.go b/apis/kubedb/v1alpha2/pgbouncer_helpers.go index f879d65e24..2d247ade98 100644 --- a/apis/kubedb/v1alpha2/pgbouncer_helpers.go +++ b/apis/kubedb/v1alpha2/pgbouncer_helpers.go @@ -192,7 +192,7 @@ func (p *PgBouncer) SetDefaults(pgBouncerVersion *catalog.PgBouncerVersion, uses } if p.Spec.TerminationPolicy == "" { - p.Spec.TerminationPolicy = PgBouncerTerminationPolicyDelete + p.Spec.TerminationPolicy = DeletionPolicyDelete } p.setConnectionPoolConfigDefaults() diff --git a/apis/kubedb/v1alpha2/pgbouncer_types.go b/apis/kubedb/v1alpha2/pgbouncer_types.go index 095e99cff9..3a15897072 100644 --- a/apis/kubedb/v1alpha2/pgbouncer_types.go +++ b/apis/kubedb/v1alpha2/pgbouncer_types.go @@ -99,7 +99,7 @@ type PgBouncerSpec struct { // TerminationPolicy controls the delete operation for database // +optional - TerminationPolicy PgBouncerTerminationPolicy `json:"terminationPolicy,omitempty"` + TerminationPolicy DeletionPolicy `json:"terminationPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional @@ -265,17 +265,3 @@ const ( // to Send the client cert and client key certificate for authentication. PgBouncerClientAuthModeCert PgBouncerClientAuthMode = "cert" ) - -// +kubebuilder:validation:Enum=Halt;Delete;WipeOut;DoNotTerminate -type PgBouncerTerminationPolicy string - -const ( - // Deletes database pods, service but leave the PVCs and stash backup data intact. - PgBouncerDeletionPolicyHalt PgBouncerTerminationPolicy = "Halt" - // Deletes database pods, service, pvcs but leave the stash backup data intact. - PgBouncerTerminationPolicyDelete PgBouncerTerminationPolicy = "Delete" - // Deletes database pods, service, pvcs and stash backup data. - PgBouncerTerminationPolicyWipeOut PgBouncerTerminationPolicy = "WipeOut" - // Rejects attempt to delete database using ValidationWebhook. - PgBouncerTerminationPolicyDoNotTerminate PgBouncerTerminationPolicy = "DoNotTerminate" -) diff --git a/apis/kubedb/v1alpha2/pgpool_helpers.go b/apis/kubedb/v1alpha2/pgpool_helpers.go index 7e0167b7af..9fc3e14545 100644 --- a/apis/kubedb/v1alpha2/pgpool_helpers.go +++ b/apis/kubedb/v1alpha2/pgpool_helpers.go @@ -348,7 +348,7 @@ func (p *Pgpool) SetDefaults() { p.Spec.Replicas = pointer.Int32P(1) } if p.Spec.DeletionPolicy == "" { - p.Spec.DeletionPolicy = TerminationPolicyDelete + p.Spec.DeletionPolicy = DeletionPolicyDelete } if p.Spec.PodTemplate == nil { p.Spec.PodTemplate = &ofst.PodTemplateSpec{} diff --git a/apis/kubedb/v1alpha2/pgpool_types.go b/apis/kubedb/v1alpha2/pgpool_types.go index b2795de86f..605b95088d 100644 --- a/apis/kubedb/v1alpha2/pgpool_types.go +++ b/apis/kubedb/v1alpha2/pgpool_types.go @@ -99,7 +99,7 @@ type PgpoolSpec struct { // DeletionPolicy controls the delete operation for database // +optional - DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` + DeletionPolicy DeletionPolicy `json:"deletionPolicy,omitempty"` // SSLMode for both standalone and clusters. [disable;allow;prefer;require;verify-ca;verify-full] SSLMode PgpoolSSLMode `json:"sslMode,omitempty"` diff --git a/apis/kubedb/v1alpha2/pgpool_webhook.go b/apis/kubedb/v1alpha2/pgpool_webhook.go index 7476ca18af..d870dd754a 100644 --- a/apis/kubedb/v1alpha2/pgpool_webhook.go +++ b/apis/kubedb/v1alpha2/pgpool_webhook.go @@ -90,7 +90,7 @@ func (p *Pgpool) ValidateDelete() (admission.Warnings, error) { pgpoollog.Info("validate delete", "name", p.Name) var errorList field.ErrorList - if p.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { + if p.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { errorList = append(errorList, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), p.Name, "Can not delete as terminationPolicy is set to \"DoNotTerminate\"")) diff --git a/apis/kubedb/v1alpha2/postgres_helpers.go b/apis/kubedb/v1alpha2/postgres_helpers.go index ee212cbac1..a31dbb4ce4 100644 --- a/apis/kubedb/v1alpha2/postgres_helpers.go +++ b/apis/kubedb/v1alpha2/postgres_helpers.go @@ -193,7 +193,7 @@ func (p *Postgres) SetDefaults(postgresVersion *catalog.PostgresVersion, topolog p.Spec.StorageType = StorageTypeDurable } if p.Spec.TerminationPolicy == "" { - p.Spec.TerminationPolicy = TerminationPolicyDelete + p.Spec.TerminationPolicy = DeletionPolicyDelete } if p.Spec.LeaderElection == nil { diff --git a/apis/kubedb/v1alpha2/postgres_types.go b/apis/kubedb/v1alpha2/postgres_types.go index ff4b5ea29c..dbbf37dd7f 100644 --- a/apis/kubedb/v1alpha2/postgres_types.go +++ b/apis/kubedb/v1alpha2/postgres_types.go @@ -131,7 +131,7 @@ type PostgresSpec struct { // TerminationPolicy controls the delete operation for database // +optional - TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"` + TerminationPolicy DeletionPolicy `json:"terminationPolicy,omitempty"` // Coordinator defines attributes of the coordinator container // +optional diff --git a/apis/kubedb/v1alpha2/proxysql_types.go b/apis/kubedb/v1alpha2/proxysql_types.go index 9a196ce2a9..630c0a0300 100644 --- a/apis/kubedb/v1alpha2/proxysql_types.go +++ b/apis/kubedb/v1alpha2/proxysql_types.go @@ -166,7 +166,7 @@ type ProxySQLSpec struct { // TerminationPolicy controls the delete operation for database // +optional - TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"` + TerminationPolicy DeletionPolicy `json:"terminationPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional diff --git a/apis/kubedb/v1alpha2/rabbitmq_helpers.go b/apis/kubedb/v1alpha2/rabbitmq_helpers.go index f998beb0c9..35384a26fa 100644 --- a/apis/kubedb/v1alpha2/rabbitmq_helpers.go +++ b/apis/kubedb/v1alpha2/rabbitmq_helpers.go @@ -281,7 +281,7 @@ func (r *RabbitMQ) SetDefaults() { } if r.Spec.DeletionPolicy == "" { - r.Spec.DeletionPolicy = TerminationPolicyDelete + r.Spec.DeletionPolicy = DeletionPolicyDelete } if r.Spec.StorageType == "" { diff --git a/apis/kubedb/v1alpha2/rabbitmq_types.go b/apis/kubedb/v1alpha2/rabbitmq_types.go index 050c8a9547..bb42ff5a79 100644 --- a/apis/kubedb/v1alpha2/rabbitmq_types.go +++ b/apis/kubedb/v1alpha2/rabbitmq_types.go @@ -110,7 +110,7 @@ type RabbitMQSpec struct { // DeletionPolicy controls the delete operation for database // +optional - DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` + DeletionPolicy DeletionPolicy `json:"deletionPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional diff --git a/apis/kubedb/v1alpha2/rabbitmq_webhook.go b/apis/kubedb/v1alpha2/rabbitmq_webhook.go index 6a33e59a4e..4ad133a9f3 100644 --- a/apis/kubedb/v1alpha2/rabbitmq_webhook.go +++ b/apis/kubedb/v1alpha2/rabbitmq_webhook.go @@ -71,8 +71,8 @@ func (r *RabbitMQ) ValidateDelete() (admission.Warnings, error) { rabbitmqlog.Info("validate delete", "name", r.Name) var allErr field.ErrorList - if r.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { - allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("teminationPolicy"), + if r.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("deletionPolicy"), r.Name, "Can not delete as terminationPolicy is set to \"DoNotTerminate\"")) return nil, apierrors.NewInvalid(schema.GroupKind{Group: "rabbitmq.kubedb.com", Kind: "RabbitMQ"}, r.Name, allErr) diff --git a/apis/kubedb/v1alpha2/redis_helpers.go b/apis/kubedb/v1alpha2/redis_helpers.go index 163eae20e5..048be592e1 100644 --- a/apis/kubedb/v1alpha2/redis_helpers.go +++ b/apis/kubedb/v1alpha2/redis_helpers.go @@ -227,7 +227,7 @@ func (r *Redis) SetDefaults(rdVersion *catalog.RedisVersion, topology *core_util r.Spec.StorageType = StorageTypeDurable } if r.Spec.TerminationPolicy == "" { - r.Spec.TerminationPolicy = TerminationPolicyDelete + r.Spec.TerminationPolicy = DeletionPolicyDelete } r.setDefaultContainerSecurityContext(rdVersion, &r.Spec.PodTemplate) if r.Spec.PodTemplate.Spec.ServiceAccountName == "" { diff --git a/apis/kubedb/v1alpha2/redis_sentinel_helpers.go b/apis/kubedb/v1alpha2/redis_sentinel_helpers.go index ec023d85ab..73d2fa19bf 100644 --- a/apis/kubedb/v1alpha2/redis_sentinel_helpers.go +++ b/apis/kubedb/v1alpha2/redis_sentinel_helpers.go @@ -188,7 +188,7 @@ func (rs *RedisSentinel) SetDefaults(rdVersion *catalog.RedisVersion, topology * rs.Spec.StorageType = StorageTypeDurable } if rs.Spec.TerminationPolicy == "" { - rs.Spec.TerminationPolicy = TerminationPolicyDelete + rs.Spec.TerminationPolicy = DeletionPolicyDelete } rs.setDefaultContainerSecurityContext(rdVersion, &rs.Spec.PodTemplate) diff --git a/apis/kubedb/v1alpha2/redis_sentinel_types.go b/apis/kubedb/v1alpha2/redis_sentinel_types.go index dbb0608324..a36e180240 100644 --- a/apis/kubedb/v1alpha2/redis_sentinel_types.go +++ b/apis/kubedb/v1alpha2/redis_sentinel_types.go @@ -90,7 +90,7 @@ type RedisSentinelSpec struct { // TerminationPolicy controls the delete operation for database // +optional - TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"` + TerminationPolicy DeletionPolicy `json:"terminationPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional diff --git a/apis/kubedb/v1alpha2/redis_types.go b/apis/kubedb/v1alpha2/redis_types.go index 9d2f2615a2..fb40cb8aaa 100644 --- a/apis/kubedb/v1alpha2/redis_types.go +++ b/apis/kubedb/v1alpha2/redis_types.go @@ -123,7 +123,7 @@ type RedisSpec struct { // TerminationPolicy controls the delete operation for database // +optional - TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"` + TerminationPolicy DeletionPolicy `json:"terminationPolicy,omitempty"` // Coordinator defines attributes of the coordinator container // +optional diff --git a/apis/kubedb/v1alpha2/singlestore_helpers.go b/apis/kubedb/v1alpha2/singlestore_helpers.go index a0136f0337..617317a658 100644 --- a/apis/kubedb/v1alpha2/singlestore_helpers.go +++ b/apis/kubedb/v1alpha2/singlestore_helpers.go @@ -327,7 +327,7 @@ func (s *Singlestore) SetDefaults() { s.Spec.StorageType = StorageTypeDurable } if s.Spec.DeletionPolicy == "" { - s.Spec.DeletionPolicy = TerminationPolicyDelete + s.Spec.DeletionPolicy = DeletionPolicyDelete } if s.Spec.Topology == nil { diff --git a/apis/kubedb/v1alpha2/singlestore_types.go b/apis/kubedb/v1alpha2/singlestore_types.go index da7375461d..48b3b00411 100644 --- a/apis/kubedb/v1alpha2/singlestore_types.go +++ b/apis/kubedb/v1alpha2/singlestore_types.go @@ -102,7 +102,7 @@ type SinglestoreSpec struct { // DeletionPolicy controls the delete operation for database // +optional - DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` + DeletionPolicy DeletionPolicy `json:"deletionPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional diff --git a/apis/kubedb/v1alpha2/singlestore_webhook.go b/apis/kubedb/v1alpha2/singlestore_webhook.go index 7547abb319..5078f78148 100644 --- a/apis/kubedb/v1alpha2/singlestore_webhook.go +++ b/apis/kubedb/v1alpha2/singlestore_webhook.go @@ -78,7 +78,7 @@ func (s *Singlestore) ValidateDelete() (admission.Warnings, error) { singlestorelog.Info("validate delete", "name", s.Name) var allErr field.ErrorList - if s.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { + if s.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), s.Name, "Can not delete as terminationPolicy is set to \"DoNotTerminate\"")) diff --git a/apis/kubedb/v1alpha2/solr_helpers.go b/apis/kubedb/v1alpha2/solr_helpers.go index ca0b3b26ca..265e7fb481 100644 --- a/apis/kubedb/v1alpha2/solr_helpers.go +++ b/apis/kubedb/v1alpha2/solr_helpers.go @@ -274,7 +274,7 @@ func (s Solr) CoordinatorSelectors() map[string]string { func (s *Solr) SetDefaults() { if s.Spec.DeletionPolicy == "" { - s.Spec.DeletionPolicy = TerminationPolicyDelete + s.Spec.DeletionPolicy = DeletionPolicyDelete } if s.Spec.ClientAuthSSL != "need" && s.Spec.ClientAuthSSL != "want" { diff --git a/apis/kubedb/v1alpha2/solr_types.go b/apis/kubedb/v1alpha2/solr_types.go index b56760945c..25abe9352d 100644 --- a/apis/kubedb/v1alpha2/solr_types.go +++ b/apis/kubedb/v1alpha2/solr_types.go @@ -123,7 +123,7 @@ type SolrSpec struct { // DeletionPolicy controls the delete operation for database // +optional - DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` + DeletionPolicy DeletionPolicy `json:"deletionPolicy,omitempty"` // HealthChecker defines attributes of the health checker // +optional diff --git a/apis/kubedb/v1alpha2/solr_webhook.go b/apis/kubedb/v1alpha2/solr_webhook.go index 4a64c8e857..1ea9feecb8 100644 --- a/apis/kubedb/v1alpha2/solr_webhook.go +++ b/apis/kubedb/v1alpha2/solr_webhook.go @@ -84,7 +84,7 @@ func (s *Solr) ValidateDelete() (admission.Warnings, error) { solrlog.Info("validate delete", "name", s.Name) var allErr field.ErrorList - if s.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { + if s.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), s.Name, "Can not delete as terminationPolicy is set to \"DoNotTerminate\"")) diff --git a/apis/kubedb/v1alpha2/types.go b/apis/kubedb/v1alpha2/types.go index bb818a9604..3a8aab79e1 100644 --- a/apis/kubedb/v1alpha2/types.go +++ b/apis/kubedb/v1alpha2/types.go @@ -111,17 +111,17 @@ const ( ) // +kubebuilder:validation:Enum=Halt;Delete;WipeOut;DoNotTerminate -type TerminationPolicy string +type DeletionPolicy string const ( // Deletes database pods, service but leave the PVCs and stash backup data intact. - TerminationPolicyHalt TerminationPolicy = "Halt" + DeletionPolicyHalt DeletionPolicy = "Halt" // Deletes database pods, service, pvcs but leave the stash backup data intact. - TerminationPolicyDelete TerminationPolicy = "Delete" + DeletionPolicyDelete DeletionPolicy = "Delete" // Deletes database pods, service, pvcs and stash backup data. - TerminationPolicyWipeOut TerminationPolicy = "WipeOut" + DeletionPolicyWipeOut DeletionPolicy = "WipeOut" // Rejects attempt to delete database using ValidationWebhook. - TerminationPolicyDoNotTerminate TerminationPolicy = "DoNotTerminate" + DeletionPolicyDoNotTerminate DeletionPolicy = "DoNotTerminate" ) // +kubebuilder:validation:Enum=primary;standby;stats;dashboard;secondary diff --git a/apis/kubedb/v1alpha2/zookeeper_helpers.go b/apis/kubedb/v1alpha2/zookeeper_helpers.go index 5bd4730eff..39b9b8b7cd 100644 --- a/apis/kubedb/v1alpha2/zookeeper_helpers.go +++ b/apis/kubedb/v1alpha2/zookeeper_helpers.go @@ -188,18 +188,18 @@ func (z *ZooKeeper) SetHealthCheckerDefaults() { func (z *ZooKeeper) SetDefaults() { if z.Spec.DeletionPolicy == "" { - z.Spec.DeletionPolicy = TerminationPolicyDelete + z.Spec.DeletionPolicy = DeletionPolicyDelete } if z.Spec.Replicas == nil { z.Spec.Replicas = pointer.Int32P(1) } if z.Spec.Halted { - if z.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { + if z.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { klog.Errorf(`Can't halt, since termination policy is 'DoNotTerminate'`) return } - z.Spec.DeletionPolicy = TerminationPolicyHalt + z.Spec.DeletionPolicy = DeletionPolicyHalt } var zkVersion catalog.ZooKeeperVersion diff --git a/apis/kubedb/v1alpha2/zookeeper_types.go b/apis/kubedb/v1alpha2/zookeeper_types.go index 661a5feea7..972d48c59c 100644 --- a/apis/kubedb/v1alpha2/zookeeper_types.go +++ b/apis/kubedb/v1alpha2/zookeeper_types.go @@ -106,7 +106,7 @@ type ZooKeeperSpec struct { // DeletionPolicy controls the delete operation for database // +optional - DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"` + DeletionPolicy DeletionPolicy `json:"deletionPolicy,omitempty"` // Indicates that the database is halted and all offshoot Kubernetes resources except PVCs are deleted. // +optional diff --git a/apis/kubedb/v1alpha2/zookeeper_webhook.go b/apis/kubedb/v1alpha2/zookeeper_webhook.go index 20fcfba928..e9da6a2ce9 100644 --- a/apis/kubedb/v1alpha2/zookeeper_webhook.go +++ b/apis/kubedb/v1alpha2/zookeeper_webhook.go @@ -79,7 +79,7 @@ func (z *ZooKeeper) ValidateDelete() (admission.Warnings, error) { zookeeperlog.Info("validate delete", "name", z.Name) var allErr field.ErrorList - if z.Spec.DeletionPolicy == TerminationPolicyDoNotTerminate { + if z.Spec.DeletionPolicy == DeletionPolicyDoNotTerminate { allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("teminationPolicy"), z.Name, "Can not delete as terminationPolicy is set to \"DoNotTerminate\"")) diff --git a/apis/kubedb/v1alpha2/zz_generated.conversion.go b/apis/kubedb/v1alpha2/zz_generated.conversion.go index a9586fa311..eef82ace18 100644 --- a/apis/kubedb/v1alpha2/zz_generated.conversion.go +++ b/apis/kubedb/v1alpha2/zz_generated.conversion.go @@ -2045,7 +2045,7 @@ func autoConvert_v1_KafkaSpec_To_v1alpha2_KafkaSpec(in *v1.KafkaSpec, out *Kafka out.TLS = (*clientgoapiv1.TLSConfig)(unsafe.Pointer(in.TLS)) out.PodTemplate = in.PodTemplate out.ServiceTemplates = *(*[]NamedServiceTemplateSpec)(unsafe.Pointer(&in.ServiceTemplates)) - out.DeletionPolicy = TerminationPolicy(in.DeletionPolicy) + out.DeletionPolicy = DeletionPolicy(in.DeletionPolicy) out.HealthChecker = in.HealthChecker out.CruiseControl = (*KafkaCruiseControl)(unsafe.Pointer(in.CruiseControl)) out.Monitor = (*monitoringagentapiapiv1.AgentSpec)(unsafe.Pointer(in.Monitor)) @@ -4300,6 +4300,8 @@ func Convert_v1_ScriptSourceSpec_To_v1alpha2_ScriptSourceSpec(in *v1.ScriptSourc func autoConvert_v1alpha2_SecretReference_To_v1_SecretReference(in *SecretReference, out *v1.SecretReference, s conversion.Scope) error { out.LocalObjectReference = in.LocalObjectReference + out.RotateAfter = (*metav1.Duration)(unsafe.Pointer(in.RotateAfter)) + out.ActiveFrom = (*metav1.Time)(unsafe.Pointer(in.ActiveFrom)) out.ExternallyManaged = in.ExternallyManaged return nil } @@ -4311,6 +4313,8 @@ func Convert_v1alpha2_SecretReference_To_v1_SecretReference(in *SecretReference, func autoConvert_v1_SecretReference_To_v1alpha2_SecretReference(in *v1.SecretReference, out *SecretReference, s conversion.Scope) error { out.LocalObjectReference = in.LocalObjectReference + out.RotateAfter = (*metav1.Duration)(unsafe.Pointer(in.RotateAfter)) + out.ActiveFrom = (*metav1.Time)(unsafe.Pointer(in.ActiveFrom)) out.ExternallyManaged = in.ExternallyManaged return nil } diff --git a/apis/kubedb/v1alpha2/zz_generated.deepcopy.go b/apis/kubedb/v1alpha2/zz_generated.deepcopy.go index 4f8458a765..458bb13fcf 100644 --- a/apis/kubedb/v1alpha2/zz_generated.deepcopy.go +++ b/apis/kubedb/v1alpha2/zz_generated.deepcopy.go @@ -1938,27 +1938,6 @@ func (in *InitSpec) DeepCopy() *InitSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InternalAuthentication) DeepCopyInto(out *InternalAuthentication) { - *out = *in - if in.EndpointCert != nil { - in, out := &in.EndpointCert, &out.EndpointCert - *out = new(apiv1.TLSConfig) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InternalAuthentication. -func (in *InternalAuthentication) DeepCopy() *InternalAuthentication { - if in == nil { - return nil - } - out := new(InternalAuthentication) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Kafka) DeepCopyInto(out *Kafka) { *out = *in @@ -2328,6 +2307,11 @@ func (in *MSSQLServerAvailabilityGroupSpec) DeepCopyInto(out *MSSQLServerAvailab *out = make([]string, len(*in)) copy(*out, *in) } + if in.LeaderElection != nil { + in, out := &in.LeaderElection, &out.LeaderElection + *out = new(MSSQLServerLeaderElectionConfig) + (*in).DeepCopyInto(*out) + } return } @@ -2429,11 +2413,6 @@ func (in *MSSQLServerSpec) DeepCopyInto(out *MSSQLServerSpec) { *out = new(corev1.LocalObjectReference) **out = **in } - if in.InternalAuth != nil { - in, out := &in.InternalAuth, &out.InternalAuth - *out = new(InternalAuthentication) - (*in).DeepCopyInto(*out) - } if in.Init != nil { in, out := &in.Init, &out.Init *out = new(InitSpec) @@ -2456,12 +2435,6 @@ func (in *MSSQLServerSpec) DeepCopyInto(out *MSSQLServerSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - in.Coordinator.DeepCopyInto(&out.Coordinator) - if in.LeaderElection != nil { - in, out := &in.LeaderElection, &out.LeaderElection - *out = new(MSSQLServerLeaderElectionConfig) - (*in).DeepCopyInto(*out) - } in.HealthChecker.DeepCopyInto(&out.HealthChecker) if in.Monitor != nil { in, out := &in.Monitor, &out.Monitor diff --git a/crds/kubedb.com_mssqlservers.yaml b/crds/kubedb.com_mssqlservers.yaml index e29a08f8fe..9982ca81c4 100644 --- a/crds/kubedb.com_mssqlservers.yaml +++ b/crds/kubedb.com_mssqlservers.yaml @@ -80,112 +80,6 @@ spec: type: string type: object x-kubernetes-map-type: atomic - coordinator: - properties: - resources: - properties: - claims: - items: - properties: - name: - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - type: object - securityContext: - properties: - allowPrivilegeEscalation: - type: boolean - appArmorProfile: - properties: - localhostProfile: - type: string - type: - type: string - required: - - type - type: object - capabilities: - properties: - add: - items: - type: string - type: array - x-kubernetes-list-type: atomic - drop: - items: - type: string - type: array - x-kubernetes-list-type: atomic - type: object - privileged: - type: boolean - procMount: - type: string - readOnlyRootFilesystem: - type: boolean - runAsGroup: - format: int64 - type: integer - runAsNonRoot: - type: boolean - runAsUser: - format: int64 - type: integer - seLinuxOptions: - properties: - level: - type: string - role: - type: string - type: - type: string - user: - type: string - type: object - seccompProfile: - properties: - localhostProfile: - type: string - type: - type: string - required: - - type - type: object - windowsOptions: - properties: - gmsaCredentialSpec: - type: string - gmsaCredentialSpecName: - type: string - hostProcess: - type: boolean - runAsUserName: - type: string - type: object - type: object - type: object deletionPolicy: enum: - Halt @@ -1229,133 +1123,6 @@ spec: waitForInitialRestore: type: boolean type: object - internalAuth: - nullable: true - properties: - endpointCert: - properties: - certificates: - items: - properties: - alias: - type: string - dnsNames: - items: - type: string - type: array - duration: - type: string - emailAddresses: - items: - type: string - type: array - ipAddresses: - items: - type: string - type: array - issuerRef: - properties: - apiGroup: - type: string - kind: - type: string - name: - type: string - required: - - kind - - name - type: object - x-kubernetes-map-type: atomic - privateKey: - properties: - encoding: - enum: - - PKCS1 - - PKCS8 - type: string - type: object - renewBefore: - type: string - secretName: - type: string - subject: - properties: - countries: - items: - type: string - type: array - localities: - items: - type: string - type: array - organizationalUnits: - items: - type: string - type: array - organizations: - items: - type: string - type: array - postalCodes: - items: - type: string - type: array - provinces: - items: - type: string - type: array - serialNumber: - type: string - streetAddresses: - items: - type: string - type: array - type: object - uris: - items: - type: string - type: array - required: - - alias - type: object - type: array - issuerRef: - properties: - apiGroup: - type: string - kind: - type: string - name: - type: string - required: - - kind - - name - type: object - x-kubernetes-map-type: atomic - type: object - required: - - endpointCert - type: object - leaderElection: - properties: - electionTick: - default: 10 - format: int32 - type: integer - heartbeatTick: - default: 1 - format: int32 - type: integer - period: - default: 100ms - type: string - transferLeadershipInterval: - default: 1s - type: string - transferLeadershipTimeout: - default: 60s - type: string - type: object monitor: properties: agent: @@ -4902,6 +4669,26 @@ spec: items: type: string type: array + leaderElection: + properties: + electionTick: + default: 10 + format: int32 + type: integer + heartbeatTick: + default: 1 + format: int32 + type: integer + period: + default: 100ms + type: string + transferLeadershipInterval: + default: 1s + type: string + transferLeadershipTimeout: + default: 60s + type: string + type: object type: object mode: enum: diff --git a/pkg/admission/namespace/admission.go b/pkg/admission/namespace/admission.go index 58baa0be47..1af1b8716b 100644 --- a/pkg/admission/namespace/admission.go +++ b/pkg/admission/namespace/admission.go @@ -114,8 +114,8 @@ func (a *NamespaceValidator) Admit(req *admission.AdmissionRequest) *admission.A return err } if found && - (terminationPolicy == string(olddbapi.TerminationPolicyHalt) || - terminationPolicy == string(olddbapi.TerminationPolicyDoNotTerminate)) { + (terminationPolicy == string(olddbapi.DeletionPolicyHalt) || + terminationPolicy == string(olddbapi.DeletionPolicyDoNotTerminate)) { return fmt.Errorf("%s %s/%s has termination policy `%s`", u.GetKind(), u.GetNamespace(), u.GetName(), terminationPolicy) } return nil diff --git a/pkg/admission/namespace/admission_test.go b/pkg/admission/namespace/admission_test.go index f68fafcb4e..9bc159ece3 100644 --- a/pkg/admission/namespace/admission_test.go +++ b/pkg/admission/namespace/admission_test.go @@ -111,7 +111,7 @@ var cases = []struct { "demo", admission.Delete, sampleNamespace(), - []runtime.Object{setTerminationPolicy(sampleDatabase(), olddbapi.TerminationPolicyDoNotTerminate)}, + []runtime.Object{setTerminationPolicy(sampleDatabase(), olddbapi.DeletionPolicyDoNotTerminate)}, false, }, { @@ -120,7 +120,7 @@ var cases = []struct { "demo", admission.Delete, sampleNamespace(), - []runtime.Object{setTerminationPolicy(sampleDatabase(), olddbapi.TerminationPolicyHalt)}, + []runtime.Object{setTerminationPolicy(sampleDatabase(), olddbapi.DeletionPolicyHalt)}, false, }, { @@ -129,7 +129,7 @@ var cases = []struct { "demo", admission.Delete, sampleNamespace(), - []runtime.Object{setTerminationPolicy(sampleDatabase(), olddbapi.TerminationPolicyDelete)}, + []runtime.Object{setTerminationPolicy(sampleDatabase(), olddbapi.DeletionPolicyDelete)}, true, }, { @@ -138,7 +138,7 @@ var cases = []struct { "demo", admission.Delete, sampleNamespace(), - []runtime.Object{setTerminationPolicy(sampleDatabase(), olddbapi.TerminationPolicyWipeOut)}, + []runtime.Object{setTerminationPolicy(sampleDatabase(), olddbapi.DeletionPolicyWipeOut)}, true, }, { @@ -178,12 +178,12 @@ func sampleDatabase() *olddbapi.Postgres { }, }, Spec: olddbapi.PostgresSpec{ - TerminationPolicy: olddbapi.TerminationPolicyDelete, + TerminationPolicy: olddbapi.DeletionPolicyDelete, }, } } -func setTerminationPolicy(obj runtime.Object, terminationPolicy olddbapi.TerminationPolicy) runtime.Object { +func setTerminationPolicy(obj runtime.Object, terminationPolicy olddbapi.DeletionPolicy) runtime.Object { db := obj.(*olddbapi.Postgres) db.Spec.TerminationPolicy = terminationPolicy return obj