diff --git a/charts/README.md b/charts/README.md index 2f0eba1c..34c65f0c 100644 --- a/charts/README.md +++ b/charts/README.md @@ -66,6 +66,7 @@ Parameter | Description | Default `prometheus.serviceEndpoint` | If prometheus.enabled is false, please assign the prometheus service URL that is accessible by components. | `nil` `canaryDeployment.enabled` | Set to true if you need canary deployment feature | `true` in `fission-all`, `false` in `fission-core` `extraCoreComponentPodConfig` | Extend the container specs for the core fission pods. Can be used to add things like affinty/tolerations/nodeSelectors/etc. | None +`executor.adoptExistingResources` | If true, executor will try to adopt existing resources created by the old executor instance. | `false` `router.deployAsDaemonSet` | Deploy router as DaemonSet instead of Deployment | `false` `router.svcAddressMaxRetries` | Max retries times for router to retry on a certain service URL returns from cache/executor | `5` `router.svcAddressUpdateTimeout` | The length of update lock expiry time for router to get a service URL returns from executor | `30` diff --git a/charts/fission-all/templates/deployment.yaml b/charts/fission-all/templates/deployment.yaml index 5b21bcb5..1d045a95 100644 --- a/charts/fission-all/templates/deployment.yaml +++ b/charts/fission-all/templates/deployment.yaml @@ -215,6 +215,8 @@ spec: value: "{{ .Values.pullPolicy }}" - name: RUNTIME_IMAGE_PULL_POLICY value: "{{ .Values.pullPolicy }}" + - name: ADOPT_EXISTING_RESOURCES + value: {{ .Values.executor.adoptExistingResources | default false | quote }} - name: ENABLE_ISTIO value: "{{ .Values.enableIstio }}" - name: TRACE_JAEGER_COLLECTOR_ENDPOINT diff --git a/charts/fission-all/values.yaml b/charts/fission-all/values.yaml index 6262bef1..765b01bb 100644 --- a/charts/fission-all/values.yaml +++ b/charts/fission-all/values.yaml @@ -65,6 +65,9 @@ logger: ## security context and set privileged to true. enableSecurityContext: false +executor: + adoptExistingResources: false + ## Router config router: deployAsDaemonSet: false diff --git a/charts/fission-core/templates/deployment.yaml b/charts/fission-core/templates/deployment.yaml index c0dc8a2f..5061c11f 100644 --- a/charts/fission-core/templates/deployment.yaml +++ b/charts/fission-core/templates/deployment.yaml @@ -217,6 +217,8 @@ spec: value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} + - name: ADOPT_EXISTING_RESOURCES + value: {{ .Values.executor.adoptExistingResources | default false | quote }} - name: ENABLE_ISTIO value: "{{ .Values.enableIstio }}" - name: FETCHER_MINCPU diff --git a/charts/fission-core/values.yaml b/charts/fission-core/values.yaml index 5d476160..1d038eb0 100644 --- a/charts/fission-core/values.yaml +++ b/charts/fission-core/values.yaml @@ -45,6 +45,9 @@ builderNamespace: fission-builder ## Enable istio integration enableIstio: false +executor: + adoptExistingResources: false + ## Router config router: deployAsDaemonSet: false diff --git a/pkg/executor/executor.go b/pkg/executor/executor.go index bdace374..c3aedda3 100644 --- a/pkg/executor/executor.go +++ b/pkg/executor/executor.go @@ -20,6 +20,8 @@ import ( "context" "fmt" "net/http" + "os" + "strconv" "strings" "sync" "time" @@ -242,16 +244,18 @@ func StartExecutor(logger *zap.Logger, functionNamespace string, envBuilderNames executorTypes[gpm.GetTypeName()] = gpm executorTypes[ndm.GetTypeName()] = ndm - wg := &sync.WaitGroup{} - for _, et := range executorTypes { - wg.Add(1) - go func(et executortype.ExecutorType) { - defer wg.Done() - et.AdoptOrphanResources() - }(et) + if ok, _ := strconv.ParseBool(os.Getenv("ADOPT_EXISTING_RESOURCES")); ok { + wg := &sync.WaitGroup{} + for _, et := range executorTypes { + wg.Add(1) + go func(et executortype.ExecutorType) { + defer wg.Done() + et.AdoptExistingResources() + }(et) + } + // set hard timeout for resource adoption + util.WaitTimeout(wg, 30*time.Second) } - // set hard timeout for resource adoption - util.WaitTimeout(wg, 30*time.Second) cms := cms.MakeConfigSecretController(logger, fissionClient, kubernetesClient, executorTypes) diff --git a/pkg/executor/executortype/executortype.go b/pkg/executor/executortype/executortype.go index cb41d411..ad126738 100644 --- a/pkg/executor/executortype/executortype.go +++ b/pkg/executor/executortype/executortype.go @@ -52,5 +52,5 @@ type ExecutorType interface { RefreshFuncPods(*zap.Logger, fv1.Function) error // AdoptOrphanResources adopts existing resources created by the deleted executor. - AdoptOrphanResources() + AdoptExistingResources() } diff --git a/pkg/executor/executortype/newdeploy/newdeploymgr.go b/pkg/executor/executortype/newdeploy/newdeploymgr.go index 27577784..10f17dd5 100644 --- a/pkg/executor/executortype/newdeploy/newdeploymgr.go +++ b/pkg/executor/executortype/newdeploy/newdeploymgr.go @@ -244,7 +244,7 @@ func (deploy *NewDeploy) RefreshFuncPods(logger *zap.Logger, f fv1.Function) err return nil } -func (deploy *NewDeploy) AdoptOrphanResources() { +func (deploy *NewDeploy) AdoptExistingResources() { l := map[string]string{ types.EXECUTOR_TYPE: string(fv1.ExecutorTypeNewdeploy), } diff --git a/pkg/executor/executortype/poolmgr/gpm.go b/pkg/executor/executortype/poolmgr/gpm.go index 2c73d6cf..b86df3f5 100644 --- a/pkg/executor/executortype/poolmgr/gpm.go +++ b/pkg/executor/executortype/poolmgr/gpm.go @@ -243,7 +243,7 @@ func (gpm *GenericPoolManager) RefreshFuncPods(logger *zap.Logger, f fv1.Functio return nil } -func (gpm *GenericPoolManager) AdoptOrphanResources() { +func (gpm *GenericPoolManager) AdoptExistingResources() { envs, err := gpm.fissionClient.Environments(metav1.NamespaceAll).List(metav1.ListOptions{}) if err != nil { gpm.logger.Error("error getting environment list", zap.Error(err)) @@ -573,9 +573,12 @@ func (gpm *GenericPoolManager) idleObjectReaper() { } if deleted { for i := range fsvc.KubernetesObjects { - gpm.logger.Debug("release idle function resources", - zap.String("function", fsvc.Name), zap.String("address", fsvc.Address), - zap.String("executor", string(fsvc.Executor))) + gpm.logger.Info("release idle function resources", + zap.String("function", fsvc.Function.Name), + zap.String("address", fsvc.Address), + zap.String("executor", string(fsvc.Executor)), + zap.String("pod", fsvc.Name), + ) reaper.CleanupKubeObject(gpm.logger, gpm.kubernetesClient, &fsvc.KubernetesObjects[i]) time.Sleep(50 * time.Millisecond) }