Skip to content

Commit

Permalink
controller: fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
talal committed Aug 19, 2020
1 parent 2141440 commit 18daa89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (c *Controller) syncHandler(key string) error {
return nil
}

// Get the corresponding AbsentPrometheusRule.
// Get the corresponding absentPrometheusRule.
existingAbsentPromRule := false
absentPromRule, err := c.getAbsentPrometheusRule(namespace, prometheusServer)
switch {
Expand Down
13 changes: 6 additions & 7 deletions internal/controller/prometheusrule.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (
"k8s.io/apimachinery/pkg/labels"
)

// AbsentPrometheusRuleName returns the name of an AbsentPrometheusRule.
// AbsentPrometheusRuleName returns the name of an absentPrometheusRule.
func AbsentPrometheusRuleName(prometheusServer string) string {
return fmt.Sprintf("%s-absent-metric-alert-rules", prometheusServer)
}

// absentPrometheusRule is a wrapper around *monitoringv1.PrometheusRule with
// some additional info that we use for working with AbsentPrometheusRules.
// some additional info that we use for working with absentPrometheusRules.
//
// An absentPrometheusRule is the corresponding resource that is generated for
// a PrometheusRule resource for defining the absent metric alerts.
Expand All @@ -45,7 +45,6 @@ type absentPrometheusRule struct {
Service string
}

// TODO: add tier and service as labels.
func (c *Controller) getAbsentPrometheusRule(namespace, prometheusServer string) (*absentPrometheusRule, error) {
n := AbsentPrometheusRuleName(prometheusServer)
pr, err := c.promClientset.MonitoringV1().PrometheusRules(namespace).Get(context.Background(), n, metav1.GetOptions{})
Expand Down Expand Up @@ -138,13 +137,13 @@ func (c *Controller) newAbsentPrometheusRule(namespace, prometheusServer string)
return &aPR, nil
}

// updateAbsentPrometheusRule updates an AbsentPrometheusRule with the provided
// updateAbsentPrometheusRule updates an absentPrometheusRule with the provided
// slice of RuleGroup.
func (c *Controller) updateAbsentPrometheusRule(
absentPromRule *absentPrometheusRule,
absentAlertRuleGroups []monitoringv1.RuleGroup) error {

// Check if the AbsentPrometheusRule already has these rule groups.
// Check if the absentPrometheusRule already has these rule groups.
// Update if it does, otherwise append.
old := absentPromRule.Spec.Groups
var new []monitoringv1.RuleGroup
Expand Down Expand Up @@ -207,12 +206,12 @@ func (c *Controller) cleanUpOrphanedAbsentAlertsNamespace(namespace, promRuleNam
}

// cleanUpOrphanedAbsentAlerts deletes orphaned absent alert rules concerning a
// specific PrometheusRule from a specific AbsentPrometheusRule.
// specific PrometheusRule from a specific absentPrometheusRule.
func (c *Controller) cleanUpOrphanedAbsentAlerts(promRuleName string, absentPromRule *absentPrometheusRule) error {
old := absentPromRule.Spec.Groups
new := make([]monitoringv1.RuleGroup, 0, len(old))
for _, g := range old {
// The rule group names for AbsentPrometheusRule have the format:
// The rule group names for absentPrometheusRule have the format:
// originPromRuleName/ruleGroupName.
sL := strings.Split(g.Name, "/")
if len(sL) > 0 && sL[0] == promRuleName {
Expand Down

0 comments on commit 18daa89

Please sign in to comment.