Skip to content

Commit

Permalink
Merge pull request #191 from Vikaspogu/issue-162-sync-period
Browse files Browse the repository at this point in the history
Fixes#162
  • Loading branch information
raffaelespazzoli authored Sep 11, 2023
2 parents e804465 + edc154a commit e8311c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package main
import (
"flag"
"os"
"strconv"
"time"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
Expand Down Expand Up @@ -70,13 +72,24 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

var syncPeriod = 36000 * time.Second //Defaults to every 10Hrs
if syncPeriodSeconds, ok := os.LookupEnv("SYNC_PERIOD_SECONDS"); ok && syncPeriodSeconds != "" {
if syncPeriodSecondsInt, err := strconv.ParseInt(syncPeriodSeconds, 10, 64); err == nil {
syncPeriod = time.Duration(syncPeriodSecondsInt) * time.Second
} else if err != nil {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
}
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "3d7d3a62.redhat.io",
SyncPeriod: &syncPeriod,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ Additionally, the operator checks for an environment variable named `CACHE_VAULT

By default, or if the variable is set to any other value, the operator will create a new client with a new token for each request it makes to Vault.

SyncPeriod determines the minimum frequency at which watched resources are reconciled. Set the environment variable named `SYNC_PERIOD_SECONDS` to update the frequency at which watched resources are reconciled. It defaults to 10 hours if unset.

For certificates, the recommended approach is to mount the secret or configmap containing the certificate as described [here](https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/design/subscription-config.md#volumes), and the configure the corresponding variables to point at the files location in the mounted path.

Here is an example:
Expand Down

0 comments on commit e8311c1

Please sign in to comment.