-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into k0s-1-29
- Loading branch information
Showing
38 changed files
with
1,528 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ go.work.sum | |
.gomodcache | ||
/local-dev/ | ||
*.tmp | ||
.envrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io" | ||
"os" | ||
|
||
"github.com/urfave/cli/v2" | ||
|
||
"github.com/replicatedhq/embedded-cluster/pkg/defaults" | ||
"github.com/replicatedhq/embedded-cluster/pkg/helpers" | ||
"github.com/replicatedhq/embedded-cluster/pkg/spinner" | ||
) | ||
|
||
func supportBundleCommand() *cli.Command { | ||
return &cli.Command{ | ||
Name: "support-bundle", | ||
Usage: fmt.Sprintf("Generate a %s support bundle", defaults.BinaryName()), | ||
Before: func(c *cli.Context) error { | ||
if os.Getuid() != 0 { | ||
return fmt.Errorf("support-bundle command must be run as root") | ||
} | ||
return nil | ||
}, | ||
Action: func(c *cli.Context) error { | ||
provider := discoverBestProvider(c.Context) | ||
os.Setenv("TMPDIR", provider.EmbeddedClusterTmpSubDir()) | ||
|
||
supportBundle := provider.PathToEmbeddedClusterBinary("kubectl-support_bundle") | ||
if _, err := os.Stat(supportBundle); err != nil { | ||
return fmt.Errorf("unable to find support bundle binary") | ||
} | ||
|
||
kubeConfig := provider.PathToKubeConfig() | ||
hostSupportBundle := provider.PathToEmbeddedClusterSupportFile("host-support-bundle.yaml") | ||
|
||
spin := spinner.Start() | ||
spin.Infof("Collecting support bundle (this may take a while)") | ||
|
||
stdout := bytes.NewBuffer(nil) | ||
stderr := bytes.NewBuffer(nil) | ||
if err := helpers.RunCommandWithOptions( | ||
helpers.RunCommandOptions{ | ||
Writer: stdout, | ||
ErrWriter: stderr, | ||
LogOnSuccess: true, | ||
}, | ||
supportBundle, | ||
"--interactive=false", | ||
fmt.Sprintf("--kubeconfig=%s", kubeConfig), | ||
"--load-cluster-specs", | ||
hostSupportBundle, | ||
); err != nil { | ||
spin.Infof("Failed to collect support bundle") | ||
spin.CloseWithError() | ||
io.Copy(os.Stdout, stdout) | ||
io.Copy(os.Stderr, stderr) | ||
return ErrNothingElseToAdd | ||
} | ||
|
||
spin.Infof("Support bundle collected!") | ||
spin.Close() | ||
return nil | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package e2e | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/replicatedhq/embedded-cluster/e2e/cluster/docker" | ||
) | ||
|
||
func TestHostCollectSupportBundleInCluster(t *testing.T) { | ||
t.Parallel() | ||
|
||
RequireEnvVars(t, []string{"SHORT_SHA"}) | ||
|
||
tc := docker.NewCluster(&docker.ClusterInput{ | ||
T: t, | ||
Nodes: 1, | ||
Distro: "debian-bookworm", | ||
LicensePath: "license.yaml", | ||
ECBinaryPath: "../output/bin/embedded-cluster", | ||
}) | ||
defer tc.Cleanup() | ||
|
||
t.Logf("%s: installing embedded-cluster on node 0", time.Now().Format(time.RFC3339)) | ||
line := []string{"single-node-install.sh", "cli"} | ||
if stdout, stderr, err := tc.RunCommandOnNode(0, line); err != nil { | ||
t.Fatalf("fail to install embedded-cluster: %v: %s: %s", err, stdout, stderr) | ||
} | ||
|
||
line = []string{"collect-support-bundle-host-in-cluster.sh"} | ||
stdout, stderr, err := tc.RunCommandOnNode(0, line) | ||
if err != nil { | ||
t.Fatalf("fail to collect host support bundle: %v: %s: %s", err, stdout, stderr) | ||
} | ||
|
||
t.Logf("%s: test complete", time.Now().Format(time.RFC3339)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.