Make AdoptExistingResources optional (#1453)

This commit is contained in:
Ta-Ching Chen
2019-12-02 07:34:07 +08:00
committed by GitHub
parent 003c304105
commit 7f8cb69326
9 changed files with 33 additions and 15 deletions
+1
View File
@@ -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`
@@ -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
+3
View File
@@ -65,6 +65,9 @@ logger:
## security context and set privileged to true.
enableSecurityContext: false
executor:
adoptExistingResources: false
## Router config
router:
deployAsDaemonSet: false
@@ -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
+3
View File
@@ -45,6 +45,9 @@ builderNamespace: fission-builder
## Enable istio integration
enableIstio: false
executor:
adoptExistingResources: false
## Router config
router:
deployAsDaemonSet: false
+5 -1
View File
@@ -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
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.AdoptOrphanResources()
et.AdoptExistingResources()
}(et)
}
// set hard timeout for resource adoption
util.WaitTimeout(wg, 30*time.Second)
}
cms := cms.MakeConfigSecretController(logger, fissionClient, kubernetesClient, executorTypes)
+1 -1
View File
@@ -52,5 +52,5 @@ type ExecutorType interface {
RefreshFuncPods(*zap.Logger, fv1.Function) error
// AdoptOrphanResources adopts existing resources created by the deleted executor.
AdoptOrphanResources()
AdoptExistingResources()
}
@@ -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),
}
+7 -4
View File
@@ -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)
}