DRY up fetcher configuration (#1168)

Consolidates the addition of the fetcher container to the pod into a new type FetcherConfig and takes care of serviceAccountName if not set. Also added PreStop lifecycle handler if pod set TerminationGracePeriodSeconds
This commit is contained in:
Vishal
2019-05-02 21:39:42 +05:30
committed by GitHub
parent 23f3585245
commit c88033fc0b
13 changed files with 396 additions and 483 deletions
+4 -18
View File
@@ -41,6 +41,7 @@ import (
"github.com/fission/fission"
"github.com/fission/fission/crd"
fetcherConfig "github.com/fission/fission/environments/fetcher/config"
"github.com/fission/fission/executor/fscache"
)
@@ -52,14 +53,10 @@ type (
fissionClient *crd.FissionClient
crdClient *rest.RESTClient
instanceID string
fetcherConfig *fetcherConfig.Config
fetcherImg string
fetcherImagePullPolicy apiv1.PullPolicy
runtimeImagePullPolicy apiv1.PullPolicy
namespace string
sharedMountPath string
sharedSecretPath string
sharedCfgMapPath string
useIstio bool
collectorEndpoint string
@@ -82,18 +79,12 @@ func MakeNewDeploy(
kubernetesClient *kubernetes.Clientset,
crdClient *rest.RESTClient,
namespace string,
fetcherConfig *fetcherConfig.Config,
instanceID string,
) *NewDeploy {
logger.Info("creating NewDeploy ExecutorType")
fetcherImg := os.Getenv("FETCHER_IMAGE")
if len(fetcherImg) == 0 {
fetcherImg = "fission/fetcher"
}
collectorEndpoint := os.Getenv("TRACE_JAEGER_COLLECTOR_ENDPOINT")
enableIstio := false
if len(os.Getenv("ENABLE_ISTIO")) > 0 {
istio, err := strconv.ParseBool(os.Getenv("ENABLE_ISTIO"))
@@ -115,13 +106,8 @@ func MakeNewDeploy(
fsCache: fscache.MakeFunctionServiceCache(logger),
throttler: throttler.MakeThrottler(1 * time.Minute),
fetcherImg: fetcherImg,
fetcherImagePullPolicy: fission.GetImagePullPolicy(os.Getenv("FETCHER_IMAGE_PULL_POLICY")),
fetcherConfig: fetcherConfig,
runtimeImagePullPolicy: fission.GetImagePullPolicy(os.Getenv("RUNTIME_IMAGE_PULL_POLICY")),
sharedMountPath: "/userfunc",
sharedSecretPath: "/secrets",
sharedCfgMapPath: "/configs",
collectorEndpoint: collectorEndpoint,
useIstio: enableIstio,
idlePodReapTime: 2 * time.Minute,