Skip to content

Commit

Permalink
fix library usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Pothulapati committed Sep 19, 2023
1 parent 72d49b9 commit 03e11ff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions hack/print-roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func main() {
panic(err.Error())
}

role, err := getRole(fmt.Sprintf("localhost:%d", startPort+i))
role, err := getRole(context.Background(), fmt.Sprintf("localhost:%d", startPort+i))
if err != nil {
panic(err.Error())
}
Expand Down Expand Up @@ -108,12 +108,12 @@ func portForward(ctx context.Context, clientset *kubernetes.Clientset, config *r
return nil
}

func getRole(url string) (string, error) {
func getRole(ctx context.Context, url string) (string, error) {
redisClient := redis.NewClient(&redis.Options{
Addr: url,
})

resp, err := redisClient.Info("replication").Result()
resp, err := redisClient.Info(ctx, "replication").Result()
if err != nil {
return "", err
}
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/dragonfly_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (dfi *DragonflyInstance) checkReplicaRole(ctx context.Context, pod *corev1.
Addr: fmt.Sprintf("%s:%d", pod.Status.PodIP, resources.DragonflyAdminPort),
})

resp, err := redisClient.Info("replication").Result()
resp, err := redisClient.Info(ctx, "replication").Result()
if err != nil {
return false, err
}
Expand Down Expand Up @@ -328,7 +328,7 @@ func (dfi *DragonflyInstance) replicaOf(ctx context.Context, pod *corev1.Pod, ma
})

dfi.log.Info("Trying to invoke SLAVE OF command", "pod", pod.Name, "master", masterIp, "addr", redisClient.Options().Addr)
resp, err := redisClient.SlaveOf(masterIp, fmt.Sprint(resources.DragonflyAdminPort)).Result()
resp, err := redisClient.SlaveOf(ctx, masterIp, fmt.Sprint(resources.DragonflyAdminPort)).Result()
if err != nil {
return fmt.Errorf("error running SLAVE OF command: %s", err)
}
Expand All @@ -355,7 +355,7 @@ func (dfi *DragonflyInstance) replicaOfNoOne(ctx context.Context, pod *corev1.Po
})

dfi.log.Info("Running SLAVE OF NO ONE command", "pod", pod.Name, "addr", redisClient.Options().Addr)
resp, err := redisClient.SlaveOf("NO", "ONE").Result()
resp, err := redisClient.SlaveOf(ctx, "NO", "ONE").Result()
if err != nil {
return fmt.Errorf("error running SLAVE OF NO ONE command: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ func isStableState(ctx context.Context, c client.Client, pod *corev1.Pod) (bool,
Addr: fmt.Sprintf("%s:%d", pod.Status.PodIP, resources.DragonflyAdminPort),
})

_, err := redisClient.Ping().Result()
_, err := redisClient.Ping(ctx).Result()
if err != nil {
return false, err
}

info, err := redisClient.Info("replication").Result()
info, err := redisClient.Info(ctx, "replication").Result()
if err != nil {
return false, err
}
Expand Down

0 comments on commit 03e11ff

Please sign in to comment.