New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 1809353: Exclude Kubernetes control plane rules when running on IBM Cloud #705
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -22,6 +22,8 @@ import ( | |||||||||
"testing" | ||||||||||
|
||||||||||
monv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1" | ||||||||||
configv1 "github.com/openshift/api/config/v1" | ||||||||||
|
||||||||||
v1 "k8s.io/api/core/v1" | ||||||||||
"k8s.io/apimachinery/pkg/api/resource" | ||||||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||||||
|
@@ -1176,6 +1178,63 @@ func TestOpenShiftStateMetrics(t *testing.T) { | |||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
func TestPrometheusK8sControlPlaneRulesFiltered(t *testing.T) { | ||||||||||
tests := []struct { | ||||||||||
name string | ||||||||||
config *Config | ||||||||||
verify func(bool, bool, bool) | ||||||||||
}{ | ||||||||||
{ | ||||||||||
name: "default config", | ||||||||||
config: func() *Config { | ||||||||||
c := NewDefaultConfig() | ||||||||||
c.Platform = configv1.AWSPlatformType | ||||||||||
return c | ||||||||||
}(), | ||||||||||
verify: func(api, cm, sched bool) { | ||||||||||
if !api || !cm || !sched { | ||||||||||
t.Fatal("did not get all expected kubernetes control plane rules") | ||||||||||
} | ||||||||||
}, | ||||||||||
}, | ||||||||||
{ | ||||||||||
name: "hosted control plane", | ||||||||||
config: func() *Config { | ||||||||||
c := NewDefaultConfig() | ||||||||||
c.Platform = IBMCloudPlatformType | ||||||||||
return c | ||||||||||
}(), | ||||||||||
verify: func(api, cm, sched bool) { | ||||||||||
if api || cm || sched { | ||||||||||
t.Fatalf("kubernetes control plane rules found, none expected") | ||||||||||
} | ||||||||||
}, | ||||||||||
}, | ||||||||||
} | ||||||||||
|
||||||||||
for _, tc := range tests { | ||||||||||
f := NewFactory("openshift-monitoring", "openshift-user-workload-monitoring", tc.config) | ||||||||||
r, err := f.PrometheusK8sRules() | ||||||||||
if err != nil { | ||||||||||
t.Fatal(err) | ||||||||||
} | ||||||||||
apiServerRulesFound := false | ||||||||||
controllerManagerRulesFound := false | ||||||||||
schedulerRulesFound := false | ||||||||||
for _, g := range r.Spec.Groups { | ||||||||||
switch g.Name { | ||||||||||
case "kubernetes-system-apiserver": | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about etcd? and what about the servicemonitors that are provisioned to monitor these in the first place, they will now show "down" targets? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Service monitors that are part of control plane operators are skipped via annotation: https://github.com/openshift/cluster-kube-apiserver-operator/blob/4de583dffa47c25adde871e7361386b0d55c674a/manifests/0000_90_kube-apiserver-operator_03_servicemonitor.yaml#L7 cluster-monitoring-operator/pkg/operator/operator.go Lines 418 to 421 in 207ec4e
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see ok. |
||||||||||
apiServerRulesFound = true | ||||||||||
case "kubernetes-system-controller-manager": | ||||||||||
controllerManagerRulesFound = true | ||||||||||
case "kubernetes-system-scheduler": | ||||||||||
schedulerRulesFound = true | ||||||||||
} | ||||||||||
} | ||||||||||
tc.verify(apiServerRulesFound, controllerManagerRulesFound, schedulerRulesFound) | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
func TestPrometheusEtcdRulesFiltered(t *testing.T) { | ||||||||||
enabled := false | ||||||||||
c := NewDefaultConfig() | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't redefine constant as vars, that's horribly dangerous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx! fixed