Skip to content

Commit

Permalink
Fix EACRuntime controller scaling out bug (fluid-cloudnative#2628)
Browse files Browse the repository at this point in the history
* Fix EACRuntime controller scaling out bug

Signed-off-by: dongyun.xzh <[email protected]>

* FIx scaling out bug for All runtimes

Signed-off-by: dongyun.xzh <[email protected]>

---------

Signed-off-by: dongyun.xzh <[email protected]>
  • Loading branch information
TrafalgarZZZ authored Feb 20, 2023
1 parent 7233437 commit 6eb0910
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
control-plane: alluxioruntime-controller
annotations:
{{ if gt (.Values.runtime.alluxio.replicas | int) 1 -}}
replicas: {{ .Values.runtime.alluxio.replicas | quote }}
controller.runtime.fluid.io/replicas: {{ .Values.runtime.alluxio.replicas | quote }}
{{- end }}
spec:
{{- with .Values.image.imagePullSecrets }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{ if .Values.runtime.eac.enabled -}}
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -11,11 +10,19 @@ spec:
selector:
matchLabels:
control-plane: eacruntime-controller
{{ if .Values.runtime.eac.enabled -}}
replicas: {{ .Values.runtime.eac.replicas }}
{{- else }}
replicas: 0
{{- end }}
template:
metadata:
labels:
control-plane: eacruntime-controller
annotations:
{{ if gt (.Values.runtime.eac.replicas | int ) 1 -}}
controller.runtime.fluid.io/replicas: {{ .Values.runtime.eac.replicas | quote }}
{{- end }}
spec:
{{- with .Values.image.imagePullSecrets }}
imagePullSecrets:
Expand Down Expand Up @@ -84,4 +91,3 @@ spec:
cpu: 100m
memory: 200Mi
terminationGracePeriodSeconds: 10
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
control-plane: goosefsruntime-controller
annotations:
{{ if gt (.Values.runtime.goosefs.replicas | int) 1 -}}
replicas: {{ .Values.runtime.goosefs.replicas | quote }}
controller.runtime.fluid.io/replicas: {{ .Values.runtime.goosefs.replicas | quote }}
{{- end }}
spec:
{{- with .Values.image.imagePullSecrets }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
control-plane: jindoruntime-controller
annotations:
{{ if gt (.Values.runtime.jindo.replicas | int) 1 -}}
replicas: {{ .Values.runtime.jindo.replicas | quote }}
controller.runtime.fluid.io/replicas: {{ .Values.runtime.jindo.replicas | quote }}
{{- end }}
spec:
{{- with .Values.image.imagePullSecrets }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
control-plane: juicefsruntime-controller
annotations:
{{ if gt (.Values.runtime.juicefs.replicas | int) 1 -}}
replicas: {{ .Values.runtime.juicefs.replicas | quote }}
controller.runtime.fluid.io/replicas: {{ .Values.runtime.juicefs.replicas | quote }}
{{- end }}
spec:
{{- with .Values.image.imagePullSecrets }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
control-plane: thinruntime-controller
annotations:
{{ if gt (.Values.runtime.thin.replicas | int) 1 -}}
replicas: {{ .Values.runtime.thin.replicas | quote }}
controller.runtime.fluid.io/replicas: {{ .Values.runtime.thin.replicas | quote }}
{{- end }}
spec:
serviceAccountName: thinruntime-controller
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/deploy/runtime_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func ScaleoutRuntimeContollerOnDemand(c client.Client, datasetKey types.Namespac
return controllerName, scaleout, fmt.Errorf("no matched controller for dataset %s", datasetKey)
}

// scale out deployment If needed
// scaleoutDeploymentIfNeeded scales out runtime controller deployments if the current replica of it is 0.
func scaleoutDeploymentIfNeeded(c client.Client, key types.NamespacedName, log logr.Logger) (scale bool, err error) {
err = retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) {
deploy := &appsv1.Deployment{}
Expand Down
8 changes: 8 additions & 0 deletions pkg/ddc/eac/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import (
"github.com/fluid-cloudnative/fluid/pkg/ctrl"
"github.com/fluid-cloudnative/fluid/pkg/ddc/base"
cruntime "github.com/fluid-cloudnative/fluid/pkg/runtime"
"github.com/fluid-cloudnative/fluid/pkg/utils"
"github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient"
"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -86,3 +88,9 @@ func (e *EACEngine) parseRuntime(ctx cruntime.ReconcileRequestContext) error {
}
return nil
}

// Precheck checks if the given key can be found in the current runtime types
func Precheck(client client.Client, key types.NamespacedName) (found bool, err error) {
var obj datav1alpha1.EACRuntime
return utils.CheckObject(client, key, &obj)
}
1 change: 1 addition & 0 deletions pkg/ddc/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func init() {
"juicefsruntime-controller": juicefs.Precheck,
"goosefsruntime-controller": goosefs.Precheck,
"thinruntime-controller": thin.Precheck,
"eacruntime-controller": eac.Precheck,
})
}

Expand Down

0 comments on commit 6eb0910

Please sign in to comment.