Skip to content

Conversation

@machadovilaca
Copy link
Owner

No description provided.

Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
// Generate SHA256 hash
hash := sha256.Sum256([]byte(hashInput))

return fmt.Sprintf("%s;%x", name, hash)
Copy link
Collaborator

@avlitman avlitman Dec 16, 2025

Choose a reason for hiding this comment

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

I cant comment on lines that didn't change for some reason.. since now the seperator is ; need to update func (c *client) applyLabelChangesViaAlertRelabelConfig in update_platform_alert_rule.go

Copy link
Owner Author

Choose a reason for hiding this comment

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

done, thanks


configMapClient := rrm.clientset.CoreV1().ConfigMaps(ClusterMonitoringNamespace)

if err := configMapClient.Delete(ctx, RelabeledRulesConfigMapName, metav1.DeleteOptions{}); err != nil {
Copy link
Collaborator

@avlitman avlitman Dec 16, 2025

Choose a reason for hiding this comment

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

check if ConfigMap exists or ignore not found error, in case it's fresh deployment or retry (delete succeeds but create fails) it will not get to the create and fail here.

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

}

originalRule, err := c.getOriginalPlatformRule(ctx, prId, alertRuleId)
originalRule, err := c.getOriginalPlatformRule(ctx, namespace, name, rule.Labels[k8s.AlertRuleLabelId])
Copy link
Collaborator

Choose a reason for hiding this comment

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

why you use rule.Labels[k8s.AlertRuleLabelId] and not alertRuleId ?
I mean they should be same right?

Copy link
Owner Author

Choose a reason for hiding this comment

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

yup, same same

Comment on lines 355 to 363
if rule.Alert == "TestRelabelAlert" {
for _, config := range relabelConfigs {
log.Infof("TestRelabelAlert relabel config: %+v", config)
}

log.Infof("TestRelabelAlert Relabeled alert %s from %s/%s with %d relabel configs", rule.Alert, promRule.Namespace, promRule.Name, len(relabelConfigs))
log.Infof("TestRelabelAlert Original labels: %v", rule.Labels)
log.Infof("TestRelabelAlert Relabeled labels: %v", relabeledLabels.Map())
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

why we use hardcoded alert name in this file?
maybe set a debug flag or try to make the test work without it

Copy link
Owner Author

Choose a reason for hiding this comment

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

removed, used for debug

"k8s.io/apimachinery/pkg/types"

"github.com/openshift/monitoring-plugin/pkg/management/mapper"
"github.com/openshift/monitoring-plugin/pkg/k8s"
Copy link
Collaborator

@avlitman avlitman Dec 16, 2025

Choose a reason for hiding this comment

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

I can't comment on lines that didn't added in this pr, but noticed in this file in func (c *client) buildRelabelConfigs

why we dont use Action: "LabelDrop" here:

		case "LabelDrop":
			config := osmv1.RelabelConfig{
				SourceLabels: []osmv1.LabelName{"alertname"},
				Regex:        alertName,
				TargetLabel:  change.sourceLabel,
				Replacement:  "",
				Action:       "Replace",
			}

Replacement with empty string will not drop the label right?

Copy link
Owner Author

Choose a reason for hiding this comment

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

create an issue to fix please

Copy link
Collaborator

Choose a reason for hiding this comment

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

you mean in jira?

}

go rrm.prometheusRulesInformer.Run(ctx.Done())
go rrm.secretInformer.Run(ctx.Done())
Copy link
Collaborator

@avlitman avlitman Dec 16, 2025

Choose a reason for hiding this comment

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

add go rrm.configMapInformer.Run(ctx.Done()) to start the configMap informer

Copy link
Owner Author

Choose a reason for hiding this comment

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

updated


cache.WaitForNamedCacheSync("RelabeledRulesConfig informer", ctx.Done(),
rrm.prometheusRulesInformer.HasSynced,
rrm.secretInformer.HasSynced,
Copy link
Collaborator

Choose a reason for hiding this comment

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

add rrm.configMapInformer.HasSynced

Copy link
Owner Author

Choose a reason for hiding this comment

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

updated

Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
@machadovilaca machadovilaca force-pushed the add-persistent-relabeled-alerts-rules branch from 2ac914a to 63dffd3 Compare December 17, 2025 11:57
@machadovilaca machadovilaca merged commit 7f42262 into add-alert-management-api-base Dec 17, 2025
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.

3 participants