Skip to content

Commit b4e2c73

Browse files
committed
fixed deepcopy []Pod
1 parent 6d1e7f8 commit b4e2c73

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

pkg/controller/distributedrediscluster/distributedrediscluster_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ func (r *ReconcileDistributedRedisCluster) Reconcile(request reconcile.Request)
149149
}
150150

151151
ctx.pods = clusterPods(redisClusterPods.Items)
152+
reqLogger.V(6).Info("debug cluster pods", "", ctx.pods)
152153
ctx.healer = clustermanger.NewHealer(&heal.CheckAndHeal{
153154
Logger: reqLogger,
154155
PodControl: k8sutil.NewPodController(r.client),
@@ -226,7 +227,9 @@ func (r *ReconcileDistributedRedisCluster) Reconcile(request reconcile.Request)
226227
reqLogger.V(4).Info("buildClusterStatus", "status", status)
227228
r.updateClusterIfNeed(instance, status)
228229

230+
instance.Status = *status
229231
if needClusterOperation(instance, reqLogger) {
232+
reqLogger.Info(">>>>>> clustering")
230233
err = r.sync(ctx)
231234
if err != nil {
232235
new := instance.Status.DeepCopy()

pkg/controller/distributedrediscluster/helper.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ func newRedisAdmin(pods []*corev1.Pod, password string, cfg *config.Redis) (redi
5353
for _, pod := range pods {
5454
redisPort := redisutil.DefaultRedisPort
5555
for _, container := range pod.Spec.Containers {
56-
if container.Name == "redis-node" {
56+
if container.Name == "redis" {
5757
for _, port := range container.Ports {
58-
if port.Name == "redis" {
58+
if port.Name == "client" {
5959
redisPort = fmt.Sprintf("%d", port.ContainerPort)
6060
}
6161
}
6262
}
6363
}
64+
log.V(4).Info("append redis admin addr", "addr", pod.Status.PodIP, "port", redisPort)
6465
nodesAddrs = append(nodesAddrs, net.JoinHostPort(pod.Status.PodIP, redisPort))
6566
}
6667
adminConfig := redisutil.AdminOptions{
@@ -148,7 +149,8 @@ func newRedisCluster(infos *redisutil.ClusterInfos, cluster *redisv1alpha1.Distr
148149
func clusterPods(pods []corev1.Pod) []*corev1.Pod {
149150
var podSlice []*corev1.Pod
150151
for _, pod := range pods {
151-
podSlice = append(podSlice, &pod)
152+
podPointer := pod
153+
podSlice = append(podSlice, &podPointer)
152154
}
153155
return podSlice
154156
}

pkg/controller/distributedrediscluster/sync_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (r *ReconcileDistributedRedisCluster) waitForClusterJoin(ctx *syncContext)
108108
// return Redis.Wrap(err, "SetConfigEpoch")
109109
//}
110110
if infos, err := ctx.admin.GetClusterInfos(); err == nil {
111-
ctx.reqLogger.V(5).Info("debug waitForClusterJoin", "cluster infos", infos)
111+
ctx.reqLogger.V(6).Info("debug waitForClusterJoin", "cluster infos", infos)
112112
return nil
113113
}
114114
var firstNode *redisutil.Node

pkg/redisutil/admin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func (a *Admin) GetClusterInfos() (*ClusterInfos, error) {
132132
for addr, c := range a.Connections().GetAll() {
133133
nodeinfos, err := a.getInfos(c, addr)
134134
if err != nil {
135+
log.WithValues("err", err).Info("get redis info failed")
135136
infos.Status = ClusterInfosPartial
136137
clusterErr.partial = true
137138
clusterErr.errs[addr] = err

0 commit comments

Comments
 (0)