From d841aad17d2212ea4021ff32bd8026aac0d384e2 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 30 Jun 2026 11:20:07 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20golangci-lint=20=EB=B6=80=EC=B1=84=20?= =?UTF-8?q?=ED=95=B4=EC=86=8C=20+=20chart=20icon=20branding=20=EC=A0=95?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main CI 의 기존(pre-existing) lint/test red 를 정리 (코드품질·일관성). - cluster_reintegrate.go: rangeint ×4 (for i:=0;i Signed-off-by: phil --- charts/valkey-operator/Chart.yaml | 2 +- internal/controller/cluster_reintegrate.go | 8 ++++---- internal/controller/valkeyrestore_controller_test.go | 3 +-- internal/resources/servicemonitor_test.go | 3 ++- internal/resources/statefulset.go | 11 ++++++----- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/charts/valkey-operator/Chart.yaml b/charts/valkey-operator/Chart.yaml index 58f9139..4ad907f 100644 --- a/charts/valkey-operator/Chart.yaml +++ b/charts/valkey-operator/Chart.yaml @@ -26,7 +26,7 @@ maintainers: email: support@keiailab.com url: https://keiailab.com -icon: https://raw.githubusercontent.com/KeiaiLab/valkey-operator/main/docs/branding/symbol.png +icon: https://valkey.io/img/valkey-horizontal.svg annotations: artifacthub.io/license: MIT diff --git a/internal/controller/cluster_reintegrate.go b/internal/controller/cluster_reintegrate.go index e7cd2bb..bd807ff 100644 --- a/internal/controller/cluster_reintegrate.go +++ b/internal/controller/cluster_reintegrate.go @@ -83,7 +83,7 @@ func detectReintegration(shards, replicasPerShard int, observed map[int]observed total := shards * (1 + replicasPerShard) var primaries, replicas []reintegrationAction - for ord := 0; ord < total; ord++ { + for ord := range total { m, seen := observed[ord] isReplica := ord >= shards if !isReplica { @@ -130,7 +130,7 @@ func buildObservedMembers( } // nodeID → ordinal (master 매핑 역참조용). idToOrdinal := make(map[string]int, total) - for ord := 0; ord < total; ord++ { + for ord := range total { if addr := addrByOrdinal[ord]; addr != "" { if nv := byAddr[addr]; nv != nil { idToOrdinal[nv.ID] = ord @@ -140,7 +140,7 @@ func buildObservedMembers( observed := make(map[int]observedMember, total) nodeIDByOrdinal := make(map[int]string, total) - for ord := 0; ord < total; ord++ { + for ord := range total { addr := addrByOrdinal[ord] nv := byAddr[addr] if addr == "" || nv == nil { @@ -397,7 +397,7 @@ func (r *ValkeyClusterReconciler) forgetStaleNodes( func (r *ValkeyClusterReconciler) firstMemberAddr( addrByOrdinal, nodeIDByOrdinal map[int]string, shards int, ) string { - for ord := 0; ord < shards; ord++ { + for ord := range shards { if nodeIDByOrdinal[ord] != "" { return addrByOrdinal[ord] } diff --git a/internal/controller/valkeyrestore_controller_test.go b/internal/controller/valkeyrestore_controller_test.go index c507284..accae4e 100644 --- a/internal/controller/valkeyrestore_controller_test.go +++ b/internal/controller/valkeyrestore_controller_test.go @@ -20,7 +20,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -625,7 +624,7 @@ func standaloneCluster(name, ns string, shards, repsPerShard int32) *cachev1alph ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: ns}, Spec: cachev1alpha1.ValkeyClusterSpec{ Shards: shards, - ReplicasPerShard: ptr.To(repsPerShard), + ReplicasPerShard: new(repsPerShard), }, } } diff --git a/internal/resources/servicemonitor_test.go b/internal/resources/servicemonitor_test.go index 87eba51..bf88c5b 100644 --- a/internal/resources/servicemonitor_test.go +++ b/internal/resources/servicemonitor_test.go @@ -6,10 +6,11 @@ Licensed under the MIT License. See the LICENSE file for details. package resources import ( - "k8s.io/utils/ptr" "strings" "testing" + "k8s.io/utils/ptr" + cachev1alpha1 "github.com/keiailab/valkey-operator/api/v1alpha1" ) diff --git a/internal/resources/statefulset.go b/internal/resources/statefulset.go index ac4da7a..e950313 100644 --- a/internal/resources/statefulset.go +++ b/internal/resources/statefulset.go @@ -217,7 +217,8 @@ func BuildStatefulSet(p STSParams) *appsv1.StatefulSet { // announce-bus-port=tls-cluster 시 tls-port+10000(16380) / 아니면 port+10000(16379) // — 실제 bus listen 포트와 일치해야 gossip 성립 (clusterAnnounceCommand 참조). if p.ClusterMode { - containers[0].Command, containers[0].Args = clusterAnnounceCommand(containers[0].Args, p.TLSSecretName != "") + containers[0].Command = clusterAnnounceCommand(containers[0].Args, p.TLSSecretName != "") + containers[0].Args = nil } podSpec := corev1.PodSpec{ @@ -359,15 +360,15 @@ func buildRestrictedContainerSecurityContext() *corev1.SecurityContext { // clusterAnnounceCommand — cluster mode 컨테이너 command 를 셸 래핑하여 // cluster-announce-ip 를 $POD_IP(downward API)로 확장한다. 입력은 기존 -// valkey-server args (config path + --loadmodule 등). 반환은 (command, args) -// 쌍: command 는 `sh -c '...'`, args 는 nil (셸 명령에 모두 인라인). +// valkey-server args (config path + --loadmodule 등). 반환은 command (`sh -c '...'`) +// — 셸 명령에 모두 인라인되므로 호출 측은 컨테이너 Args 를 nil 로 설정한다. // // cluster-announce-ip 는 valkey-server 시작 시점에 literal 이어야 하므로 // ConfigMap directive 로 표현할 수 없다 (pod IP 는 ConfigMap 렌더 시점 미확정). // CLI flag 가 valkey.conf 보다 우선하므로 ConfigMap 의 cluster-* directive 는 // 유효하게 유지된다. `exec` 로 PID 1 을 valkey-server 로 교체해 signal/graceful // shutdown 의미를 보존한다. -func clusterAnnounceCommand(serverArgs []string, tlsEnabled bool) ([]string, []string) { +func clusterAnnounceCommand(serverArgs []string, tlsEnabled bool) []string { // cluster-bus 는 tls-cluster 시 tls-port(6380)+10000, 아니면 port(6379)+10000 에 // listen 한다. announce-bus-port 가 실제 listen 포트와 어긋나면 peer 가 닫힌 포트로 // gossip 을 시도해 모든 노드가 fail?/disconnected → cluster_state:fail, slots_ok:0. @@ -382,7 +383,7 @@ func clusterAnnounceCommand(serverArgs []string, tlsEnabled bool) ([]string, []s "--cluster-announce-port", fmt.Sprintf("%d", PortClient), "--cluster-announce-bus-port", fmt.Sprintf("%d", busPort), ) - return []string{"sh", "-c", strings.Join(parts, " ")}, nil + return []string{"sh", "-c", strings.Join(parts, " ")} } // PortIntOrString — helper for Probe/Service ports.