Skip to content

Commit

Permalink
Merge branch 'main' into bug/1923
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvp8510 authored May 31, 2022
2 parents 08c35b9 + 829ecae commit 0903439
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/cmd/start/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,13 @@ func setupControllers(ctx context.Context, mgr manager.Manager) {
os.Exit(1)
}

if err := appsv1controllers.NewNamespaceReconciler(client, clientReader, schema).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Namespace")
os.Exit(1)
if viper.GetBool(v1.ConfigEnableNamespaceController) {
if err := appsv1controllers.NewNamespaceReconciler(client, clientReader, schema).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Namespace")
os.Exit(1)
}
} else {
log.Warn("skipping reconciliation for namespaces, do not have permissions to list and watch namespaces")
}

if err := esv1controllers.NewReconciler(client, clientReader).SetupWithManager(mgr); err != nil {
Expand Down
7 changes: 7 additions & 0 deletions pkg/cronjob/es_rollover.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ func EsScriptEnvVars(opts v1.Options) []corev1.EnvVar {
envs = append(envs, corev1.EnvVar{Name: x.envVar, Value: val})
}
}

if val, ok := options["skip-dependencies"]; ok {
envs = append(envs, corev1.EnvVar{Name: "SKIP_DEPENDENCIES", Value: val})
} else if !ok && viper.GetString("platform") == v1.FlagPlatformOpenShift {
envs = append(envs, corev1.EnvVar{Name: "SKIP_DEPENDENCIES", Value: "true"})
}

return envs
}

Expand Down
26 changes: 26 additions & 0 deletions pkg/cronjob/es_rollover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ func TestRollover(t *testing.T) {
assert.Equal(t, []string{"rollover", "foo"}, cjob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Args)
assert.Equal(t, []corev1.EnvVar{{Name: "INDEX_PREFIX", Value: "shortone"}, {Name: "CONDITIONS", Value: "weheee"}}, cjob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env)
assert.Equal(t, historyLimits, *cjob.Spec.SuccessfulJobsHistoryLimit)

// Test openshift settings
viper.Set("platform", v1.FlagPlatformOpenShift)
defer viper.Set("platform", v1.FlagPlatformKubernetes)
cjob = rollover(j).(*batchv1.CronJob)
assert.Equal(t,
[]corev1.EnvVar{
{Name: "INDEX_PREFIX", Value: "shortone"},
{Name: "SKIP_DEPENDENCIES", Value: "true"},
{Name: "CONDITIONS", Value: "weheee"},
}, cjob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env,
)

j.Spec.Storage.Options = v1.NewOptions(map[string]interface{}{
"es.server-urls": "foo,bar",
"es.index-prefix": "shortone",
"skip-dependencies": "skip",
})
cjob = rollover(j).(*batchv1.CronJob)
assert.Equal(t,
[]corev1.EnvVar{
{Name: "INDEX_PREFIX", Value: "shortone"},
{Name: "SKIP_DEPENDENCIES", Value: "skip"},
{Name: "CONDITIONS", Value: "weheee"},
}, cjob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env,
)
}

func TestLookback(t *testing.T) {
Expand Down

0 comments on commit 0903439

Please sign in to comment.