Skip to content

Lease time modification #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion operator/redisfailover/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ func New(cfg Config, k8sService k8s.Services, k8sClient kubernetes.Interface, lo
rfRetriever := NewRedisFailoverRetriever(cfg, k8sService)

kooperLogger := kooperlogger{Logger: logger.WithField("operator", "redisfailover")}

lockCfg := &leaderelection.LockConfig{
Comment on lines +44 to +45
Copy link
Preview

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation detected. This line uses spaces for indentation instead of tabs, which doesn't match the surrounding code's indentation style.

Suggested change
lockCfg := &leaderelection.LockConfig{
lockCfg := &leaderelection.LockConfig{

Copilot uses AI. Check for mistakes.

LeaseDuration: 60 * time.Second,
RenewDeadline: 55 * time.Second,
RetryPeriod: 2 * time.Second,
Comment on lines +46 to +48
Copy link
Preview

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider defining the timing values as named constants to improve maintainability and make the configuration more explicit. Magic numbers like 60, 55, and 2 should be documented or extracted as constants.

Suggested change
LeaseDuration: 60 * time.Second,
RenewDeadline: 55 * time.Second,
RetryPeriod: 2 * time.Second,
LeaseDuration: leaseDuration,
RenewDeadline: renewDeadline,
RetryPeriod: retryPeriod,

Copilot uses AI. Check for mistakes.

}
// Leader election service.
leSVC, err := leaderelection.NewDefault(lockKey, lockNamespace, k8sClient, kooperLogger)
leSVC, err := leaderelection.New(lockKey, lockNamespace, lockCfg, k8sClient, kooperLogger)
if err != nil {
return nil, err
}
Expand Down