Skip to content

Commit 7997542

Browse files
authored
Merge pull request #52 from Infisical/feat/fallback-sync
feat: resync interval change for instant updates
2 parents f436ac3 + ae6b6b0 commit 7997542

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

api/v1alpha1/infisicalsecret_types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ type InfisicalSecretSpec struct {
176176
// +kubebuilder:validation:Optional
177177
ManagedKubeConfigMapReferences []ManagedKubeConfigMapConfig `json:"managedKubeConfigMapReferences"`
178178

179-
// +kubebuilder:default:=60
180179
// +kubebuilder:validation:Optional
181180
ResyncInterval int `json:"resyncInterval"`
182181

@@ -199,7 +198,6 @@ type InfisicalSecretSyncConfig struct {
199198
InstantUpdates bool `json:"instantUpdates"`
200199

201200
// +kubebuilder:validation:Optional
202-
// +kubebuilder:default:="60s"
203201
ResyncInterval string `json:"resyncInterval"`
204202
}
205203

config/crd/bases/secrets.infisical.com_infisicalsecrets.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,12 @@ spec:
506506
- secretNamespace
507507
type: object
508508
resyncInterval:
509-
default: 60
510509
type: integer
511510
syncConfig:
512511
properties:
513512
instantUpdates:
514513
type: boolean
515514
resyncInterval:
516-
default: 60s
517515
type: string
518516
type: object
519517
tls:

internal/controller/infisicalsecret_controller.go

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
)
4141

4242
const DEFAULT_RESYNC_INTERVAL = time.Minute
43+
const DEFAULT_RESYNC_INTERVAL_WITH_INSTANT_UPDATES = time.Hour
4344

4445
// InfisicalSecretReconciler reconciles a InfisicalSecret object
4546
type InfisicalSecretReconciler struct {
@@ -144,19 +145,34 @@ func (r *InfisicalSecretReconciler) Reconcile(ctx context.Context, req ctrl.Requ
144145

145146
}
146147

147-
if duration, err := util.ConvertResyncIntervalToDuration(syncConfig.ResyncInterval, true); err == nil {
148-
// successfully parsed the resync interval. if its parsed to 0, we should use the default of 60 seconds
149-
if duration != 0 {
150-
requeueTime = duration
151-
logger.Info(fmt.Sprintf("resync interval set from syncConfig. interval: %v", requeueTime))
148+
// Determine the default resync interval based on InstantUpdates setting
149+
defaultResyncInterval := DEFAULT_RESYNC_INTERVAL
150+
if syncConfig.InstantUpdates {
151+
defaultResyncInterval = DEFAULT_RESYNC_INTERVAL_WITH_INSTANT_UPDATES
152+
}
153+
154+
// Check if ResyncInterval was explicitly provided
155+
resyncIntervalProvided := syncConfig.ResyncInterval != "" && syncConfig.ResyncInterval != "0s"
156+
157+
if resyncIntervalProvided {
158+
if duration, err := util.ConvertResyncIntervalToDuration(syncConfig.ResyncInterval, true); err == nil {
159+
if duration != 0 {
160+
requeueTime = duration
161+
logger.Info(fmt.Sprintf("resync interval set from syncConfig. interval: %v", requeueTime))
162+
} else {
163+
// Parsed to 0, use default based on InstantUpdates
164+
logger.Info(fmt.Sprintf("resync interval set to 0, using default of %v", defaultResyncInterval))
165+
requeueTime = defaultResyncInterval
166+
}
152167
} else {
153-
logger.Info(fmt.Sprintf("resync interval set to 0, using default of %v", DEFAULT_RESYNC_INTERVAL))
154-
requeueTime = DEFAULT_RESYNC_INTERVAL
168+
// Failed to parse the resync interval
169+
logger.Error(err, fmt.Sprintf("failed to parse resync interval from syncConfig, using default of %v. [err=%v]", defaultResyncInterval, err))
170+
requeueTime = defaultResyncInterval
155171
}
156172
} else {
157-
// failed to parse the resync interval
158-
logger.Error(err, fmt.Sprintf("failed to parse resync interval from syncConfig, using default of %v. [err=%v]", DEFAULT_RESYNC_INTERVAL, err))
159-
requeueTime = DEFAULT_RESYNC_INTERVAL
173+
// ResyncInterval not provided, use default based on InstantUpdates
174+
logger.Info(fmt.Sprintf("resync interval not provided, using default of %v (instantUpdates=%v)", defaultResyncInterval, syncConfig.InstantUpdates))
175+
requeueTime = defaultResyncInterval
160176
}
161177

162178
// Check if the resource is already marked for deletion

0 commit comments

Comments
 (0)