Skip to content

Commit

Permalink
fix: skip dependencies on openshift platform (#1921)
Browse files Browse the repository at this point in the history
Signed-off-by: Benedikt Bongartz <[email protected]>
  • Loading branch information
frzifus authored May 31, 2022
1 parent 5044aa9 commit e17fa17
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
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 e17fa17

Please sign in to comment.