Skip to content

Commit

Permalink
Include Arbiter & hidden nodes in MongoAutoscaler (#979)
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <arnob@appscode.com>

Signed-off-by: Arnob kumar saha <arnob@appscode.com>
  • Loading branch information
ArnobKumarSaha committed Sep 30, 2022
1 parent 3c2f4a7 commit 31c66a3
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apis/autoscaling/v1alpha1/mongodb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ type MongoDBComputeAutoscalerSpec struct {
ConfigServer *ComputeAutoscalerSpec `json:"configServer,omitempty"`
Shard *ComputeAutoscalerSpec `json:"shard,omitempty"`
Mongos *ComputeAutoscalerSpec `json:"mongos,omitempty"`
Arbiter *ComputeAutoscalerSpec `json:"arbiter,omitempty"`
Hidden *ComputeAutoscalerSpec `json:"hidden,omitempty"`
}

type MongoDBStorageAutoscalerSpec struct {
Standalone *StorageAutoscalerSpec `json:"standalone,omitempty"`
ReplicaSet *StorageAutoscalerSpec `json:"replicaSet,omitempty"`
ConfigServer *StorageAutoscalerSpec `json:"configServer,omitempty"`
Shard *StorageAutoscalerSpec `json:"shard,omitempty"`
Hidden *StorageAutoscalerSpec `json:"hidden,omitempty"`
}

type MongoDBOpsRequestOptions struct {
Expand Down
14 changes: 14 additions & 0 deletions apis/autoscaling/v1alpha1/mongodb_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (in *MongoDBAutoscaler) setDefaults() {
setDefaultStorageValues(in.Spec.Storage.ReplicaSet)
setDefaultStorageValues(in.Spec.Storage.Shard)
setDefaultStorageValues(in.Spec.Storage.ConfigServer)
setDefaultStorageValues(in.Spec.Storage.Hidden)
}

if in.Spec.Compute != nil {
Expand All @@ -64,6 +65,8 @@ func (in *MongoDBAutoscaler) setDefaults() {
setDefaultComputeValues(in.Spec.Compute.Shard)
setDefaultComputeValues(in.Spec.Compute.ConfigServer)
setDefaultComputeValues(in.Spec.Compute.Mongos)
setDefaultComputeValues(in.Spec.Compute.Arbiter)
setDefaultComputeValues(in.Spec.Compute.Hidden)
}
}

Expand All @@ -85,6 +88,8 @@ func (in *MongoDBAutoscaler) SetDefaults(db *dbapi.MongoDB) {
setInMemoryDefaults(in.Spec.Compute.Shard, db.Spec.StorageEngine)
setInMemoryDefaults(in.Spec.Compute.ConfigServer, db.Spec.StorageEngine)
setInMemoryDefaults(in.Spec.Compute.Mongos, db.Spec.StorageEngine)
// no need for Defaulting the Arbiter & Hidden Node.
// As arbiter is not a data-node. And hidden doesn't have the impact of storageEngine (it can't be InMemory).
}
}

Expand Down Expand Up @@ -151,6 +156,12 @@ func (in *MongoDBAutoscaler) ValidateFields(mg *dbapi.MongoDB) error {
if cm.Mongos != nil {
return errors.New("Spec.Compute.Mongos is invalid for Standalone mongoDB")
}
if cm.Arbiter != nil {
return errors.New("Spec.Compute.Arbiter is invalid for Standalone mongoDB")
}
if cm.Hidden != nil {
return errors.New("Spec.Compute.Hidden is invalid for Standalone mongoDB")
}
}
}

Expand Down Expand Up @@ -183,6 +194,9 @@ func (in *MongoDBAutoscaler) ValidateFields(mg *dbapi.MongoDB) error {
if st.ConfigServer != nil {
return errors.New("Spec.Storage.ConfigServer is invalid for Standalone mongoDB")
}
if st.Hidden != nil {
return errors.New("Spec.Storage.Hidden is invalid for Standalone mongoDB")
}
}
}
return nil
Expand Down
15 changes: 15 additions & 0 deletions apis/autoscaling/v1alpha1/openapi_generated.go

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

15 changes: 15 additions & 0 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.

104 changes: 104 additions & 0 deletions crds/autoscaling.kubedb.com_mongodbautoscalers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,50 @@ spec:
properties:
compute:
properties:
arbiter:
properties:
containerControlledValues:
enum:
- RequestsAndLimits
- RequestsOnly
type: string
controlledResources:
items:
type: string
type: array
inMemoryStorage:
properties:
scalingFactorPercentage:
format: int32
type: integer
usageThresholdPercentage:
format: int32
type: integer
type: object
maxAllowed:
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
minAllowed:
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
podLifeTimeThreshold:
type: string
resourceDiffPercentage:
format: int32
type: integer
trigger:
type: string
type: object
configServer:
properties:
containerControlledValues:
Expand Down Expand Up @@ -78,6 +122,50 @@ spec:
trigger:
type: string
type: object
hidden:
properties:
containerControlledValues:
enum:
- RequestsAndLimits
- RequestsOnly
type: string
controlledResources:
items:
type: string
type: array
inMemoryStorage:
properties:
scalingFactorPercentage:
format: int32
type: integer
usageThresholdPercentage:
format: int32
type: integer
type: object
maxAllowed:
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
minAllowed:
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
podLifeTimeThreshold:
type: string
resourceDiffPercentage:
format: int32
type: integer
trigger:
type: string
type: object
mongos:
properties:
containerControlledValues:
Expand Down Expand Up @@ -302,6 +390,22 @@ spec:
format: int32
type: integer
type: object
hidden:
properties:
expansionMode:
enum:
- Offline
- Online
type: string
scalingThreshold:
format: int32
type: integer
trigger:
type: string
usageThreshold:
format: int32
type: integer
type: object
replicaSet:
properties:
expansionMode:
Expand Down

0 comments on commit 31c66a3

Please sign in to comment.