Skip to content

Commit

Permalink
Merge pull request grafana#355 from periklis/backport-pr-14314-6.0
Browse files Browse the repository at this point in the history
[release-6.0] Backport PR grafana#14314
  • Loading branch information
periklis authored Oct 1, 2024
2 parents ce7934d + 654998a commit fbb2c5e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
1 change: 1 addition & 0 deletions operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Release 6.0.1

- [14314](https://github.com/grafana/loki/pull/14314) **periklis**: fix(operator): Use empty initiliazed pod status map when no pods
- [14308](https://github.com/grafana/loki/pull/14308) **periklis**: feat(operator): Declare feature FIPS support for OpenShift only
- [14279](https://github.com/grafana/loki/pull/14279) **periklis**: fix(operator): Add missing groupBy label for all rules on OpenShift

Expand Down
9 changes: 9 additions & 0 deletions operator/internal/status/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ func appendPodStatus(ctx context.Context, k k8s.Client, component, stack, ns str
status := podStatus(&pod)
psm[status] = append(psm[status], pod.Name)
}

if len(psm) == 0 {
psm = lokiv1.PodStatusMap{
lokiv1.PodFailed: []string{},
lokiv1.PodPending: []string{},
lokiv1.PodRunning: []string{},
lokiv1.PodReady: []string{},
}
}
return psm, nil
}

Expand Down
46 changes: 38 additions & 8 deletions operator/internal/status/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ func setupListClient(t *testing.T, stack *lokiv1.LokiStack, componentPods map[st
}

func TestGenerateComponentStatus(t *testing.T) {
empty := lokiv1.PodStatusMap{
lokiv1.PodFailed: []string{},
lokiv1.PodPending: []string{},
lokiv1.PodRunning: []string{},
lokiv1.PodReady: []string{},
}

tt := []struct {
desc string
componentPods map[string]*corev1.PodList
Expand All @@ -83,14 +90,14 @@ func TestGenerateComponentStatus(t *testing.T) {
manifests.LabelGatewayComponent: {},
},
wantComponentStatus: &lokiv1.LokiStackComponentStatus{
Compactor: lokiv1.PodStatusMap{},
Distributor: lokiv1.PodStatusMap{},
IndexGateway: lokiv1.PodStatusMap{},
Ingester: lokiv1.PodStatusMap{},
Querier: lokiv1.PodStatusMap{},
QueryFrontend: lokiv1.PodStatusMap{},
Gateway: lokiv1.PodStatusMap{},
Ruler: lokiv1.PodStatusMap{},
Compactor: empty,
Distributor: empty,
IndexGateway: empty,
Ingester: empty,
Querier: empty,
QueryFrontend: empty,
Gateway: empty,
Ruler: empty,
},
},
{
Expand All @@ -116,6 +123,29 @@ func TestGenerateComponentStatus(t *testing.T) {
Ruler: lokiv1.PodStatusMap{lokiv1.PodRunning: {"ruler-pod-0"}},
},
},
{
desc: "all pods without ruler",
componentPods: map[string]*corev1.PodList{
manifests.LabelCompactorComponent: createPodList(manifests.LabelCompactorComponent, false, corev1.PodRunning),
manifests.LabelDistributorComponent: createPodList(manifests.LabelDistributorComponent, false, corev1.PodRunning),
manifests.LabelIngesterComponent: createPodList(manifests.LabelIngesterComponent, false, corev1.PodRunning),
manifests.LabelQuerierComponent: createPodList(manifests.LabelQuerierComponent, false, corev1.PodRunning),
manifests.LabelQueryFrontendComponent: createPodList(manifests.LabelQueryFrontendComponent, false, corev1.PodRunning),
manifests.LabelIndexGatewayComponent: createPodList(manifests.LabelIndexGatewayComponent, false, corev1.PodRunning),
manifests.LabelRulerComponent: {},
manifests.LabelGatewayComponent: createPodList(manifests.LabelGatewayComponent, false, corev1.PodRunning),
},
wantComponentStatus: &lokiv1.LokiStackComponentStatus{
Compactor: lokiv1.PodStatusMap{lokiv1.PodRunning: {"compactor-pod-0"}},
Distributor: lokiv1.PodStatusMap{lokiv1.PodRunning: {"distributor-pod-0"}},
IndexGateway: lokiv1.PodStatusMap{lokiv1.PodRunning: {"index-gateway-pod-0"}},
Ingester: lokiv1.PodStatusMap{lokiv1.PodRunning: {"ingester-pod-0"}},
Querier: lokiv1.PodStatusMap{lokiv1.PodRunning: {"querier-pod-0"}},
QueryFrontend: lokiv1.PodStatusMap{lokiv1.PodRunning: {"query-frontend-pod-0"}},
Gateway: lokiv1.PodStatusMap{lokiv1.PodRunning: {"lokistack-gateway-pod-0"}},
Ruler: empty,
},
},
}

for _, tc := range tt {
Expand Down

0 comments on commit fbb2c5e

Please sign in to comment.