Skip to content

Commit 2c623e1

Browse files
exdxbenluddy
authored andcommitted
Surface API server warnings when applying plan steps.
Responses from the API server may include RFC2616 14.46 warnings (for example, due to deprecation). Since the catalog-operator creates and updates cluster resources on behalf of users, these warnings should be surfaced to users. When at least one warning is returned during the creation or update of a step resource, catalog-operator now creates an Event with reason "AppliedWithWarnings", involvedObject and fieldPath set to the plan and step that generated the warning, respectively, and its message containing the warning text. In addition, a new metric, "installplan_warnings_total", counts the number of steps that have been applied with warnings. Signed-off-by: Ben Luddy <[email protected]>
1 parent d0d208d commit 2c623e1

File tree

14 files changed

+757
-445
lines changed

14 files changed

+757
-445
lines changed

deploy/chart/templates/0000_90_olm_01-prometheus-rule.yaml

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,30 @@ metadata:
99
role: alert-rules
1010
spec:
1111
groups:
12-
- name: olm.csv_abnormal.rules
13-
rules:
14-
- alert: CsvAbnormalFailedOver2Min
15-
expr: csv_abnormal{phase=~"^Failed$"}
16-
for: 2m
17-
labels:
18-
severity: warning
19-
namespace: "{{ "{{ $labels.namespace }}" }}"
20-
annotations:
21-
message: Failed to install Operator {{ printf "{{ $labels.name }}" }} version {{ printf "{{ $labels.version }}" }}. Reason-{{ printf "{{ $labels.reason }}" }}
22-
23-
- alert: CsvAbnormalOver30Min
24-
expr: csv_abnormal{phase=~"(^Replacing$|^Pending$|^Deleting$|^Unknown$)"}
25-
for: 30m
26-
labels:
27-
severity: warning
28-
namespace: "{{ "{{ $labels.namespace }}" }}"
29-
annotations:
30-
message: Failed to install Operator {{ printf "{{ $labels.name }}" }} version {{ printf "{{ $labels.version }}" }}. Phase-{{ printf "{{ $labels.phase }}" }} Reason-{{ printf "{{ $labels.reason }}" }}
12+
- name: olm.csv_abnormal.rules
13+
rules:
14+
- alert: CsvAbnormalFailedOver2Min
15+
expr: csv_abnormal{phase=~"^Failed$"}
16+
for: 2m
17+
labels:
18+
severity: warning
19+
namespace: "{{ "{{ $labels.namespace }}" }}"
20+
annotations:
21+
message: Failed to install Operator {{ printf "{{ $labels.name }}" }} version {{ printf "{{ $labels.version }}" }}. Reason-{{ printf "{{ $labels.reason }}" }}
22+
- alert: CsvAbnormalOver30Min
23+
expr: csv_abnormal{phase=~"(^Replacing$|^Pending$|^Deleting$|^Unknown$)"}
24+
for: 30m
25+
labels:
26+
severity: warning
27+
namespace: "{{ "{{ $labels.namespace }}" }}"
28+
annotations:
29+
message: Failed to install Operator {{ printf "{{ $labels.name }}" }} version {{ printf "{{ $labels.version }}" }}. Phase-{{ printf "{{ $labels.phase }}" }} Reason-{{ printf "{{ $labels.reason }}" }}
30+
- name: olm.installplan.rules
31+
rules:
32+
- alert: InstallPlanStepAppliedWithWarnings
33+
expr: sum(sum_over_time(installplan_warnings_total[5m])) > 0
34+
labels:
35+
severity: warning
36+
annotations:
37+
message: The API server returned a warning during installation or upgrade of an operator. An Event with reason "AppliedWithWarnings" has been created with complete details, including a reference to the InstallPlan step that generated the warning.
3138
{{ end }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package catalog
2+
3+
import (
4+
"k8s.io/client-go/dynamic"
5+
6+
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
7+
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/clients"
8+
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
9+
)
10+
11+
type stubClientFactory struct {
12+
operatorClient operatorclient.ClientInterface
13+
kubernetesClient versioned.Interface
14+
dynamicClient dynamic.Interface
15+
}
16+
17+
var _ clients.Factory = &stubClientFactory{}
18+
19+
func (f *stubClientFactory) WithConfigTransformer(clients.ConfigTransformer) clients.Factory {
20+
return f
21+
}
22+
23+
func (f *stubClientFactory) NewOperatorClient() (operatorclient.ClientInterface, error) {
24+
return f.operatorClient, nil
25+
}
26+
27+
func (f *stubClientFactory) NewKubernetesClient() (versioned.Interface, error) {
28+
return f.kubernetesClient, nil
29+
}
30+
31+
func (f *stubClientFactory) NewDynamicClient() (dynamic.Interface, error) {
32+
return f.dynamicClient, nil
33+
}

0 commit comments

Comments
 (0)