Skip to content
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 2060726: Use namespace when creating ServiceMonitor #70

Merged
merged 2 commits into from Jul 18, 2022

Conversation

mrogers950
Copy link

Take the given operator namespace into account when setting the
ServiceMonitor ServerName field. Previously it was always assumed to be
openshift-compliance.

ref: https://bugzilla.redhat.com/show_bug.cgi?id=2060726

@openshift-ci
Copy link

openshift-ci bot commented Jul 18, 2022

@mrogers950: This pull request references Bugzilla bug 2060726, which is invalid:

  • expected the bug to target the "4.12.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 2060726: Use namespace when creating ServiceMonitor

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.

@mrogers950
Copy link
Author

/bugzilla refresh

@openshift-ci
Copy link

openshift-ci bot commented Jul 18, 2022

@mrogers950: This pull request references Bugzilla bug 2060726, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.12.0) matches configured target release for branch (4.12.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @xiaojiey

In response to this:

/bugzilla refresh

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.

@mrogers950
Copy link
Author

The test failure was with the metrics for TestSingleScanSucceeds -

compliance_operator_compliance_scan_status_total{name="test-single-scan-succeeds",phase="AGGREGATING",result="NOT-AVAILABLE"} 3
        compliance_operator_compliance_scan_status_total{name="test-single-scan-succeeds",phase="DONE",result="COMPLIANT"} 1
        compliance_operator_compliance_scan_status_total{name="test-single-scan-succeeds",phase="LAUNCHING",result="NOT-AVAILABLE"} 1

...
        
    helpers.go:[2463](https://prow.ci.openshift.org/view/gs/origin-ci-test/pr-logs/pull/ComplianceAsCode_compliance-operator/70/pull-ci-ComplianceAsCode-compliance-operator-master-e2e-aws/1549052847419559936#1:build-log.txt%3A2463): 0
    helpers.go:295: unexpected metrics value

We test for the AGGREGATING metric to be 1 or 2, here it registered AGGREGATING a 3rd time. Not a problem in itself, but the test needs to be adjusted. Added another commit.

Copy link

@rhmdnd rhmdnd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one question inline.

@@ -562,7 +561,7 @@ func createServiceMonitor(ctx context.Context, cfg *rest.Config, mClient *moncli
serviceMonitor.Spec.Endpoints[i].BearerTokenFile = serviceMonitorBearerTokenFile
serviceMonitor.Spec.Endpoints[i].TLSConfig = &monitoring.TLSConfig{
CAFile: serviceMonitorTLSCAFile,
ServerName: serviceMonitorTLSServerName,
ServerName: "metrics." + namespace + ".svc",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This the crux of the fix, right? The testing changes below aren't directly related to this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the testing changes are unrelated. (Our CI testing is a direct read from the metrics service, while the ServiceMonitor is so cluster monitoring can read the metrics)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a unit testing layer available to ensure this format doesn't regress?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not atm. I can add it though

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhmdnd I refactored some to fit a simple unit test..

@mrogers950
Copy link
Author

Got a flake in TestScanSettingBindingWatchesTailoredProfile
/retest

Matt Rogers added 2 commits July 18, 2022 17:44
Take the given operator namespace into account when setting the
ServiceMonitor ServerName field. Previously it was always assumed to be
openshift-compliance.

Also, add cmd/manager/operator_test.go with a unit test for the
ServiceMonitor, with some refactoring.

ref: https://bugzilla.redhat.com/show_bug.cgi?id=2060726
Previously we allowed the AGGREGATING metric test to adjust for 1 or 2,
but 3 was recently seen in CI. (This metric is expected to vary slightly).
"github.com/openshift/compliance-operator/pkg/controller/metrics"
)

var _ = Describe("Operator Startup Function tests", func() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this

@openshift-ci
Copy link

openshift-ci bot commented Jul 18, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mrogers950, rhmdnd

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot merged commit c199e98 into ComplianceAsCode:master Jul 18, 2022
@openshift-ci
Copy link

openshift-ci bot commented Jul 18, 2022

@mrogers950: All pull requests linked via external trackers have merged:

Bugzilla bug 2060726 has been moved to the MODIFIED state.

In response to this:

Bug 2060726: Use namespace when creating ServiceMonitor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants