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

monitoring: update label on prometheus resources #9243

Merged
merged 1 commit into from Nov 24, 2021

Conversation

LittleFox94
Copy link
Contributor

Description of your changes:

Updating the promethes resources (PrometheusRule and ServiceMonitor) is
done by fetching the current resource from the server and updating the
spec on it. This commit makes it also apply the labels, so users can
update them via rook CRDs.

Which issue is resolved by this Pull Request:
Resolves #9241

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Skip Tests for Docs: Add the flag for skipping the build if this is only a documentation change. See here for the flag.
  • Skip Unrelated Tests: Add a flag to run tests for a specific storage provider. See test options.
  • Reviewed the developer guide on Submitting a Pull Request
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.
  • Pending release notes updated with breaking and/or notable changes, if necessary.
  • Upgrade from previous release is tested and upgrade user guide is updated, if necessary.
  • Code generation (make codegen) has been run to update object specifications, if necessary.

Updating the promethes reources (PrometheusRule and ServiceMonitor) is
done by fetching the current resource from the server and updating the
spec on it. This commit makes it also apply the labels, so users can
update them via rook CRDs.

Closes: rook#9241
Signed-off-by: Mara Sophie Grosch <littlefox@lf-net.org>
@@ -80,6 +80,7 @@ func CreateOrUpdateServiceMonitor(serviceMonitorDefinition *monitoringv1.Service
return nil, fmt.Errorf("failed to retrieve servicemonitor. %v", err)
}
oldSm.Spec = serviceMonitorDefinition.Spec
oldSm.ObjectMeta.Labels = serviceMonitorDefinition.ObjectMeta.Labels
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to do the same for annotations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually had that in there at first, but iirc there is currently no way to set annotations on these resources via rook CRDs and the templates do not contain any, too - so I removed that, for not cluttering code with seemingly unneeded things.

Copy link
Member

Choose a reason for hiding this comment

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

I see, we should probably add the annotations in a future PR, but looks good for now!

@@ -80,6 +80,7 @@ func CreateOrUpdateServiceMonitor(serviceMonitorDefinition *monitoringv1.Service
return nil, fmt.Errorf("failed to retrieve servicemonitor. %v", err)
}
oldSm.Spec = serviceMonitorDefinition.Spec
oldSm.ObjectMeta.Labels = serviceMonitorDefinition.ObjectMeta.Labels
Copy link
Member

Choose a reason for hiding this comment

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

I see, we should probably add the annotations in a future PR, but looks good for now!

@travisn travisn merged commit 9d3bcb4 into rook:master Nov 24, 2021
mergify bot added a commit that referenced this pull request Nov 24, 2021
monitoring: update label on prometheus resources (backport #9243)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

monitoring: PrometheusRule and ServiceMonitor labels not updated
2 participants