Skip to content

Commit

Permalink
fix: fix exporter listen address
Browse files Browse the repository at this point in the history
  • Loading branch information
chideat committed Oct 11, 2024
1 parent 196dd16 commit cf72c74
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
3 changes: 1 addition & 2 deletions internal/builder/clusterbuilder/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,10 @@ func buildContainers(cluster *redisv1alpha1.DistributedRedisCluster, user *user.
}

func redisExporterContainer(cluster *redisv1alpha1.DistributedRedisCluster, user *user.User) corev1.Container {
const DefaultPasswordFile = "/tmp/passwords.json"
cmd := append([]string{
"/redis_exporter",
"--web.listen-address",
strconv.Itoa(PrometheusExporterPortNumber),
fmt.Sprintf(":%d", PrometheusExporterPortNumber),
"--web.telemetry-path",
PrometheusExporterTelemetryPath}, cluster.Spec.Monitor.Args...)
container := corev1.Container{
Expand Down
19 changes: 17 additions & 2 deletions internal/builder/clusterbuilder/statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package clusterbuilder

import (
"fmt"
"testing"

redisv1alpha1 "github.com/alauda/redis-operator/api/cluster/v1alpha1"
Expand Down Expand Up @@ -63,7 +64,13 @@ func TestRedisExporterContainer(t *testing.T) {
},
},
expected: corev1.Container{
Name: ExporterContainerName,
Name: ExporterContainerName,
Command: []string{
"/redis_exporter",
"--web.listen-address",
fmt.Sprintf(":%d", PrometheusExporterPortNumber),
"--web.telemetry-path",
PrometheusExporterTelemetryPath},
Image: "redis-exporter:latest",
ImagePullPolicy: corev1.PullAlways,
Ports: []corev1.ContainerPort{
Expand Down Expand Up @@ -129,7 +136,13 @@ func TestRedisExporterContainer(t *testing.T) {
},
},
expected: corev1.Container{
Name: ExporterContainerName,
Name: ExporterContainerName,
Command: []string{
"/redis_exporter",
"--web.listen-address",
fmt.Sprintf(":%d", PrometheusExporterPortNumber),
"--web.telemetry-path",
PrometheusExporterTelemetryPath},
Image: "redis-exporter:latest",
ImagePullPolicy: corev1.PullAlways,
Ports: []corev1.ContainerPort{
Expand Down Expand Up @@ -177,6 +190,8 @@ func TestRedisExporterContainer(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
container := redisExporterContainer(tt.cluster, tt.user)
assert.Equal(t, tt.expected.Name, container.Name)
assert.Equal(t, tt.expected.Command, container.Command)
assert.Equal(t, tt.expected.Args, container.Args)
assert.Equal(t, tt.expected.Image, container.Image)
assert.Equal(t, tt.expected.ImagePullPolicy, container.ImagePullPolicy)
assert.Equal(t, tt.expected.Ports, container.Ports)
Expand Down

0 comments on commit cf72c74

Please sign in to comment.