Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions api/disaggregated/v1/disaggregatedcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package v1
import (
"context"
"fmt"
tdev1 "github.com/apache/doris-operator/api/tde"
"reflect"

"k8s.io/apimachinery/pkg/runtime"
kerrors "k8s.io/apimachinery/pkg/util/errors"
Expand Down Expand Up @@ -50,7 +52,7 @@ func (ddc *DorisDisaggregatedCluster) Default(ctx context.Context, obj runtime.O
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
// +kubebuilder:unnamedwatches:path=/validate-disaggregated-doris-com-v1-dorisdisaggregatedcluster,mutating=false,failurePolicy=ignore,sideEffects=None,groups=disaggregated.cluster.doris.com,resources=dorisdisaggregatedclusters,verbs=create;update,versions=v1,name=vdorisdisaggregatedcluster.kb.io,admissionReviewVersions=v1
// +kubebuilder:unnamedwatches:path=/validate-disaggregated-cluster-doris-com-v1-dorisdisaggregatedcluster,mutating=false,failurePolicy=fail,sideEffects=None,groups=disaggregated.cluster.doris.com,resources=dorisdisaggregatedclusters,verbs=create;update,versions=v1,name=vdorisdisaggregatedcluster.kb.io,admissionReviewVersions=v1
var _ webhook.CustomValidator = &DorisDisaggregatedCluster{}

// ValidateCreate implements webhook.Validator so a unnamedwatches will be registered for the type
Expand All @@ -64,6 +66,9 @@ func (ddc *DorisDisaggregatedCluster) ValidateCreate(ctx context.Context, obj ru
if errs := cluster.validate(); len(errs) != 0 {
return nil, kerrors.NewAggregate(errs)
}
if errs := tdev1.ValidateCreate(cluster.Spec.TDE); len(errs) != 0 {
return nil, kerrors.NewAggregate(errs)
}

return nil, nil
}
Expand All @@ -76,7 +81,20 @@ func (ddc *DorisDisaggregatedCluster) ValidateUpdate(ctx context.Context, oldObj
}
klog.Info("validate update", "name", cluster.Name)

if errs := cluster.validate(); len(errs) != 0 {
oldCluster, ok := oldObj.(*DorisDisaggregatedCluster)
if !ok {
return nil, fmt.Errorf("expected an old DorisDisaggregatedCluster but got %T", oldObj)
}
errs := cluster.validate()
errs = append(errs, tdev1.ValidateUpdate(oldCluster.Spec.TDE, cluster.Spec.TDE, oldCluster.Status.TDE)...)
if tdev1.BlocksFELifecycle(oldCluster.Status.TDE) &&
!reflect.DeepEqual(oldCluster.Spec.FeSpec, cluster.Spec.FeSpec) {
errs = append(errs, fmt.Errorf("spec.feSpec cannot change while a TDE operation or configuration sync is pending"))
}
if !reflect.DeepEqual(oldCluster.Spec.TDE, cluster.Spec.TDE) && !reflect.DeepEqual(oldCluster.Spec.FeSpec, cluster.Spec.FeSpec) {
errs = append(errs, fmt.Errorf("spec.tde and spec.feSpec cannot change in the same update"))
}
if len(errs) != 0 {
return nil, kerrors.NewAggregate(errs)
}

Expand Down
7 changes: 7 additions & 0 deletions api/disaggregated/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
package v1

import (
tdev1 "github.com/apache/doris-operator/api/tde"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type DorisDisaggregatedClusterSpec struct {
// TDE declares cluster-wide transparent data encryption management.
TDE *tdev1.TDEConfig `json:"tde,omitempty"`

//VaultConfigmap specify the configmap that have configuration of file object information. example S3.
//configmap have to config, please reference the doc.
//InstanceConfigMap string `json:"instanceConfigMap,omitempty"`
Expand Down Expand Up @@ -344,6 +348,9 @@ type PortMap struct {
}

type DorisDisaggregatedClusterStatus struct {
// TDE reports the observed encryption configuration and operation state.
TDE *tdev1.TDEStatus `json:"tde,omitempty"`

//describe the metaservice status now.
MetaServiceStatus MetaServiceStatus `json:"metaServiceStatus,omitempty"`

Expand Down
8 changes: 8 additions & 0 deletions api/disaggregated/v1/zz_generated.deepcopy.go

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

17 changes: 17 additions & 0 deletions api/doris/v1/doriscluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ package v1
import (
"context"
"fmt"
tdev1 "github.com/apache/doris-operator/api/tde"
"k8s.io/apimachinery/pkg/runtime"
kerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/klog/v2"
"reflect"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
Expand Down Expand Up @@ -81,6 +83,9 @@ func (r *DorisCluster) ValidateCreate(ctx context.Context, obj runtime.Object) (
if errs := cluster.validateManagementUser(); len(errs) != 0 {
return nil, kerrors.NewAggregate(errs)
}
if errs := tdev1.ValidateCreate(cluster.Spec.TDE); len(errs) != 0 {
return nil, kerrors.NewAggregate(errs)
}

return nil, nil
}
Expand All @@ -94,6 +99,18 @@ func (r *DorisCluster) ValidateUpdate(ctx context.Context, oldObj, newObj runtim
klog.Info("validate update", "name", cluster.Name)
var errors []error
errors = append(errors, cluster.validateManagementUser()...)
oldCluster, ok := oldObj.(*DorisCluster)
if !ok {
return nil, fmt.Errorf("expected an old DorisCluster but got %T", oldObj)
}
errors = append(errors, tdev1.ValidateUpdate(oldCluster.Spec.TDE, cluster.Spec.TDE, oldCluster.Status.TDE)...)
if tdev1.BlocksFELifecycle(oldCluster.Status.TDE) &&
!reflect.DeepEqual(oldCluster.Spec.FeSpec, cluster.Spec.FeSpec) {
errors = append(errors, fmt.Errorf("spec.feSpec cannot change while a TDE operation or configuration sync is pending"))
}
if !reflect.DeepEqual(oldCluster.Spec.TDE, cluster.Spec.TDE) && !reflect.DeepEqual(oldCluster.Spec.FeSpec, cluster.Spec.FeSpec) {
errors = append(errors, fmt.Errorf("spec.tde and spec.feSpec cannot change in the same update"))
}
// fe FeSpec.Replicas must greater than or equal to FeSpec.ElectionNumber
if cluster.Spec.FeSpec.Replicas != nil && *cluster.Spec.FeSpec.Replicas < cluster.GetElectionNumber() {
errors = append(errors, fmt.Errorf("'FeSpec.Replicas' error: the number of FeSpec.Replicas should greater than or equal to FeSpec.ElectionNumber"))
Expand Down
7 changes: 7 additions & 0 deletions api/doris/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package v1

import (
tdev1 "github.com/apache/doris-operator/api/tde"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -30,6 +31,9 @@ var (

// DorisClusterSpec defines the desired state of DorisCluster
type DorisClusterSpec struct {
// TDE declares cluster-wide transparent data encryption management.
TDE *tdev1.TDEConfig `json:"tde,omitempty"`

//defines the fe cluster state that will be created by operator.
FeSpec *FeSpec `json:"feSpec,omitempty"`

Expand Down Expand Up @@ -444,6 +448,9 @@ type DorisServicePort struct {

// DorisClusterStatus defines the observed state of DorisCluster
type DorisClusterStatus struct {
// TDE reports the observed encryption configuration and operation state.
TDE *tdev1.TDEStatus `json:"tde,omitempty"`

//describe fe cluster status, record running, creating and failed pods.
FEStatus *ComponentStatus `json:"feStatus,omitempty"`

Expand Down
8 changes: 8 additions & 0 deletions api/doris/v1/zz_generated.deepcopy.go

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

Loading
Loading