Skip to content

Commit

Permalink
Change EnableDownloader to EnableInitContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangpengcheng committed Nov 9, 2022
1 parent b5fa21b commit 61b5afa
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .ci/tests/integration-oauth2/e2e_with_downloader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ setup:
image="function-mesh-operator:latest"
IMG=${image} make docker-build-skip-test
kind load docker-image ${image}
helm install ${FUNCTION_MESH_RELEASE_NAME} -n ${FUNCTION_MESH_NAMESPACE} --set operatorImage=${image} --set controllerManager.enableDownloader=true --create-namespace charts/function-mesh-operator
helm install ${FUNCTION_MESH_RELEASE_NAME} -n ${FUNCTION_MESH_NAMESPACE} --set operatorImage=${image} --set controllerManager.enableInitContainers=true --create-namespace charts/function-mesh-operator
wait:
- namespace: function-mesh
resource: pod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ spec:
- --health-probe-addr=:{{ .Values.controllerManager.healthProbe.port }}
- --pprof-addr=:{{ .Values.controllerManager.pprof.port }}
- --config-file={{ .Values.controllerManager.configFile }}
- --enable-downloader={{ .Values.controllerManager.enableDownloader }}
- --enable-init-containers={{ .Values.controllerManager.enableInitContainers }}
env:
- name: NAMESPACE
valueFrom:
Expand Down
2 changes: 1 addition & 1 deletion charts/function-mesh-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ controllerManager:
pprof:
enable: false
port: 8090
enableDownloader: false
enableInitContainers: false

admissionWebhook:
enabled: true
10 changes: 5 additions & 5 deletions controllers/spec/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func MakeJavaFunctionCommand(downloadPath, packageFile, name, clusterName, gener
processCommand := setShardIDEnvironmentVariableCommand() + " && " + generateLogConfigCommand +
strings.Join(getProcessJavaRuntimeArgs(name, packageFile, clusterName, logLevel, details,
memory, extraDependenciesDir, uid, authProvided, tlsProvided, secretMaps, state, tlsConfig, authConfig), " ")
if downloadPath != "" && !utils.EnableDownloader {
if downloadPath != "" && !utils.EnableInitContainers {
// prepend download command if the downPath is provided
downloadCommand := strings.Join(getLegacyDownloadCommand(downloadPath, packageFile, authProvided, tlsProvided,
tlsConfig, authConfig), " ")
Expand All @@ -364,7 +364,7 @@ func MakePythonFunctionCommand(downloadPath, packageFile, name, clusterName, gen
processCommand := setShardIDEnvironmentVariableCommand() + " && " + generateLogConfigCommand +
strings.Join(getProcessPythonRuntimeArgs(name, packageFile, clusterName,
details, uid, authProvided, tlsProvided, secretMaps, state, tlsConfig, authConfig), " ")
if downloadPath != "" && !utils.EnableDownloader {
if downloadPath != "" && !utils.EnableInitContainers {
// prepend download command if the downPath is provided
downloadCommand := strings.Join(getLegacyDownloadCommand(downloadPath, packageFile, authProvided, tlsProvided,
tlsConfig, authConfig), " ")
Expand All @@ -376,7 +376,7 @@ func MakePythonFunctionCommand(downloadPath, packageFile, name, clusterName, gen
func MakeGoFunctionCommand(downloadPath, goExecFilePath string, function *v1alpha1.Function) []string {
processCommand := setShardIDEnvironmentVariableCommand() + " && " +
strings.Join(getProcessGoRuntimeArgs(goExecFilePath, function), " ")
if downloadPath != "" && !utils.EnableDownloader {
if downloadPath != "" && !utils.EnableInitContainers {
// prepend download command if the downPath is provided
downloadCommand := strings.Join(getLegacyDownloadCommand(downloadPath, goExecFilePath,
function.Spec.Pulsar.AuthSecret != "", function.Spec.Pulsar.TLSSecret != "",
Expand Down Expand Up @@ -1281,7 +1281,7 @@ func generateContainerVolumeMountsFromConsumerConfigs(confs map[string]v1alpha1.
}

func generateDownloaderVolumeMountsForDownloader(javaRuntime *v1alpha1.JavaRuntime, pythonRuntime *v1alpha1.PythonRuntime, goRuntime *v1alpha1.GoRuntime) []corev1.VolumeMount {
if !utils.EnableDownloader {
if !utils.EnableInitContainers {
return nil
}
if (javaRuntime != nil && javaRuntime.JarLocation != "") ||
Expand Down Expand Up @@ -1349,7 +1349,7 @@ func generateContainerVolumeMounts(volumeMounts []corev1.VolumeMount, producerCo
mounts = append(mounts, generateVolumeMountFromOAuth2Config(authConfig.OAuth2Config))
}
}
if utils.EnableDownloader {
if utils.EnableInitContainers {
mounts = append(mounts, generateDownloaderVolumeMountsForRuntime(javaRuntime, pythonRuntime, goRuntime)...)
}
mounts = append(mounts, generateContainerVolumeMountsFromProducerConf(producerConf)...)
Expand Down
2 changes: 1 addition & 1 deletion controllers/spec/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ func TestGeneratePodVolumes(t *testing.T) {
}

func TestGenerateContainerVolumeMounts(t *testing.T) {
utils.EnableDownloader = true
utils.EnableInitContainers = true
type args struct {
volumeMounts []corev1.VolumeMount
producerConf *v1alpha1.ProducerConfig
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func main() {
var enableLeaderElection, enablePprof bool
var configFile string
var namespace string
var enableDownloader bool
var enableInitContainers bool
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&leaderElectionID, "leader-election-id", "a3f45fce.functionmesh.io",
"the name of the configmap that leader election will use for holding the leader lock.")
Expand All @@ -79,11 +79,11 @@ func main() {
"Namespace if specified restricts the manager's cache to watch objects in the desired namespace. Defaults to all namespaces.")
flag.BoolVar(&enablePprof, "enable-pprof", false, "Enable pprof for controller manager.")
flag.StringVar(&pprofAddr, "pprof-addr", ":8090", "The address the pprof binds to.")
flag.BoolVar(&enableDownloader, "enable-downloader", false, "Whether to use an init container to download package")
flag.BoolVar(&enableInitContainers, "enable-init-containers", false, "Whether to use an init container to download package")
flag.Parse()

ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
utils.EnableDownloader = enableDownloader
utils.EnableInitContainers = enableInitContainers

// enable pprof
if enablePprof {
Expand Down
2 changes: 1 addition & 1 deletion utils/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
// Package utils define some common used functions&structs
package utils

var EnableDownloader = false
var EnableInitContainers = false

0 comments on commit 61b5afa

Please sign in to comment.