Skip to content

Commit c27a286

Browse files
authored
Autosupport YAML enhancements
1 parent ae6ee3b commit c27a286

File tree

14 files changed

+309
-88
lines changed

14 files changed

+309
-88
lines changed

cli/cmd/install.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ var (
9797
silent bool
9898
useIPv6 bool
9999
silenceAutosupport bool
100+
excludeAutosupport bool
100101
nodePrep []string
101102
skipK8sVersionCheck bool
102103
windows bool
@@ -197,6 +198,8 @@ func init() {
197198
installCmd.Flags().BoolVar(&useIPv6, "use-ipv6", false, "Use IPv6 for Trident's communication.")
198199
installCmd.Flags().BoolVar(&silenceAutosupport, "silence-autosupport", tridentconfig.BuildType != "stable",
199200
"Don't send autosupport bundles to NetApp automatically.")
201+
installCmd.Flags().BoolVar(&excludeAutosupport, "exclude-autosupport", false,
202+
"Don't install or run the autosupport container.")
200203
installCmd.Flags().StringSliceVar(&nodePrep, "node-prep", []string{}, "Comma separated list of protocols to prepare nodes for. Currently only iSCSI is supported.")
201204
installCmd.Flags().BoolVar(&enableForceDetach, "enable-force-detach", false,
202205
"Enable the force detach feature.")
@@ -264,6 +267,9 @@ func init() {
264267
if err := installCmd.Flags().MarkHidden("autosupport-hostname"); err != nil {
265268
_, _ = fmt.Fprintln(os.Stderr, err)
266269
}
270+
if err := installCmd.Flags().MarkHidden("exclude-autosupport"); err != nil {
271+
_, _ = fmt.Fprintln(os.Stderr, err)
272+
}
267273
if err := installCmd.Flags().MarkHidden("fs-group-policy"); err != nil {
268274
_, _ = fmt.Fprintln(os.Stderr, err)
269275
}
@@ -673,6 +679,7 @@ func prepareYAMLFiles() error {
673679
ControllingCRDetails: nil,
674680
UseIPv6: useIPv6,
675681
SilenceAutosupport: silenceAutosupport,
682+
ExcludeAutosupport: excludeAutosupport,
676683
Version: client.ServerVersion(),
677684
HTTPRequestTimeout: httpRequestTimeout.String(),
678685
ServiceAccountName: getControllerRBACResourceName(),
@@ -996,6 +1003,13 @@ func installTrident() (returnError error) {
9961003
}).Info("ACP is now obsolete; All workflows are now enabled by default.")
9971004
}
9981005

1006+
// excludeAutosupport completely removes the autosupport container from the deployment.
1007+
if excludeAutosupport {
1008+
Log().WithFields(LogFields{
1009+
"excludeAutosupport": excludeAutosupport,
1010+
}).Warn("Autosupport bundles cannot be generated.")
1011+
}
1012+
9991013
// Create the deployment
10001014
if useYAML && fileExists(deploymentPath) {
10011015
returnError = validateTridentDeployment()
@@ -1027,6 +1041,7 @@ func installTrident() (returnError error) {
10271041
ControllingCRDetails: nil,
10281042
UseIPv6: useIPv6,
10291043
SilenceAutosupport: silenceAutosupport,
1044+
ExcludeAutosupport: excludeAutosupport,
10301045
Version: client.ServerVersion(),
10311046
HTTPRequestTimeout: httpRequestTimeout.String(),
10321047
ServiceAccountName: getControllerRBACResourceName(),

cli/cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2025 NetApp, Inc. All Rights Reserved.
22

33
package cmd
44

@@ -125,7 +125,7 @@ func discoverOperatingMode(_ *cobra.Command) error {
125125

126126
switch OperatingMode {
127127
case ModeDirect:
128-
fmt.Printf("Operating mode = %s, Server = %s, Autosuport server = %s\n",
128+
fmt.Printf("Operating mode = %s, Server = %s, Autosupport server = %s\n",
129129
OperatingMode, Server, AutosupportCollector)
130130
case ModeTunnel:
131131
fmt.Printf("Operating mode = %s, Trident pod = %s, Namespace = %s, CLI = %s\n",

cli/cmd/send.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2025 NetApp, Inc. All Rights Reserved.
22

33
package cmd
44

cli/cmd/send_autosupport.go

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
// Copyright 2020 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2025 NetApp, Inc. All Rights Reserved.
22

33
package cmd
44

55
import (
6+
"bytes"
7+
"encoding/json"
68
"fmt"
79
"net/http"
810
"time"
911

1012
"github.com/spf13/cobra"
13+
k8s "k8s.io/api/core/v1"
1114

1215
"github.com/netapp/trident/cli/api"
16+
"github.com/netapp/trident/config"
1317
)
1418

1519
const (
@@ -45,6 +49,15 @@ var sendAutosupportCmd = &cobra.Command{
4549
}
4650

4751
if OperatingMode == ModeTunnel {
52+
// Do not attempt to send a support bundle if the ASUP container does not exist.
53+
isAutosupportPresent, err := isAutosupportContainerPresent(TridentPodNamespace, TridentCSILabel)
54+
if err != nil {
55+
return err
56+
} else if !isAutosupportPresent {
57+
cmd.Println("Unable to send autosupport bundle; no autosupport container found.")
58+
return nil
59+
}
60+
4861
command := []string{"send", "autosupport"}
4962
args = append(args, "--accept-agreement")
5063

@@ -83,3 +96,39 @@ func triggerAutosupport(since string) error {
8396

8497
return nil
8598
}
99+
100+
func isAutosupportContainerPresent(namespace, appLabel string) (bool, error) {
101+
// Get 'trident' pod info
102+
cmd := execKubernetesCLIRaw(
103+
"get", "pod",
104+
"-n", namespace,
105+
"-l", appLabel,
106+
"-o=json",
107+
"--field-selector=status.phase=Running")
108+
var outbuff bytes.Buffer
109+
cmd.Stdout = &outbuff
110+
err := cmd.Run()
111+
if err != nil {
112+
return false, err
113+
}
114+
115+
var tridentPodList k8s.PodList
116+
if err = json.Unmarshal(outbuff.Bytes(), &tridentPodList); err != nil {
117+
return false, fmt.Errorf("could not unmarshal Trident pod list; %v", err)
118+
}
119+
120+
if len(tridentPodList.Items) != 1 {
121+
return false, fmt.Errorf("could not find a Trident pod in the %s namespace. "+
122+
"You may need to use the -n option to specify the correct namespace", namespace)
123+
}
124+
tridentPod := tridentPodList.Items[0]
125+
126+
// Check for the autosupport container.
127+
for _, c := range tridentPod.Spec.Containers {
128+
if c.Name == config.DefaultAutosupportName {
129+
return true, nil
130+
}
131+
}
132+
133+
return false, nil
134+
}

cli/k8s_client/types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2025 NetApp, Inc. All Rights Reserved.
22

33
package k8sclient
44

@@ -158,6 +158,7 @@ type DeploymentYAMLArguments struct {
158158
Debug bool `json:"debug"`
159159
UseIPv6 bool `json:"useIPv6"`
160160
SilenceAutosupport bool `json:"silenceAutosupport"`
161+
ExcludeAutosupport bool `json:"excludeAutosupport"`
161162
Version *versionutils.Version `json:"version"`
162163
DisableAuditLog bool `json:"disableAuditLog"`
163164
HTTPRequestTimeout string `json:"httpRequestTimeout"`

0 commit comments

Comments
 (0)