Skip to content

Commit 8a1830c

Browse files
authored
Merge pull request #21530 from k8s-infra-cherrypick-robot/cherry-pick-21528-to-release-3.6
[release-3.6] Fix etcdctl endpoint command with option --cluster when auth is enabled
2 parents e841e10 + e0f7af4 commit 8a1830c

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

etcdctl/ctlv3/command/ep_command.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ func endpointsFromCluster(cmd *cobra.Command) []string {
251251
}
252252

253253
sec := secureCfgFromCmd(cmd)
254+
au := authCfgFromCmd(cmd)
254255
dt := dialTimeoutFromCmd(cmd)
255256
ka := keepAliveTimeFromCmd(cmd)
256257
kat := keepAliveTimeoutFromCmd(cmd)
@@ -267,6 +268,7 @@ func endpointsFromCluster(cmd *cobra.Command) []string {
267268
KeepAliveTime: ka,
268269
KeepAliveTimeout: kat,
269270
Secure: sec,
271+
Auth: au,
270272
}, lg)
271273
if err != nil {
272274
cobrautl.ExitWithError(cobrautl.ExitError, err)

tests/e2e/ctl_v3_auth_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"context"
1919
"fmt"
2020
"os"
21+
"strings"
2122
"testing"
2223

2324
"github.com/stretchr/testify/require"
@@ -315,6 +316,16 @@ func authTestEndpointHealth(cx ctlCtx) {
315316
require.NoErrorf(cx.t, lerr, "endpoint health should fail with permission denied error")
316317
}
317318
}(cx)
319+
320+
cmdArgs := append(cx.PrefixArgs(), "endpoint", "health", "--user=root:root", "--cluster")
321+
proc, err := e2e.SpawnCmd(cmdArgs, cx.envMap)
322+
require.NoError(cx.t, err)
323+
defer func() {
324+
require.NoError(cx.t, proc.Close())
325+
}()
326+
proc.Wait()
327+
response := strings.Join(proc.Lines(), "\n")
328+
require.Contains(cx.t, response, "is healthy: successfully")
318329
}
319330

320331
func certCNAndUsername(cx ctlCtx, noPassword bool) {

0 commit comments

Comments
 (0)