Make AdoptExistingResources optional (#1453)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user