Skip to content

Commit

Permalink
Reconcile when changing from Cache to DataGrid type. Fixes #1886
Browse files Browse the repository at this point in the history
  • Loading branch information
rigazilla authored Nov 7, 2023
1 parent b97fca2 commit e335c7f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ func StatefulSetRollingUpgrade(i *ispnv1.Infinispan, ctx pipeline.Context) {
}

// Validate extra Java options changes
if updateStatefulSetEnv(container, statefulSet, "EXTRA_JAVA_OPTIONS", ispnContr.ExtraJvmOpts) {
updateStatefulSetEnv(container, statefulSet, "JAVA_OPTIONS", i.GetJavaOptions())
if updateStatefulSetEnv(container, statefulSet, "JAVA_OPTIONS", i.GetJavaOptions()) {
updateNeeded = true
}
if updateStatefulSetEnv(container, statefulSet, "CLI_JAVA_OPTIONS", ispnContr.CliExtraJvmOpts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func PodEnv(i *ispnv1.Infinispan, systemEnv *[]corev1.EnvVar) []corev1.EnvVar {
// Prevent the image from generating a user if authentication disabled
{Name: "MANAGED_ENV", Value: "TRUE"},
{Name: "JAVA_OPTIONS", Value: i.GetJavaOptions()},
{Name: "EXTRA_JAVA_OPTIONS", Value: i.Spec.Container.ExtraJvmOpts},
{Name: "CLI_JAVA_OPTIONS", Value: i.Spec.Container.CliExtraJvmOpts},
}

Expand Down
25 changes: 25 additions & 0 deletions test/e2e/infinispan/spec_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,31 @@ func TestContainerJavaOptsUpdate(t *testing.T) {
genericTestForContainerUpdated(*spec, modifier, verifier)
}

func TestInfinispanMigrateFromCacheToDatagrid(t *testing.T) {
t.Parallel()
defer testKube.CleanNamespaceAndLogOnPanic(t, tutils.Namespace)

var modifier = func(ispn *ispnv1.Infinispan) {
ispn.Spec.Service.Type = ispnv1.ServiceTypeDataGrid
}
var verifier = func(ispn *ispnv1.Infinispan, ss *appsv1.StatefulSet) {
env := ss.Spec.Template.Spec.Containers[0].Env
for _, value := range env {
if value.Name == "JAVA_OPTIONS" {
if value.Value != "" {
panic("Expected empty JAVA_OPTIONS. Migration failed?")
} else {
return
}
}
}
panic("JAVA_OPTIONS not found")
}
spec := tutils.DefaultSpec(t, testKube, nil)
spec.Spec.Service.Type = ispnv1.ServiceTypeCache
genericTestForContainerUpdated(*spec, modifier, verifier)
}

func genericTestForContainerUpdated(ispn ispnv1.Infinispan, modifier func(*ispnv1.Infinispan), verifier func(*ispnv1.Infinispan, *appsv1.StatefulSet)) {
testKube.CreateInfinispan(&ispn, tutils.Namespace)
testKube.WaitForInfinispanPods(int(ispn.Spec.Replicas), tutils.SinglePodTimeout, ispn.Name, tutils.Namespace)
Expand Down

0 comments on commit e335c7f

Please sign in to comment.