pkg

package
v0.0.0-...-f36a784 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LogsSince time.Duration
	Timeout   time.Duration
	SkipTLS   bool

	CLI = &cobra.Command{
		Use: "oc adm must-gather --image=<this-image> -- /usr/bin/gather",
		Long: `OADP Must-gather

TODO`,
		Args: cobra.NoArgs,
		Example: `  # TODO
  oc adm must-gather --image=<this-image>

  # TODO
  oc adm must-gather --image=<this-image> -- /usr/bin/gather --essential-only --logs-since <time>

  # TODO
  oc adm must-gather --image=<this-image> -- /usr/bin/gather --timeout <time>

  # TODO
  oc adm must-gather --image=<this-image> -- /usr/bin/gather --skip-tls --timeout <time>

  # TODO metrics dump`,
		SilenceErrors: true,
		SilenceUsage:  true,
		RunE: func(_ *cobra.Command, _ []string) error {

			clusterConfig := config.GetConfigOrDie()

			clusterConfig.QPS = 999999
			clusterConfig.Burst = 999999

			clusterClient, err := client.New(clusterConfig, client.Options{})
			if err != nil {
				fmt.Printf("Exiting OADP must-gather, an error happened while creating Go client: %v\n", err)
				return err
			}

			openshiftconfigv1.AddToScheme(clusterClient.Scheme())
			operatorsv1alpha1.AddToScheme(clusterClient.Scheme())
			storagev1.AddToScheme(clusterClient.Scheme())
			corev1.AddToScheme(clusterClient.Scheme())

			oadpv1alpha1.AddToScheme(clusterClient.Scheme())
			velerov1.AddToScheme(clusterClient.Scheme())
			velerov2alpha1.AddToScheme(clusterClient.Scheme())

			clusterVersion, err := gather.ClusterVersion(clusterClient)
			if err != nil {
				fmt.Printf("Exiting OADP must-gather, an error happened while gathering ClusterVersion: %v\n", err)
				return err
			}

			clusterID := string(clusterVersion.Spec.ClusterID[:8])

			path := fmt.Sprintf("must-gather/clusters/%s/", clusterID)

			folders := []string{
				"cluster-scoped-resources/storage.k8s.io/storageclasses",
				"cluster-scoped-resources/config.openshift.io",
				"cluster-scoped-resources/apiextensions.k8s.io/customresourcedefinitions",
			}

			for _, folder := range folders {
				err = os.MkdirAll(path+folder, 0777)
				if err != nil {
					fmt.Printf("Exiting OADP must-gather, an error happened while creating folder structure: %v\n", err)
					return err
				}
			}

			infrastructure, err := gather.Infrastructure(clusterClient)
			if err != nil {
				fmt.Println(err)
			}

			nodeList, err := gather.ALLNodes(clusterClient)
			if err != nil {
				fmt.Println(err)
			}

			clusterServiceVersionList, err := gather.AllClusterServiceVersions(clusterClient)
			if err != nil {
				fmt.Println(err)
			}

			dataProtectionApplicationList, err := gather.AllDataProtectionApplications(clusterClient)
			if err != nil {
				fmt.Println(err)
			}

			backupStorageLocationList, err := gather.AllBackupStorageLocations(clusterClient)
			if err != nil {
				fmt.Println(err)
			}

			volumeSnapshotLocationList, err := gather.AllVolumeSnapshotLocations(clusterClient)
			if err != nil {
				fmt.Println(err)
			}

			storageClassList, err := gather.AllStorageClasses(clusterClient)
			if err != nil {
				fmt.Println(err)
			}

			templates.ReplaceMustGatherVersion("dev-Oct-21-2024")
			templates.ReplaceClusterInformationSection(path, clusterID, clusterVersion, infrastructure, nodeList)
			templates.ReplaceOADPOperatorInstallationSection(path, clusterServiceVersionList)
			templates.ReplaceDataProtectionApplicationsSection(path, dataProtectionApplicationList)
			templates.ReplaceBackupStorageLocationsSection(path, backupStorageLocationList)
			templates.ReplaceVolumeSnapshotLocationsSection(path, volumeSnapshotLocationList)
			templates.ReplaceAvailableStorageClassesSection(path, storageClassList)
			templates.ReplaceCustomResourceDefinitionsSection(path, clusterConfig)

			err = templates.Write(path)
			if err != nil {
				fmt.Printf("Error occurred: %v\n", err)
				return err
			}
			return nil
		},
	}
)

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL