Skip to content

Commit

Permalink
chore: rename dn to tn (#424)
Browse files Browse the repository at this point in the history
Signed-off-by: Aylei <[email protected]>
  • Loading branch information
aylei authored Sep 6, 2023
1 parent b2d97d7 commit c64a2d6
Show file tree
Hide file tree
Showing 15 changed files with 369 additions and 27 deletions.
2 changes: 1 addition & 1 deletion api/core/v1alpha1/matrixonecluster_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (m *MatrixOneCluster) LogSetImage() string {
}

func (m *MatrixOneCluster) DnSetImage() string {
image := m.Spec.DN.Image
image := m.GetTN().Image
if image == "" {
image = m.DefaultImage()
}
Expand Down
13 changes: 12 additions & 1 deletion api/core/v1alpha1/matrixonecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ type MatrixOneClusterSpec struct {
CNGroups []CNGroup `json:"cnGroups,omitempty"`

// DN is the default DN pod set of this Cluster
DN DNSetSpec `json:"dn"`
// Deprecated: use TN instead
DN *DNSetSpec `json:"dn,omitempty"`

// TN is the default TN pod set of this Cluster
TN *DNSetSpec `json:"tn,omitempty"`

// LogService is the default LogService pod set of this cluster
LogService LogSetSpec `json:"logService"`
Expand Down Expand Up @@ -82,6 +86,13 @@ type MatrixOneClusterSpec struct {
RestoreFrom *string `json:"restoreFrom,omitempty"`
}

func (m *MatrixOneCluster) GetTN() *DNSetSpec {
if m.Spec.TN == nil {
return m.Spec.DN
}
return m.Spec.TN
}

type CNGroup struct {
CNSetSpec `json:",inline"`

Expand Down
15 changes: 13 additions & 2 deletions api/core/v1alpha1/matrixonecluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ var _ webhook.Defaulter = &MatrixOneCluster{}
// Default implements webhook.Defaulter so a webhook will be registered for the type
func (r *MatrixOneCluster) Default() {
r.Spec.LogService.Default()
r.Spec.DN.Default()
if r.Spec.DN != nil {
r.Spec.DN.Default()
}
if r.Spec.TN != nil {
r.Spec.TN.Default()
}
if r.Spec.TP != nil {
r.Spec.TP.Default()
}
Expand All @@ -59,6 +64,12 @@ var _ webhook.Validator = &MatrixOneCluster{}
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *MatrixOneCluster) ValidateCreate() (admission.Warnings, error) {
var errs field.ErrorList
if r.Spec.DN == nil && r.Spec.TN == nil {
errs = append(errs, field.Invalid(field.NewPath("spec").Child("tn"), "", ".spec.tn must be set"))
}
if r.Spec.DN != nil && r.Spec.TN != nil {
errs = append(errs, field.Invalid(field.NewPath("spec").Child("dn"), "", "legacy component .spec.dn cannot be set when .spec.tn is set"))
}
errs = append(errs, r.validateMutateCommon()...)
errs = append(errs, r.Spec.LogService.ValidateCreate(LogSetKey(r))...)
return nil, invalidOrNil(errs, r)
Expand All @@ -75,7 +86,7 @@ func (r *MatrixOneCluster) ValidateUpdate(o runtime.Object) (admission.Warnings,

func (r *MatrixOneCluster) validateMutateCommon() field.ErrorList {
var errs field.ErrorList
errs = append(errs, r.Spec.DN.ValidateCreate()...)
errs = append(errs, r.GetTN().ValidateCreate()...)
groups := map[string]bool{}
if r.Spec.TP != nil {
errs = append(errs, r.Spec.TP.ValidateCreate()...)
Expand Down
12 changes: 6 additions & 6 deletions api/core/v1alpha1/matrixonecluster_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var _ = Describe("MatrixOneCluster Webhook", func() {
S3: &S3Provider{Path: "test/data"},
},
},
DN: DNSetSpec{
TN: &DNSetSpec{
PodSet: PodSet{
Replicas: 2,
},
Expand All @@ -65,7 +65,7 @@ var _ = Describe("MatrixOneCluster Webhook", func() {
Expect(k8sClient.Create(context.TODO(), func() *MatrixOneCluster {
singleReplica := v06.DeepCopy()
singleReplica.Spec.LogService.Replicas = 1
singleReplica.Spec.DN.Replicas = 1
singleReplica.Spec.TN.Replicas = 1
singleReplica.Spec.TP.Replicas = 1
singleReplica.Name = "mo-" + randomString(5)
return singleReplica
Expand All @@ -90,7 +90,7 @@ var _ = Describe("MatrixOneCluster Webhook", func() {
S3: &S3Provider{Path: "test/data"},
},
},
DN: DNSetSpec{
TN: &DNSetSpec{
PodSet: PodSet{
Replicas: 2,
},
Expand Down Expand Up @@ -141,7 +141,7 @@ var _ = Describe("MatrixOneCluster Webhook", func() {
},
},
},
DN: DNSetSpec{
TN: &DNSetSpec{
PodSet: PodSet{
Replicas: 2,
},
Expand Down Expand Up @@ -200,7 +200,7 @@ var _ = Describe("MatrixOneCluster Webhook", func() {
},
},
},
DN: DNSetSpec{
TN: &DNSetSpec{
PodSet: PodSet{
Replicas: 2,
},
Expand Down Expand Up @@ -268,7 +268,7 @@ var _ = Describe("MatrixOneCluster Webhook", func() {
},
},
},
DN: DNSetSpec{
TN: &DNSetSpec{
PodSet: PodSet{
Replicas: 1,
},
Expand Down
11 changes: 10 additions & 1 deletion api/core/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ spec:
- name
x-kubernetes-list-type: map
dn:
description: DN is the default DN pod set of this Cluster
description: 'DN is the default DN pod set of this Cluster Deprecated:
use TN instead'
properties:
cacheVolume:
description: CacheVolume is the desired local cache volume for
Expand Down Expand Up @@ -1059,6 +1060,161 @@ spec:
type: object
restoreFrom:
type: string
tn:
description: TN is the default TN pod set of this Cluster
properties:
cacheVolume:
description: CacheVolume is the desired local cache volume for
DNSet, node storage will be used if not specified
properties:
memoryCacheSize:
anyOf:
- type: integer
- type: string
description: 'Deprecated: use SharedStorageCache instead'
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
size:
anyOf:
- type: integer
- type: string
description: Size is the desired storage size of the volume
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
storageClassName:
description: StorageClassName reference to the storageclass
of the desired volume, the default storageclass of the cluster
would be used if no specified.
type: string
type: object
clusterDomain:
description: ClusterDomain is the cluster-domain of current kubernetes
cluster, refer https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/
for details
type: string
config:
description: Config is the raw config for pods
type: string
dnsBasedIdentity:
description: If enabled, use the Pod dns name as the Pod identity
type: boolean
image:
description: Image is the docker image of the main container
type: string
memoryLimitPercent:
description: MemoryLimitPercent is percent used to set GOMEMLIMIT
env, its value must be in interval (0, 100]. GOMEMLIMIT = limits.memory
* MemoryLimitPercent / 100
type: integer
nodeSelector:
additionalProperties:
type: string
type: object
overlay:
x-kubernetes-preserve-unknown-fields: true
replicas:
description: Replicas is the desired number of pods of this set
format: int32
type: integer
resources:
description: Resources is the resource requirement of the main
conainer
properties:
claims:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable. It can only be
set for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: Name must match the name of one entry in
pod.spec.resourceClaims of the Pod where this field
is used. It makes that resource available inside a
container.
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
description: 'Limits describes the maximum amount of compute
resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
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
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. Requests cannot exceed
Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
serviceArgs:
description: 'ServiceArgs define command line options for process,
used by logset/cnset/dnset service. NOTE: user should not define
"-cfg" argument in this field, which is defined default by controller'
items:
type: string
type: array
sharedStorageCache:
properties:
diskCacheSize:
anyOf:
- type: integer
- type: string
description: 'DiskCacheSize specifies how much disk space
can be used to cache the object in shared storage, the default
size would be 90% of the cacheVolume size to reserve some
space to the filesystem metadata and avoid disk space exhaustion
DiskCache would be disabled if CacheVolume is not set for
DN/CN, and if DiskCacheSize is set while the CacheVolume
is not set for DN/CN, an error would be raised to indicate
the misconfiguration. NOTE: Unless there is a specific reason
not to set this field, it is usually more reasonable to
let the operator set the available disk cache size according
to the actual size of the cacheVolume.'
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memoryCacheSize:
anyOf:
- type: integer
- type: string
description: MemoryCacheSize specifies how much memory would
be used to cache the object in shared storage, the default
size would be 50% of the container memory request MemoryCache
cannot be completely disabled due to MO limitation currently,
you can set MemoryCacheSize to 1B to achieve an effect similar
to disabling
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
topologySpread:
description: TopologyEvenSpread specifies what topology domains
the Pods in set should be evenly spread in. This will be overridden
by .overlay.TopologySpreadConstraints
items:
type: string
type: array
required:
- replicas
type: object
topologySpread:
description: TopologyEvenSpread specifies default topology policy
for all components, this will be overridden by component-level config
Expand Down Expand Up @@ -1442,7 +1598,6 @@ spec:
- replicas
type: object
required:
- dn
- logService
- version
type: object
Expand Down
Loading

0 comments on commit c64a2d6

Please sign in to comment.