Skip to content

Commit

Permalink
remove logger
Browse files Browse the repository at this point in the history
Signed-off-by: drivebyer <[email protected]>
  • Loading branch information
drivebyer committed Nov 15, 2024
1 parent 8df44c3 commit d4f3e13
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion pkg/controllerutil/controller_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func RequeueAfter(ctx context.Context, duration time.Duration, msg string, keysA
if msg == "" {
msg = "requeue-after"
}
log.FromContext(ctx).Info(msg, keysAndValues...)
log.FromContext(ctx).V(1).Info(msg, keysAndValues...)
return reconcile.Result{
Requeue: true,
RequeueAfter: duration,
Expand Down
26 changes: 13 additions & 13 deletions pkg/k8sutils/cluster-scaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func ReshardRedisCluster(ctx context.Context, client kubernetes.Interface, cr *r

cmd = append(cmd, "--cluster-yes")

log.FromContext(ctx).Info("Redis cluster reshard command is", "Command", cmd)
log.FromContext(ctx).V(1).Info("Redis cluster reshard command is", "Command", cmd)

if slot == "0" {
log.FromContext(ctx).Info("Skipped the execution of", "Cmd", cmd)
log.FromContext(ctx).V(1).Info("Skipped the execution of", "Cmd", cmd)
return
}
executeCommand(ctx, client, cr, cmd, cr.ObjectMeta.Name+"-leader-0")
Expand Down Expand Up @@ -101,7 +101,7 @@ func getRedisClusterSlots(ctx context.Context, redisClient *redis.Client, nodeID
}
}

log.FromContext(ctx).Info("Total cluster slots to be transferred from", "node", nodeID, "is", totalSlots)
log.FromContext(ctx).V(1).Info("Total cluster slots to be transferred from", "node", nodeID, "is", totalSlots)
return strconv.Itoa(totalSlots)
}

Expand All @@ -128,7 +128,7 @@ func getRedisNodeID(ctx context.Context, client kubernetes.Interface, cr *redisv
log.FromContext(ctx).Error(err, "Redis command failed with this error")
return ""
}
log.FromContext(ctx).Info("Redis node ID ", "is", output)
log.FromContext(ctx).V(1).Info("Redis node ID ", "is", output)
return output
}

Expand Down Expand Up @@ -161,7 +161,7 @@ func RebalanceRedisClusterEmptyMasters(ctx context.Context, client kubernetes.In

cmd = append(cmd, getRedisTLSArgs(cr.Spec.TLS, cr.ObjectMeta.Name+"-leader-0")...)

log.FromContext(ctx).Info("Redis cluster rebalance command is", "Command", cmd)
log.FromContext(ctx).V(1).Info("Redis cluster rebalance command is", "Command", cmd)
executeCommand(ctx, client, cr, cmd, cr.ObjectMeta.Name+"-leader-1")
}

Expand All @@ -179,7 +179,7 @@ func CheckIfEmptyMasters(ctx context.Context, client kubernetes.Interface, cr *r
podSlots := getRedisClusterSlots(ctx, redisClient, podNodeID)

if podSlots == "0" || podSlots == "" {
log.FromContext(ctx).Info("Found Empty Redis Leader Node", "pod", pod)
log.FromContext(ctx).V(1).Info("Found Empty Redis Leader Node", "pod", pod)
RebalanceRedisClusterEmptyMasters(ctx, client, cr)
break
}
Expand Down Expand Up @@ -213,7 +213,7 @@ func RebalanceRedisCluster(ctx context.Context, client kubernetes.Interface, cr

cmd = append(cmd, getRedisTLSArgs(cr.Spec.TLS, cr.ObjectMeta.Name+"-leader-0")...)

log.FromContext(ctx).Info("Redis cluster rebalance command is", "Command", cmd)
log.FromContext(ctx).V(1).Info("Redis cluster rebalance command is", "Command", cmd)
executeCommand(ctx, client, cr, cmd, cr.ObjectMeta.Name+"-leader-1")
}

Expand Down Expand Up @@ -252,7 +252,7 @@ func AddRedisNodeToCluster(ctx context.Context, client kubernetes.Interface, cr

cmd = append(cmd, getRedisTLSArgs(cr.Spec.TLS, cr.ObjectMeta.Name+"-leader-0")...)

log.FromContext(ctx).Info("Redis cluster add-node command is", "Command", cmd)
log.FromContext(ctx).V(1).Info("Redis cluster add-node command is", "Command", cmd)
executeCommand(ctx, client, cr, cmd, cr.ObjectMeta.Name+"-leader-0")
}

Expand All @@ -269,7 +269,7 @@ func getAttachedFollowerNodeIDs(ctx context.Context, redisClient *redis.Client,
stringSlice := strings.Split(slave, " ")
slaveIDs = append(slaveIDs, stringSlice[0])
}
log.FromContext(ctx).Info("Slaves Nodes attached to", "node", masterNodeID, "are", slaveIDs)
log.FromContext(ctx).V(1).Info("Slaves Nodes attached to", "node", masterNodeID, "are", slaveIDs)
return slaveIDs
}

Expand Down Expand Up @@ -313,7 +313,7 @@ func RemoveRedisFollowerNodesFromCluster(ctx context.Context, client kubernetes.

for _, followerNodeID := range followerNodeIDs {
cmd = append(cmd, followerNodeID)
log.FromContext(ctx).Info("Redis cluster follower remove command is", "Command", cmd)
log.FromContext(ctx).V(1).Info("Redis cluster follower remove command is", "Command", cmd)
executeCommand(ctx, client, cr, cmd, cr.ObjectMeta.Name+"-leader-0")
cmd = cmd[:len(cmd)-1]
}
Expand Down Expand Up @@ -357,9 +357,9 @@ func RemoveRedisNodeFromCluster(ctx context.Context, client kubernetes.Interface

cmd = append(cmd, getRedisTLSArgs(cr.Spec.TLS, cr.ObjectMeta.Name+"-leader-0")...)

log.FromContext(ctx).Info("Redis cluster leader remove command is", "Command", cmd)
log.FromContext(ctx).V(1).Info("Redis cluster leader remove command is", "Command", cmd)
if getRedisClusterSlots(ctx, redisClient, removePodNodeID) != "0" {
log.FromContext(ctx).Info("Skipping execution remove leader not empty", "cmd", cmd)
log.FromContext(ctx).V(1).Info("Skipping execution remove leader not empty", "cmd", cmd)
}
executeCommand(ctx, client, cr, cmd, cr.ObjectMeta.Name+"-leader-0")
}
Expand Down Expand Up @@ -419,6 +419,6 @@ func ClusterFailover(ctx context.Context, client kubernetes.Interface, cr *redis

cmd = append(cmd, getRedisTLSArgs(cr.Spec.TLS, slavePodName)...)

log.FromContext(ctx).Info("Redis cluster failover command is", "Command", cmd)
log.FromContext(ctx).V(1).Info("Redis cluster failover command is", "Command", cmd)
executeCommand(ctx, client, cr, cmd, slavePodName)
}
2 changes: 1 addition & 1 deletion pkg/k8sutils/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type patchStringValue struct {
}

func (s *PodService) PatchPodLabels(ctx context.Context, namespace, podName string, labels map[string]string) error {
log.FromContext(ctx).Info("Patch pod labels", "namespace", namespace, "podName", podName, "labels", labels)
log.FromContext(ctx).V(1).Info("Patch pod labels", "namespace", namespace, "podName", podName, "labels", labels)

var payloads []interface{}
for labelKey, labelValue := range labels {
Expand Down
16 changes: 8 additions & 8 deletions pkg/k8sutils/poddisruption.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func ReconcileRedisPodDisruptionBudget(ctx context.Context, cr *redisv1beta2.Red
if err == nil {
return deletePodDisruptionBudget(ctx, cr.Namespace, pdbName, cl)
} else if err != nil && errors.IsNotFound(err) {
log.FromContext(ctx).Info("Reconciliation Successful, no PodDisruptionBudget Found.")
log.FromContext(ctx).V(1).Info("Reconciliation Successful, no PodDisruptionBudget Found.")
// Its ok if its not found, as we're deleting anyway
return nil
}
Expand All @@ -52,7 +52,7 @@ func ReconcileSentinelPodDisruptionBudget(ctx context.Context, cr *redisv1beta2.
if err == nil {
return deletePodDisruptionBudget(ctx, cr.Namespace, pdbName, cl)
} else if err != nil && errors.IsNotFound(err) {
log.FromContext(ctx).Info("Reconciliation Successful, no PodDisruptionBudget Found.")
log.FromContext(ctx).V(1).Info("Reconciliation Successful, no PodDisruptionBudget Found.")
// Its ok if its not found, as we're deleting anyway
return nil
}
Expand Down Expand Up @@ -151,7 +151,7 @@ func patchPodDisruptionBudget(ctx context.Context, storedPdb *policyv1.PodDisrup
return err
}
if !patchResult.IsEmpty() {
log.FromContext(ctx).Info("Changes in PodDisruptionBudget Detected, Updating...",
log.FromContext(ctx).V(1).Info("Changes in PodDisruptionBudget Detected, Updating...",
"patch", string(patchResult.Patch),
"Current", string(patchResult.Current),
"Original", string(patchResult.Original),
Expand All @@ -178,7 +178,7 @@ func createPodDisruptionBudget(ctx context.Context, namespace string, pdb *polic
log.FromContext(ctx).Error(err, "Redis PodDisruptionBudget creation failed")
return err
}
log.FromContext(ctx).Info("Redis PodDisruptionBudget creation was successful")
log.FromContext(ctx).V(1).Info("Redis PodDisruptionBudget creation was successful")
return nil
}

Expand All @@ -189,7 +189,7 @@ func updatePodDisruptionBudget(ctx context.Context, namespace string, pdb *polic
log.FromContext(ctx).Error(err, "Redis PodDisruptionBudget update failed")
return err
}
log.FromContext(ctx).Info("Redis PodDisruptionBudget update was successful", "PDB.Spec", pdb.Spec)
log.FromContext(ctx).V(1).Info("Redis PodDisruptionBudget update was successful", "PDB.Spec", pdb.Spec)
return nil
}

Expand All @@ -200,7 +200,7 @@ func deletePodDisruptionBudget(ctx context.Context, namespace string, pdbName st
log.FromContext(ctx).Error(err, "Redis PodDisruption deletion failed")
return err
}
log.FromContext(ctx).Info("Redis PodDisruption delete was successful")
log.FromContext(ctx).V(1).Info("Redis PodDisruption delete was successful")
return nil
}

Expand All @@ -211,9 +211,9 @@ func GetPodDisruptionBudget(ctx context.Context, namespace string, pdb string, c
}
pdbInfo, err := cl.PolicyV1().PodDisruptionBudgets(namespace).Get(context.TODO(), pdb, getOpts)
if err != nil {
log.FromContext(ctx).Info("Redis PodDisruptionBudget get action failed")
log.FromContext(ctx).V(1).Info("Redis PodDisruptionBudget get action failed")
return nil, err
}
log.FromContext(ctx).Info("Redis PodDisruptionBudget get action was successful")
log.FromContext(ctx).V(1).Info("Redis PodDisruptionBudget get action was successful")
return pdbInfo, err
}
2 changes: 1 addition & 1 deletion pkg/k8sutils/redis-sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func getRedisReplicationMasterIP(ctx context.Context, client kubernetes.Interfac
log.FromContext(ctx).Error(err, "Failed to Execute Get Request", "replication name", replicationName, "namespace", replicationNamespace)
return ""
} else {
log.FromContext(ctx).Info("Successfully Execute the Get Request", "replication name", replicationName, "namespace", replicationNamespace)
log.FromContext(ctx).V(1).Info("Successfully Execute the Get Request", "replication name", replicationName, "namespace", replicationNamespace)
}

// Marshal CustomObject to JSON
Expand Down
Loading

0 comments on commit d4f3e13

Please sign in to comment.