Skip to content

Commit

Permalink
Add REPORTING_INTERVAL env var
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
  • Loading branch information
stefanprodan committed Jun 28, 2024
1 parent c8589d4 commit 97e11fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
18 changes: 15 additions & 3 deletions api/v1/fluxreport_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
package v1

import (
"os"
"strings"
"time"

"github.com/fluxcd/pkg/apis/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const FluxReportKind = "FluxReport"
const (
FluxReportKind = "FluxReport"
ReportIntervalEvnKey = "REPORTING_INTERVAL"
)

// FluxReportSpec defines the observed state of a Flux installation.
type FluxReportSpec struct {
Expand Down Expand Up @@ -188,13 +192,21 @@ func (in *FluxReport) IsDisabled() bool {
}

// GetInterval returns the interval at which the object should be reconciled.
// If no interval is set, the default is 10 minutes.
// If the annotation is not set, the interval is read from the
// REPORTING_INTERVAL environment variable. If the variable is not set,
// the default interval is 5 minutes.
func (in *FluxReport) GetInterval() time.Duration {
val, ok := in.GetAnnotations()[ReconcileAnnotation]
if ok && strings.ToLower(val) == DisabledValue {
return 0
}
defaultInterval := 10 * time.Minute
defaultInterval := 5 * time.Minute
if ri, _ := os.LookupEnv(ReportIntervalEvnKey); ri != "" {
if d, err := time.ParseDuration(ri); err != nil {
defaultInterval = d
}
}

val, ok = in.GetAnnotations()[ReconcileEveryAnnotation]
if !ok {
return defaultInterval
Expand Down
5 changes: 4 additions & 1 deletion docs/api/v1/fluxreport.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ The FluxReport is automatically generated by the operator for the following cond
The reconciliation behaviour can be configured using the following annotations:

- `fluxcd.controlplane.io/reconcile`: Enable or disable the reconciliation loop. Default is `enabled`, set to `disabled` to pause the reconciliation.
- `fluxcd.controlplane.io/reconcileEvery`: Set the reconciliation interval. Default is `10m`.
- `fluxcd.controlplane.io/reconcileEvery`: Set the reconciliation interval. Default is `5m`.

The default reconciliation interval of the report can be changed by setting
the `REPORTING_INTERVAL` environment variable in the operator deployment.

## Flux Resource Metrics

Expand Down

0 comments on commit 97e11fd

Please sign in to comment.