Skip to content

Commit

Permalink
Merge branch 'master' into solr-ops
Browse files Browse the repository at this point in the history
  • Loading branch information
pritamdas99 authored Aug 2, 2024
2 parents 8f45f15 + 9cb2a30 commit 72692e3
Show file tree
Hide file tree
Showing 57 changed files with 2,265 additions and 235 deletions.
2 changes: 1 addition & 1 deletion apis/autoscaling/v1alpha1/mongodb_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (in *MongoDBAutoscaler) ValidateCreate() (admission.Warnings, error) {

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (in *MongoDBAutoscaler) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
mongoLog.Info("validate create", "name", in.Name)
mongoLog.Info("validate update", "name", in.Name)
return nil, in.validate()
}

Expand Down
23 changes: 6 additions & 17 deletions apis/autoscaling/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions apis/autoscaling/v1alpha1/pgbouncer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ type PgBouncerAutoscaler struct {
type PgBouncerAutoscalerSpec struct {
DatabaseRef *core.LocalObjectReference `json:"databaseRef"`

// This field will be used to control the behaviour of ops-manager
// OpsRequestOptions will be used to control the behaviour of ops-manager
OpsRequestOptions *PgBouncerOpsRequestOptions `json:"opsRequestOptions,omitempty"`

Compute *PgBouncerComputeAutoscalerSpec `json:"compute,omitempty"`
Storage *PgBouncerStorageAutoscalerSpec `json:"storage,omitempty"`
}

type PgBouncerComputeAutoscalerSpec struct {
Expand All @@ -79,13 +78,10 @@ type PgBouncerStorageAutoscalerSpec struct {
}

type PgBouncerOpsRequestOptions struct {
// Specifies the Readiness Criteria
ReadinessCriteria *opsapi.PgBouncerReplicaReadinessCriteria `json:"readinessCriteria,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.
// Apply is to control the execution of OpsRequest depending on the database state.
// +kubebuilder:default="IfReady"
Apply opsapi.ApplyOption `json:"apply,omitempty"`
}
Expand Down
24 changes: 16 additions & 8 deletions apis/autoscaling/v1alpha1/pgbouncer_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,27 @@ import (

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/builder"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
var pbLog = logf.Log.WithName("pgbouncer-autoscaler")

func (in *PgBouncerAutoscaler) SetupWebhookWithManager(mgr manager.Manager) error {
return builder.WebhookManagedBy(mgr).
For(in).
Complete()
}

// +kubebuilder:webhook:path=/mutate-autoscaling-kubedb-com-v1alpha1-pgbouncerautoscaler,mutating=true,failurePolicy=fail,sideEffects=None,groups=autoscaling.kubedb.com,resources=pgbouncerautoscaler,verbs=create;update,versions=v1alpha1,name=mpgbouncerautoscaler.kb.io,admissionReviewVersions={v1,v1beta1}

var _ webhook.Defaulter = &PgBouncerAutoscaler{}

// Default implements webhook.CustomDefaulter so a webhook will be registered for the type
// Default implements webhook.Defaulter so a webhook will be registered for the type
func (r *PgBouncerAutoscaler) Default() {
pbLog.Info("defaulting", "name", r.Name)
r.setDefaults()
Expand All @@ -55,10 +65,6 @@ func (r *PgBouncerAutoscaler) setDefaults() {

r.setOpsReqOptsDefaults()

if r.Spec.Storage != nil {
setDefaultStorageValues(r.Spec.Storage.PgBouncer)
}

if r.Spec.Compute != nil {
setDefaultComputeValues(r.Spec.Compute.PgBouncer)
}
Expand All @@ -75,6 +81,8 @@ func (r *PgBouncerAutoscaler) setOpsReqOptsDefaults() {
}
}

// +kubebuilder:webhook:path=/validate-schema-kubedb-com-v1alpha1-pgbouncerautoscaler,mutating=false,failurePolicy=fail,sideEffects=None,groups=schema.kubedb.com,resources=pgbouncerautoscalers,verbs=create;update;delete,versions=v1alpha1,name=vpgbouncerautoscaler.kb.io,admissionReviewVersions={v1,v1beta1}

var _ webhook.Validator = &PgBouncerAutoscaler{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
Expand All @@ -85,7 +93,7 @@ func (r *PgBouncerAutoscaler) ValidateCreate() (admission.Warnings, error) {

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *PgBouncerAutoscaler) ValidateUpdate(oldObj runtime.Object) (admission.Warnings, error) {
pbLog.Info("validate create", "name", r.Name)
pbLog.Info("validate update", "name", r.Name)
return nil, r.validate()
}

Expand All @@ -97,11 +105,11 @@ func (r *PgBouncerAutoscaler) validate() error {
if r.Spec.DatabaseRef == nil {
return errors.New("databaseRef can't be empty")
}
var kf dbapi.PgBouncer
var bouncer dbapi.PgBouncer
err := DefaultClient.Get(context.TODO(), types.NamespacedName{
Name: r.Spec.DatabaseRef.Name,
Namespace: r.Namespace,
}, &kf)
}, &bouncer)
if err != nil {
_ = fmt.Errorf("can't get PgBouncer %s/%s \n", r.Namespace, r.Spec.DatabaseRef.Name)
return err
Expand Down
2 changes: 1 addition & 1 deletion apis/autoscaling/v1alpha1/pgpool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type PgpoolAutoscaler struct {
type PgpoolAutoscalerSpec struct {
DatabaseRef *core.LocalObjectReference `json:"databaseRef"`

// This field will be used to control the behaviour of ops-manager
// OpsRequestOptions will be used to control the behaviour of ops-manager
OpsRequestOptions *PgpoolOpsRequestOptions `json:"opsRequestOptions,omitempty"`

Compute *PgpoolComputeAutoscalerSpec `json:"compute,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion apis/autoscaling/v1alpha1/pgpool_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (r *PgpoolAutoscaler) ValidateCreate() (admission.Warnings, error) {

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *PgpoolAutoscaler) ValidateUpdate(oldObj runtime.Object) (admission.Warnings, error) {
pgpoolLog.Info("validate create", "name", r.Name)
pgpoolLog.Info("validate update", "name", r.Name)
return nil, r.validate()
}

Expand Down
2 changes: 1 addition & 1 deletion apis/autoscaling/v1alpha1/postgres_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type PostgresAutoscaler struct {
type PostgresAutoscalerSpec struct {
DatabaseRef *core.LocalObjectReference `json:"databaseRef"`

// This field will be used to control the behaviour of ops-manager
// OpsRequestOptions will be used to control the behaviour of ops-manager
OpsRequestOptions *PostgresOpsRequestOptions `json:"opsRequestOptions,omitempty"`

Compute *PostgresComputeAutoscalerSpec `json:"compute,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion apis/autoscaling/v1alpha1/postgres_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (in *PostgresAutoscaler) ValidateCreate() (admission.Warnings, error) {

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (in *PostgresAutoscaler) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
pgLog.Info("validate create", "name", in.Name)
pgLog.Info("validate update", "name", in.Name)
return nil, in.validate()
}

Expand Down
2 changes: 1 addition & 1 deletion apis/autoscaling/v1alpha1/proxysql_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (in *ProxySQLAutoscaler) ValidateCreate() (admission.Warnings, error) {

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (in *ProxySQLAutoscaler) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
proxyLog.Info("validate create", "name", in.Name)
proxyLog.Info("validate update", "name", in.Name)
return nil, in.validate()
}

Expand Down
2 changes: 1 addition & 1 deletion apis/autoscaling/v1alpha1/rabbitmq_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (r *RabbitMQAutoscaler) ValidateCreate() (admission.Warnings, error) {

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *RabbitMQAutoscaler) ValidateUpdate(oldObj runtime.Object) (admission.Warnings, error) {
rabbitLog.Info("validate create", "name", r.Name)
rabbitLog.Info("validate update", "name", r.Name)
return nil, r.validate()
}

Expand Down
2 changes: 1 addition & 1 deletion apis/autoscaling/v1alpha1/redis_sentinel_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (in *RedisSentinelAutoscaler) ValidateCreate() (admission.Warnings, error)

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (in *RedisSentinelAutoscaler) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
rsLog.Info("validate create", "name", in.Name)
rsLog.Info("validate update", "name", in.Name)
return nil, in.validate()
}

Expand Down
2 changes: 1 addition & 1 deletion apis/autoscaling/v1alpha1/redis_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (in *RedisAutoscaler) ValidateCreate() (admission.Warnings, error) {

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (in *RedisAutoscaler) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
redisLog.Info("validate create", "name", in.Name)
redisLog.Info("validate update", "name", in.Name)
return nil, in.validate()
}

Expand Down
12 changes: 12 additions & 0 deletions apis/autoscaling/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ func Resource(resource string) schema.GroupResource {
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&ClickHouseAutoscaler{},
&ClickHouseAutoscalerList{},
&DruidAutoscaler{},
&DruidAutoscalerList{},
&ElasticsearchAutoscaler{},
&ElasticsearchAutoscalerList{},
&EtcdAutoscaler{},
&EtcdAutoscalerList{},
&FerretDBAutoscaler{},
&FerretDBAutoscalerList{},
&KafkaAutoscaler{},
&KafkaAutoscalerList{},
&MariaDBAutoscaler{},
Expand All @@ -68,10 +72,14 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&MemcachedAutoscalerList{},
&MongoDBAutoscaler{},
&MongoDBAutoscalerList{},
&MSSQLServerAutoscaler{},
&MSSQLServerAutoscalerList{},
&MySQLAutoscaler{},
&MySQLAutoscalerList{},
&PerconaXtraDBAutoscaler{},
&PerconaXtraDBAutoscalerList{},
&PgBouncerAutoscaler{},
&PgBouncerAutoscalerList{},
&PgpoolAutoscaler{},
&PgpoolAutoscalerList{},
&PostgresAutoscaler{},
Expand All @@ -86,6 +94,10 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&RedisSentinelAutoscalerList{},
&SinglestoreAutoscaler{},
&SinglestoreAutoscalerList{},
&SolrAutoscaler{},
&SolrAutoscalerList{},
&ZooKeeperAutoscaler{},
&ZooKeeperAutoscalerList{},
)

scheme.AddKnownTypes(SchemeGroupVersion,
Expand Down
2 changes: 1 addition & 1 deletion apis/autoscaling/v1alpha1/singlestore_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (s *SinglestoreAutoscaler) ValidateCreate() (admission.Warnings, error) {

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (s *SinglestoreAutoscaler) ValidateUpdate(oldObj runtime.Object) (admission.Warnings, error) {
kafkaLog.Info("validate create", "name", s.Name)
kafkaLog.Info("validate update", "name", s.Name)
return nil, s.validate()
}

Expand Down
2 changes: 1 addition & 1 deletion apis/autoscaling/v1alpha1/solr_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (r *SolrAutoscaler) ValidateCreate() (admission.Warnings, error) {

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *SolrAutoscaler) ValidateUpdate(oldObj runtime.Object) (admission.Warnings, error) {
sllog.Info("validate create", "name", r.Name)
sllog.Info("validate update", "name", r.Name)
return nil, r.validate()
}

Expand Down
2 changes: 1 addition & 1 deletion apis/autoscaling/v1alpha1/zookeeper_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (r *ZooKeeperAutoscaler) ValidateCreate() (admission.Warnings, error) {

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *ZooKeeperAutoscaler) ValidateUpdate(oldObj runtime.Object) (admission.Warnings, error) {
zkLog.Info("validate create", "name", r.Name)
zkLog.Info("validate update", "name", r.Name)
return nil, r.validate()
}

Expand Down
10 changes: 0 additions & 10 deletions apis/autoscaling/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions apis/catalog/v1alpha1/mssql_version_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ type MSSQLServerVersionSpec struct {
// Coordinator Image
// +optional
Coordinator MSSQLServerCoordinator `json:"coordinator,omitempty"`
// Exporter Image
Exporter MSSQLServerVersionExporter `json:"exporter"`
// Init container Image
InitContainer MSSQLServerInitContainer `json:"initContainer"`
// Deprecated versions usable but regarded as obsolete and best avoided, typically due to having been superseded.
Expand Down Expand Up @@ -82,6 +84,11 @@ type MSSQLServerCoordinator struct {
Image string `json:"image"`
}

// MSSQLServerVersionExporter is the image for the MSSQL Server exporter
type MSSQLServerVersionExporter struct {
Image string `json:"image"`
}

// MSSQLServerInitContainer is the MSSQLServer Container initializer
type MSSQLServerInitContainer struct {
Image string `json:"image"`
Expand Down
Loading

0 comments on commit 72692e3

Please sign in to comment.