diff --git a/cmd/collectors/rest/plugins/volume/volume.go b/cmd/collectors/rest/plugins/volume/volume.go index e13792870..6b1832cdf 100644 --- a/cmd/collectors/rest/plugins/volume/volume.go +++ b/cmd/collectors/rest/plugins/volume/volume.go @@ -17,6 +17,7 @@ import ( "github.com/netapp/harvest/v2/pkg/util" "github.com/tidwall/gjson" "log/slog" + "os" "strconv" "time" ) @@ -24,6 +25,8 @@ import ( const HoursInMonth = 24 * 30 const ARWSupportedVersion = "9.10.0" +var enableVolumeLogging bool + type Volume struct { *plugin.AbstractPlugin currentVal int @@ -91,6 +94,7 @@ func (v *Volume) Init() error { if err != nil { return fmt.Errorf("unable to get version %w", err) } + enableVolumeLogging = os.Getenv("ENABLE_VOLUME_LOGGING") != "" return nil } @@ -117,11 +121,11 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util volumeMap, err := v.getVolumeInfo() if err != nil { v.SLogger.Error("Failed to collect volume info data", slogx.Err(err)) + } else { + // update volume instance labels + v.updateVolumeLabels(data, volumeMap) } - // update volume instance labels - v.updateVolumeLabels(data, volumeMap) - // parse anti_ransomware_start_time, antiRansomwareState for all volumes and export at cluster level v.handleARWProtection(data) @@ -131,6 +135,11 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]volumeInfo) { var err error + + if enableVolumeLogging { + v.SLogger.Info("Size of volumeMap", slog.Int("size", len(volumeMap)), slog.Any("volumeMap", volumeMap)) + } + cloneSplitEstimateMetric := data.GetMetric("clone_split_estimate") if cloneSplitEstimateMetric == nil { if cloneSplitEstimateMetric, err = data.NewMetricFloat64("clone_split_estimate"); err != nil { @@ -144,6 +153,9 @@ func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]vo } if volume.GetLabel("style") == "flexgroup_constituent" { + if enableVolumeLogging { + v.SLogger.Warn("Setting exportable for flexgroup constituent", slog.String("volume", volume.GetLabel("volume")), slog.Bool("exportable", v.includeConstituents)) + } volume.SetExportable(v.includeConstituents) } @@ -151,6 +163,9 @@ func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]vo if vInfo, ok := volumeMap[volume.GetLabel("volume")+volume.GetLabel("svm")]; ok { if vInfo.isObjectStoreVolume { + if enableVolumeLogging { + v.SLogger.Warn("Setting exportable for object store volume", slog.String("volume", volume.GetLabel("volume")), slog.Bool("exportable", false)) + } volume.SetExportable(false) continue } @@ -168,6 +183,9 @@ func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]vo } } else { // The public API does not include node root and temp volumes, while the private CLI does include them. Harvest will exclude them the same as the public API by not exporting them. + if enableVolumeLogging { + v.SLogger.Warn("Setting exportable for excluded volume", slog.String("volume", volume.GetLabel("volume")), slog.Bool("exportable", false)) + } volume.SetExportable(false) } }