Skip to content

Conversation

@suhanime
Copy link
Contributor

Adds the labelSelector customization for some metrics. This feature can be opted into via HiveConfig, and the metrics, for which this customization is configured, will only be reported if the label query matches the labels on the related clusterdeployment.

To get around cyclic import cycle, the definition and registration of all supported metrics from clusterDeployment, clusterProvision and clusterDeprovision controller have been moved to metrics controller.

Hive-2285

This commit adds the labelSelector customization for some metrics. This
feature can be opted into via HiveConfig, and the metrics, for which this
customization is configured, will only be reported if the label query
matches the labels on the related clusterdeployment.

To get around cyclic import cycle, the definition and registration of
all supported metrics from clusterDeployment, clusterProvision and
clusterDeprovision controller have been moved to metrics controller.
@openshift-ci openshift-ci bot requested review from 2uasimojo and dlom October 29, 2024 10:49
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 29, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: suhanime

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 29, 2024
Copy link
Contributor Author

@suhanime suhanime left a comment

Choose a reason for hiding this comment

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

/hold

must verify hiveoperator codepath works correctly

/assign @2uasimojo

Comment on lines +517 to +525
// Read the metricsConfig section and fetch clusterDeploymentLabelSelectors, error out if it fails validation
err = controllerMetrics.GetClusterDeploymentLabelSelectors(hLog, origHiveConfig.Spec.MetricsConfig)
if err != nil {
hLog.WithError(err).Error("error in metricsConfig")
instance.Status.Conditions = util.SetHiveConfigCondition(instance.Status.Conditions, hivev1.HiveReadyCondition, corev1.ConditionFalse, "ErrorInMetricsConfig", err.Error())
r.updateHiveConfigStatus(origHiveConfig, instance, hLog, false)
return reconcile.Result{}, err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this location/incorporation correct? My testing hasn't yielded fruitful results - happy to move this to metrics controller and panic if error, and tackle this feature later if time is an issue

err := cc.client.List(context.Background(), clusterDeployments)
if err != nil {
log.WithError(err).Error("error listing cluster deployments")
ccLog.WithError(err).Error("error listing cluster deployments")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were initializing ccLog but using the one without the field set to metrics controller - corrected this in the entire file


// Metrics reported by ClusterDeployment controller

MetricInstallJobDuration = prometheus.NewHistogramVec(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You might notice, I changed the type of some of the metrics, especially ones declared as Histogram or HistogramOpts, for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah - couldn't think of any other way to avoid the import cycles. Eventual plan is to move all metrics' definitions to metrics/metrics_to_report, and streamline their types, handle registration and encapsulate observation.

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 29, 2024
@codecov
Copy link

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 50.47170% with 105 lines in your changes missing coverage. Please review.

Project coverage is 46.10%. Comparing base (d9cab21) to head (446da45).
Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
...oller/metrics/cluster_deployment_label_selector.go 9.09% 49 Missing and 1 partial ⚠️
pkg/controller/metrics/metrics.go 45.71% 19 Missing ⚠️
pkg/controller/metrics/metrics_to_report.go 60.60% 13 Missing ⚠️
pkg/controller/metrics/custom_collectors.go 69.44% 8 Missing and 3 partials ⚠️
pkg/operator/hive/hive_controller.go 0.00% 6 Missing ⚠️
...er/clusterprovision/clusterprovision_controller.go 0.00% 4 Missing ⚠️
.../clusterdeployment/clusterdeployment_controller.go 90.90% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2502      +/-   ##
==========================================
- Coverage   46.27%   46.10%   -0.17%     
==========================================
  Files         279      280       +1     
  Lines       32904    32965      +61     
==========================================
- Hits        15225    15198      -27     
- Misses      16399    16483      +84     
- Partials     1280     1284       +4     
Files with missing lines Coverage Δ
...kg/controller/clusterdeployment/clusterinstalls.go 77.53% <100.00%> (+0.40%) ⬆️
.../controller/clusterdeployment/clusterprovisions.go 62.57% <100.00%> (+0.29%) ⬆️
...lusterdeprovision/clusterdeprovision_controller.go 52.85% <100.00%> (-0.18%) ⬇️
pkg/controller/clusterprovision/metrics.go 100.00% <ø> (ø)
...g/controller/hibernation/hibernation_controller.go 64.82% <100.00%> (ø)
.../clusterdeployment/clusterdeployment_controller.go 67.42% <90.90%> (+0.41%) ⬆️
...er/clusterprovision/clusterprovision_controller.go 51.42% <0.00%> (-0.14%) ⬇️
pkg/operator/hive/hive_controller.go 0.00% <0.00%> (ø)
pkg/controller/metrics/custom_collectors.go 85.93% <69.44%> (-2.65%) ⬇️
pkg/controller/metrics/metrics_to_report.go 60.60% <60.60%> (ø)
... and 2 more

... and 1 file with indirect coverage changes

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 29, 2024

@suhanime: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-pool 446da45 link true /test e2e-pool
ci/prow/e2e 446da45 link true /test e2e

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-sigs/prow repository. I understand the commands that are listed here.

@suhanime suhanime closed this Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants