Skip to content

Commit

Permalink
[WIP] Fix issue when generating support bundle in Airgap environment
Browse files Browse the repository at this point in the history
Currently eks-anywhere cannot generate support bundle in Airgap environment
because eks-a needs to read bundle manifest from remote URL.

This PR fixed the issue by allowing user to specify path of local
bundle manifest file so that eks-a does not need to read it from
remote URL.
  • Loading branch information
Shizhao Liu committed Aug 29, 2024
1 parent a083f41 commit e89fc2c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cmd/eksctl-anywhere/cmd/supportbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/spf13/cobra"

"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/dependencies"
"github.com/aws/eks-anywhere/pkg/diagnostics"
"github.com/aws/eks-anywhere/pkg/kubeconfig"
Expand All @@ -22,6 +23,7 @@ type createSupportBundleOptions struct {
bundleConfig string
hardwareFileName string
tinkerbellBootstrapIP string
bundleManifest string
}

var csbo = &createSupportBundleOptions{}
Expand All @@ -36,7 +38,7 @@ var supportbundleCmd = &cobra.Command{
if err := csbo.validate(cmd.Context()); err != nil {
return err
}
if err := csbo.createBundle(cmd.Context(), csbo.since, csbo.sinceTime, csbo.bundleConfig); err != nil {
if err := csbo.createBundle(cmd.Context(), csbo.since, csbo.sinceTime, csbo.bundleConfig, csbo.bundleManifest); err != nil {

Check warning on line 41 in cmd/eksctl-anywhere/cmd/supportbundle.go

View check run for this annotation

Codecov / codecov/patch

cmd/eksctl-anywhere/cmd/supportbundle.go#L41

Added line #L41 was not covered by tests
return fmt.Errorf("failed to create support bundle: %v", err)
}
return nil
Expand All @@ -50,6 +52,7 @@ func init() {
supportbundleCmd.Flags().StringVarP(&csbo.bundleConfig, "bundle-config", "", "", "Bundle Config file to use when generating support bundle")
supportbundleCmd.Flags().StringVarP(&csbo.fileName, "filename", "f", "", "Filename that contains EKS-A cluster configuration")
supportbundleCmd.Flags().StringVarP(&csbo.wConfig, "w-config", "w", "", "Kubeconfig file to use when creating support bundle for a workload cluster")
supportbundleCmd.Flags().StringVarP(&csbo.bundleManifest, "bundle-manifest", "", "", "Bundle manifest to use when generating support bundle (required for generating support bundle in airgap environment)")
err := supportbundleCmd.MarkFlagRequired("filename")
if err != nil {
log.Fatalf("Error marking flag as required: %v", err)
Expand All @@ -70,8 +73,12 @@ func (csbo *createSupportBundleOptions) validate(ctx context.Context) error {
return nil
}

func (csbo *createSupportBundleOptions) createBundle(ctx context.Context, since, sinceTime, bundleConfig string) error {
clusterSpec, err := readAndValidateClusterSpec(csbo.fileName, version.Get())
func (csbo *createSupportBundleOptions) createBundle(ctx context.Context, since, sinceTime, bundleConfig string, bundleManifest string) error {
var opts []cluster.FileSpecBuilderOpt
if bundleManifest != "" {
opts = append(opts, cluster.WithOverrideBundlesManifest(bundleManifest))

Check warning on line 79 in cmd/eksctl-anywhere/cmd/supportbundle.go

View check run for this annotation

Codecov / codecov/patch

cmd/eksctl-anywhere/cmd/supportbundle.go#L76-L79

Added lines #L76 - L79 were not covered by tests
}
clusterSpec, err := readAndValidateClusterSpec(csbo.fileName, version.Get(), opts...)

Check warning on line 81 in cmd/eksctl-anywhere/cmd/supportbundle.go

View check run for this annotation

Codecov / codecov/patch

cmd/eksctl-anywhere/cmd/supportbundle.go#L81

Added line #L81 was not covered by tests
if err != nil {
return fmt.Errorf("unable to get cluster config from file: %v", err)
}
Expand Down

0 comments on commit e89fc2c

Please sign in to comment.