Skip to content

Commit

Permalink
Merge pull request #437 from DharmitD/reque-params
Browse files Browse the repository at this point in the history
Parameterize Requeue Time
  • Loading branch information
openshift-merge-bot[bot] authored Nov 13, 2023
2 parents ec0ece0 + d190eb7 commit 45f03e5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions config/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,12 @@ vars:
apiVersion: v1
fieldref:
fieldpath: data.DSPO_HEALTHCHECK_OBJECTSTORE_CONNECTIONTIMEOUT
- name: REQUEUE_TIME
objref:
kind: ConfigMap
name: dspo-parameters
apiVersion: v1
fieldref:
fieldpath: data.DSPO_REQUEUE_TIME
configurations:
- params.yaml
1 change: 1 addition & 0 deletions config/base/params.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ ZAP_LOG_LEVEL=info
MAX_CONCURRENT_RECONCILES=10
DSPO_HEALTHCHECK_DATABASE_CONNECTIONTIMEOUT=15s
DSPO_HEALTHCHECK_OBJECTSTORE_CONNECTIONTIMEOUT=15s
DSPO_REQUEUE_TIME=2m
1 change: 1 addition & 0 deletions config/configmaps/files/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ DSPO:
ConnectionTimeout: $(DSPO_HEALTHCHECK_DATABASE_CONNECTIONTIMEOUT)
ObjectStore:
ConnectionTimeout: $(DSPO_HEALTHCHECK_OBJECTSTORE_CONNECTIONTIMEOUT)
RequeueTime: $(DSPO_REQUEUE_TIME)
2 changes: 2 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ spec:
value: $(ZAP_LOG_LEVEL)
- name: MAX_CONCURRENT_RECONCILES
value: $(MAX_CONCURRENT_RECONCILES)
- name: REQUEUE_TIME
value: $(REQUEUE_TIME)
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand Down
3 changes: 3 additions & 0 deletions controllers/config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const (
MlmdWriterImagePath = "Images.MlmdWriter"
ObjStoreConnectionTimeoutConfigName = "DSPO.HealthCheck.ObjectStore.ConnectionTimeout"
DBConnectionTimeoutConfigName = "DSPO.HealthCheck.Database.ConnectionTimeout"
RequeueTimeConfigName = "DSPO.RequeueTime"
)

// DSPA Status Condition Types
Expand Down Expand Up @@ -118,6 +119,8 @@ const DefaultObjStoreConnectionTimeout = time.Second * 15

const DefaultMaxConcurrentReconciles = 10

const DefaultRequeueTime = 2 * time.Minute

func GetConfigRequiredFields() []string {
return requiredFields
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/dspipeline_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"fmt"
"sigs.k8s.io/controller-runtime/pkg/controller"
"time"

"github.com/go-logr/logr"
mf "github.com/manifestival/manifestival"
Expand Down Expand Up @@ -207,10 +206,11 @@ func (r *DSPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
return ctrl.Result{}, nil
}

requeueTime := config.GetDurationConfigWithDefault(config.RequeueTimeConfigName, config.DefaultRequeueTime)
err = params.ExtractParams(ctx, dspa, r.Client, r.Log)
if err != nil {
log.Info(fmt.Sprintf("Encountered error when parsing CR: [%s]", err))
return ctrl.Result{Requeue: true, RequeueAfter: 2 * time.Minute}, nil
return ctrl.Result{Requeue: true, RequeueAfter: requeueTime}, nil
}

err = r.ReconcileDatabase(ctx, dspa, params)
Expand Down

0 comments on commit 45f03e5

Please sign in to comment.