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
+13 -9
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
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)