Skip to content

Commit

Permalink
fixup! OCPBUGS-17113: Lazy updates for Prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
rexagod committed Sep 19, 2024
1 parent 5665e69 commit 30dc110
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,19 @@ check-runbooks:

.PHONY: bench
bench:
go test -run NONE -bench ^Bench -benchmem $(PKGS)
go test -run NONE -bench=. -benchmem $(PKGS)

.PHONY: test
test: test-unit test-rules test-e2e

.PHONY: test-unit
test-unit:
go test -run ^Test -race -short $(PKGS) -count=1
go test -race -short $(PKGS) -count=1

.PHONY: test-e2e
test-e2e: KUBECONFIG?=$(HOME)/.kube/config
test-e2e:
go test -run ^Test -v -timeout=150m ./test/e2e/ --kubeconfig $(KUBECONFIG)
go test -v -timeout=150m ./test/e2e/ --kubeconfig $(KUBECONFIG)

$(BIN_DIR):
mkdir -p $(BIN_DIR)
Expand Down
7 changes: 6 additions & 1 deletion pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,14 @@ func (c *Client) GetAlertingRule(ctx context.Context, namespace, name string) (*
return c.osmclient.MonitoringV1().AlertingRules(namespace).Get(ctx, name, metav1.GetOptions{})
}

// NOTE: We don't use a defaulting function here, and resort only to the caching mechanism, since,
// CreateOrUpdatePrometheus does not use a defaulting function, and resorts only to the caching mechanism, since,
// * defaults for Prometheus should be introduced from its operator level, and,
// * the defaulting approach generally requires hardcoding the default values, which adds on to the maintenance overhead.
// NOTE: The return values establish the following matrix (w.r.t. the create or update verbs):
// * true, nil : verb action needed; operation successful,
// * false, nil : verb action not needed; operation skipped,
// * true, error : verb action needed, operation unsuccessful.
// * false, error: verb action may or may not be needed; operation unsuccessful,
func (c *Client) CreateOrUpdatePrometheus(ctx context.Context, structuredRequiredPrometheus *monv1.Prometheus) (bool, error) {
unstructuredRequiredPrometheusObject, err := runtime.DefaultUnstructuredConverter.ToUnstructured(structuredRequiredPrometheus)
if err != nil {
Expand Down

0 comments on commit 30dc110

Please sign in to comment.