Skip to content

Commit

Permalink
[CHORE] enforcing default value instead of block cr onboarding (#136)
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Takashi <nicolas.takashi@coralogix.com>
  • Loading branch information
nicolastakashi authored Aug 26, 2024
1 parent f2adae7 commit d761dbe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
1 change: 0 additions & 1 deletion apis/coralogix/v1alpha1/recordingrulegroupset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ type RecordingRuleGroup struct {
Name string `json:"name,omitempty"`

//+kubebuilder:default=60
// +kubebuilder:validation:Minimum=60
IntervalSeconds int32 `json:"intervalSeconds,omitempty"`

// +optional
Expand Down
1 change: 0 additions & 1 deletion config/crd/bases/coralogix.com_recordingrulegroupsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ spec:
intervalSeconds:
default: 60
format: int32
minimum: 60
type: integer
limit:
format: int64
Expand Down
13 changes: 11 additions & 2 deletions controllers/prometheusrule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,18 @@ func prometheusRuleToRecordingRuleToRuleGroupSet(log logr.Logger, prometheusRule
if group.Interval != "" {
duration, err := time.ParseDuration(string(group.Interval))
if err != nil {
log.V(int(zapcore.WarnLevel)).Info("failed to parse interval duration", "interval", group.Interval, "error", err, "using default interval")
log.V(int(zapcore.WarnLevel)).Info("Failed to parse interval duration", "interval", group.Interval, "error", err, "using default interval")
}

// Convert duration to seconds
durationSeconds := int32(duration.Seconds())

if durationSeconds < interval {
log.V(int(zapcore.WarnLevel)).Info("Recording rule interval is lower than the default interval", "interval", durationSeconds, "default interval", interval, "using the greater interval")
} else {
// Update interval if parsed duration is greater
interval = durationSeconds
}
interval = int32(duration.Seconds())
}

if rules := prometheusInnerRulesToCoralogixInnerRules(group.Rules); len(rules) > 0 {
Expand Down
11 changes: 5 additions & 6 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Alert is the Schema for the alerts API
<td>true</td>
</tr>
<tr>
<td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectmeta-v1-meta">metadata</a></b></td>
<td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#objectmeta-v1-meta">metadata</a></b></td>
<td>object</td>
<td>Refer to the Kubernetes API documentation for the fields of the `metadata` field.</td>
<td>true</td>
Expand Down Expand Up @@ -4623,7 +4623,7 @@ OutboundWebhook is the Schema for the outboundwebhooks API
<td>true</td>
</tr>
<tr>
<td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectmeta-v1-meta">metadata</a></b></td>
<td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#objectmeta-v1-meta">metadata</a></b></td>
<td>object</td>
<td>Refer to the Kubernetes API documentation for the fields of the `metadata` field.</td>
<td>true</td>
Expand Down Expand Up @@ -5842,7 +5842,7 @@ RecordingRuleGroupSet is the Schema for the recordingrulegroupsets API
<td>true</td>
</tr>
<tr>
<td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectmeta-v1-meta">metadata</a></b></td>
<td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#objectmeta-v1-meta">metadata</a></b></td>
<td>object</td>
<td>Refer to the Kubernetes API documentation for the fields of the `metadata` field.</td>
<td>true</td>
Expand Down Expand Up @@ -5915,7 +5915,6 @@ RecordingRuleGroupSetSpec defines the desired state of RecordingRuleGroupSet
<br/>
<i>Format</i>: int32<br/>
<i>Default</i>: 60<br/>
<i>Minimum</i>: 60<br/>
</td>
<td>false</td>
</tr><tr>
Expand Down Expand Up @@ -6146,7 +6145,7 @@ RuleGroup is the Schema for the rulegroups API
<td>true</td>
</tr>
<tr>
<td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectmeta-v1-meta">metadata</a></b></td>
<td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#objectmeta-v1-meta">metadata</a></b></td>
<td>object</td>
<td>Refer to the Kubernetes API documentation for the fields of the `metadata` field.</td>
<td>true</td>
Expand Down Expand Up @@ -7421,4 +7420,4 @@ RuleGroupStatus defines the observed state of RuleGroup
</td>
<td>true</td>
</tr></tbody>
</table>
</table>

0 comments on commit d761dbe

Please sign in to comment.