From 7e827d88d10a8636011841f42a7d99da3f03e2a6 Mon Sep 17 00:00:00 2001 From: Robert Jacob Date: Thu, 15 Feb 2024 18:21:16 +0100 Subject: [PATCH] Fix storage status being overwritten --- operator/internal/status/storage.go | 5 +---- operator/internal/status/storage_test.go | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/operator/internal/status/storage.go b/operator/internal/status/storage.go index ca6dea060a14e..620b5d4eeb364 100644 --- a/operator/internal/status/storage.go +++ b/operator/internal/status/storage.go @@ -21,9 +21,6 @@ func SetStorageSchemaStatus(ctx context.Context, k k8s.Client, req ctrl.Request, return kverrors.Wrap(err, "failed to lookup lokistack", "name", req.NamespacedName) } - s.Status.Storage = lokiv1.LokiStackStorageStatus{ - Schemas: schemas, - } - + s.Status.Storage.Schemas = schemas return k.Status().Update(ctx, &s) } diff --git a/operator/internal/status/storage_test.go b/operator/internal/status/storage_test.go index 5e2c0b595d517..86ea6641b4739 100644 --- a/operator/internal/status/storage_test.go +++ b/operator/internal/status/storage_test.go @@ -66,6 +66,7 @@ func TestSetStorageSchemaStatus_WhenStorageStatusExists_OverwriteStorageStatus(t }, Status: lokiv1.LokiStackStatus{ Storage: lokiv1.LokiStackStorageStatus{ + CredentialMode: lokiv1.CredentialModeStatic, Schemas: []lokiv1.ObjectStorageSchema{ { Version: lokiv1.ObjectStorageSchemaV11, @@ -94,14 +95,17 @@ func TestSetStorageSchemaStatus_WhenStorageStatusExists_OverwriteStorageStatus(t }, } - expected := []lokiv1.ObjectStorageSchema{ - { - Version: lokiv1.ObjectStorageSchemaV11, - EffectiveDate: "2020-10-11", - }, - { - Version: lokiv1.ObjectStorageSchemaV12, - EffectiveDate: "2021-10-11", + expected := lokiv1.LokiStackStorageStatus{ + CredentialMode: lokiv1.CredentialModeStatic, + Schemas: []lokiv1.ObjectStorageSchema{ + { + Version: lokiv1.ObjectStorageSchemaV11, + EffectiveDate: "2020-10-11", + }, + { + Version: lokiv1.ObjectStorageSchemaV12, + EffectiveDate: "2021-10-11", + }, }, } @@ -115,7 +119,7 @@ func TestSetStorageSchemaStatus_WhenStorageStatusExists_OverwriteStorageStatus(t sw.UpdateStub = func(_ context.Context, obj client.Object, _ ...client.SubResourceUpdateOption) error { stack := obj.(*lokiv1.LokiStack) - require.Equal(t, expected, stack.Status.Storage.Schemas) + require.Equal(t, expected, stack.Status.Storage) return nil }