-
Notifications
You must be signed in to change notification settings - Fork 367
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
operator: Allow disabling Grafana deployment #1241
Conversation
4ec99aa
to
b9ede49
Compare
612e227
to
f747f70
Compare
@@ -186,3 +186,27 @@ func TestEtcdDefaultsToDisabled(t *testing.T) { | |||
t.Error("an empty etcd configuration should have etcd disabled") | |||
} | |||
} | |||
|
|||
func TestGrafanaDefaultsToEnabled(t *testing.T) { |
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.
It would be nice to convert this into a table driven test to make sure each test case is run independently of each other. Here is one such example: https://github.com/openshift/cluster-monitoring-operator/blob/master/pkg/manifests/manifests_test.go#L60
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.
ACK. I also prefer that. Honestly, I just copied the extremely similar test above this and changed it to test Grafana. I can try to find time to make it table driven.
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.
Done.
Quick note: There was some offline discussion about the fact that we generally try to keep the jsonnet / assets as close as possible to the default deployment. In this case that would require either needlessly enabling the static password auth when Grafana is disabled, or inverting the logic in |
469bd81
to
605592e
Compare
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.
Just 2 minor comments but nothing blocking. Very nice job!
pkg/manifests/manifests.go
Outdated
}) | ||
|
||
// Add the htpasswd arg and volume mount to the proxy container. | ||
for i := range p.Spec.Containers { |
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.
it might be clearer to move it to the range loop above where we alreayd tweak the prometheus-proxy container?
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.
Happy to do that. I don't have a strong opinion. I guess I could actually move all of this there to keep it all together. Unless it's too weird to have the volume bit there as well.
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.
Done.
pkg/manifests/manifests.go
Outdated
}) | ||
|
||
// Add the htpasswd arg and volume mount to the proxy container. | ||
for i := range d.Spec.Template.Spec.Containers { |
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.
same remark here
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.
Done here as well.
test/e2e/config_test.go
Outdated
assertOperatorCondition(t, configv1.OperatorAvailable, configv1.ConditionTrue) | ||
|
||
// Push a default configuration that re-enables Grafana. | ||
validCM.Data["config.yaml"] = "enableUserWorkload: true" |
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.
How does enabling user workload monitoring also enable grafana?
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.
It doesn't. That was just setting the config back to what it was originally, i.e. removing the previously added Grafana bit. It was definitely confusing though. The new test is different.
test/e2e/config_test.go
Outdated
@@ -92,6 +94,50 @@ func TestClusterMonitoringOperatorConfiguration(t *testing.T) { | |||
t.Log("asserting that CMO goes back healthy after the configuration is fixed") | |||
assertOperatorCondition(t, configv1.OperatorDegraded, configv1.ConditionFalse) | |||
assertOperatorCondition(t, configv1.OperatorAvailable, configv1.ConditionTrue) | |||
|
|||
// Push a configuration that disables Grafana. |
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.
I would extract this addition into a new independent test
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.
Done.
data := map[string]string{} | ||
|
||
// Configmap keys need to include "public" to indicate that they are public values. | ||
// See https://bugzilla.redhat.com/show_bug.cgi?id=1807100. | ||
if promHost != nil { | ||
data["prometheusPublicURL"] = promHost.String() | ||
} | ||
|
||
if amHost != nil { | ||
data["alertmanagerPublicURL"] = amHost.String() | ||
} | ||
|
||
if grafanaHost != nil { | ||
data["grafanaPublicURL"] = grafanaHost.String() | ||
} | ||
|
||
if thanosHost != nil { | ||
data["thanosPublicURL"] = thanosHost.String() | ||
} | ||
|
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.
Note: This will be removed in #1223
/lgtm but would be nice to get another review /hold |
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.
/lgtm
I've checked offline with @sichvoge who's fine with the field as exposed in the configmap.
/unhold |
This adds an option to the CMO ConfigMap that allows disabling the Grafana deployment. The actual removal of deployed Grafana resources is not yet implemented.
This implements the destroy method for the Grafana task. It deletes all the resources created by the create method in the reverse order.
@simonpasquier @fpetkovski: I had to rebase this. Can you have another look when you have a chance? |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bison, fpetkovski, simonpasquier The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
@bison: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
This exposes a config option in the ConfigMap that allows disabling the Grafana deployment.
Summary of the changes:
Enabled
field toGrafanaConfig
struct.create()
anddestroy()
methods.