Skip to content

Commit

Permalink
Fix storage status being overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
xperimental committed Feb 15, 2024
1 parent 2889437 commit 7e827d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
5 changes: 1 addition & 4 deletions operator/internal/status/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
22 changes: 13 additions & 9 deletions operator/internal/status/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func TestSetStorageSchemaStatus_WhenStorageStatusExists_OverwriteStorageStatus(t
},
Status: lokiv1.LokiStackStatus{
Storage: lokiv1.LokiStackStorageStatus{
CredentialMode: lokiv1.CredentialModeStatic,
Schemas: []lokiv1.ObjectStorageSchema{
{
Version: lokiv1.ObjectStorageSchemaV11,
Expand Down Expand Up @@ -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",
},
},
}

Expand All @@ -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
}

Expand Down

0 comments on commit 7e827d8

Please sign in to comment.