monitoring: only set prometheus rules ownerref in same namespace
The ownerref of the prometheus rules should not be set if in a different namespace than the cluster CR. Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
This commit is contained in:
1 file changed
+6
-3
@@ -523,9 +523,12 @@ func (c *Cluster) DeployPrometheusRule(name, namespace string) error {
|
||||
}
|
||||
prometheusRule.SetName(name)
|
||||
prometheusRule.SetNamespace(namespace)
|
||||
err = c.clusterInfo.OwnerInfo.SetControllerReference(prometheusRule)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to set owner reference to prometheus rule %q", prometheusRule.Name)
|
||||
if namespace == c.clusterInfo.Namespace {
|
||||
// only set the ownerref if in the same namespace
|
||||
err = c.clusterInfo.OwnerInfo.SetControllerReference(prometheusRule)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to set owner reference to prometheus rule %q", prometheusRule.Name)
|
||||
}
|
||||
}
|
||||
cephv1.GetMonitoringLabels(c.spec.Labels).OverwriteApplyToObjectMeta(&prometheusRule.ObjectMeta)
|
||||
if _, err := k8sutil.CreateOrUpdatePrometheusRule(c.clusterInfo.Context, prometheusRule); err != nil {
|
||||
|
||||
Reference in new issue
Block a user