From d1cdba420a3bc2f717e989e946e13692051eac0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Fri, 26 Nov 2021 15:45:01 +0100 Subject: [PATCH 1/3] cephfs-mirror: try to mitigate peer import error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some users have reported issues while adding the token, this is not always reproducable so perhaps it's a typo when importing the token and adding trailing spaces. Closes: https://github.com/rook/rook/issues/9151 Signed-off-by: Sébastien Han --- pkg/daemon/ceph/client/filesystem_mirror.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/daemon/ceph/client/filesystem_mirror.go b/pkg/daemon/ceph/client/filesystem_mirror.go index dfe6151cc01f..4de6b6b5336a 100644 --- a/pkg/daemon/ceph/client/filesystem_mirror.go +++ b/pkg/daemon/ceph/client/filesystem_mirror.go @@ -170,8 +170,9 @@ func ImportFSMirrorBootstrapPeer(context *clusterd.Context, clusterInfo *Cluster logger.Infof("importing cephfs bootstrap peer token for filesystem %q", fsName) // Build command - args := []string{"fs", "snapshot", "mirror", "peer_bootstrap", "import", fsName, token} + args := []string{"fs", "snapshot", "mirror", "peer_bootstrap", "import", fsName, strings.TrimSpace(token)} cmd := NewCephCommand(context, clusterInfo, args) + cmd.JsonOutput = false // Run command output, err := cmd.Run() From 7f7a72d941a419329b194dc8018452684c6d7e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Fri, 26 Nov 2021 15:47:31 +0100 Subject: [PATCH 2/3] core: add the ability to execute ceph commands with a combined output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes Ceph uses a different standard output to return errors or merges standard error to standard out. So let's allow some commands to return both in the output. Signed-off-by: Sébastien Han --- pkg/daemon/ceph/client/command.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/daemon/ceph/client/command.go b/pkg/daemon/ceph/client/command.go index b8e2b74eb225..d94a8d0d09ed 100644 --- a/pkg/daemon/ceph/client/command.go +++ b/pkg/daemon/ceph/client/command.go @@ -96,16 +96,18 @@ type CephToolCommand struct { args []string timeout time.Duration JsonOutput bool + combinedOutput bool RemoteExecution bool } func newCephToolCommand(tool string, context *clusterd.Context, clusterInfo *ClusterInfo, args []string) *CephToolCommand { return &CephToolCommand{ - context: context, - tool: tool, - clusterInfo: clusterInfo, - args: args, - JsonOutput: true, + context: context, + tool: tool, + clusterInfo: clusterInfo, + args: args, + JsonOutput: true, + combinedOutput: false, } } @@ -173,7 +175,11 @@ func (c *CephToolCommand) run() ([]byte, error) { output, err = c.context.Executor.ExecuteCommandWithTimeout(c.timeout, command, args...) } } else if c.timeout == 0 { - output, err = c.context.Executor.ExecuteCommandWithOutput(command, args...) + if c.combinedOutput { + output, err = c.context.Executor.ExecuteCommandWithCombinedOutput(command, args...) + } else { + output, err = c.context.Executor.ExecuteCommandWithOutput(command, args...) + } } else { output, err = c.context.Executor.ExecuteCommandWithTimeout(c.timeout, command, args...) } From d8a8b05c1f78a2906ab9e59e6843ab5cfb473324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Fri, 26 Nov 2021 15:49:50 +0100 Subject: [PATCH 3/3] cephfs-mirror: use combined output to possibly catch peer import error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By adding a combined output to the executor we might be able to fetch more error messages. Signed-off-by: Sébastien Han --- pkg/daemon/ceph/client/filesystem_mirror.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/daemon/ceph/client/filesystem_mirror.go b/pkg/daemon/ceph/client/filesystem_mirror.go index 4de6b6b5336a..c1386c4c7216 100644 --- a/pkg/daemon/ceph/client/filesystem_mirror.go +++ b/pkg/daemon/ceph/client/filesystem_mirror.go @@ -173,6 +173,7 @@ func ImportFSMirrorBootstrapPeer(context *clusterd.Context, clusterInfo *Cluster args := []string{"fs", "snapshot", "mirror", "peer_bootstrap", "import", fsName, strings.TrimSpace(token)} cmd := NewCephCommand(context, clusterInfo, args) cmd.JsonOutput = false + cmd.combinedOutput = true // Run command output, err := cmd.Run()