@@ -390,6 +390,13 @@ func (dfi *DragonflyInstance) replicaOf(ctx context.Context, pod *corev1.Pod, ma
390
390
return fmt .Errorf ("response of `SLAVE OF` on replica is not OK: %s" , resp )
391
391
}
392
392
393
+ if dfi .df .Spec .Snapshot != nil && dfi .df .Spec .Snapshot .EnableOnMasterOnly {
394
+ dfi .log .Info ("clearing snapshot cron schedule on replica" , "pod" , pod .Name )
395
+ if _ , err := redisClient .ConfigSet (ctx , "snapshot_cron" , "" ).Result (); err != nil {
396
+ return fmt .Errorf ("failed to clear snapshot_cron on replica %s: %w" , pod .Name , err )
397
+ }
398
+ }
399
+
393
400
dfi .log .Info ("marking pod role as replica" , "pod" , pod .Name )
394
401
patchFrom := client .MergeFrom (pod .DeepCopy ())
395
402
pod .Labels [resources .RoleLabelKey ] = resources .Replica
@@ -418,6 +425,14 @@ func (dfi *DragonflyInstance) replicaOfNoOne(ctx context.Context, pod *corev1.Po
418
425
return fmt .Errorf ("response of `SLAVE OF NO ONE` on master is not OK: %s" , resp )
419
426
}
420
427
428
+ if dfi .df .Spec .Snapshot != nil && dfi .df .Spec .Snapshot .EnableOnMasterOnly {
429
+ dfi .log .Info ("setting snapshot cron schedule on master" , "pod" , pod .Name )
430
+ cron := dfi .df .Spec .Snapshot .Cron
431
+ if _ , err := redisClient .ConfigSet (ctx , "snapshot_cron" , cron ).Result (); err != nil {
432
+ return fmt .Errorf ("failed to set snapshot_cron on master %s: %w" , pod .Name , err )
433
+ }
434
+ }
435
+
421
436
dfi .log .Info ("marking pod role as master" , "pod" , pod .Name )
422
437
patchFrom := client .MergeFrom (pod .DeepCopy ())
423
438
pod .Labels [resources .RoleLabelKey ] = resources .Master
0 commit comments