Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into hl_sm_source
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulguptajss committed Nov 4, 2024
2 parents 5cb1b2d + 01dcf9d commit 6d70cb3
Show file tree
Hide file tree
Showing 113 changed files with 2,113 additions and 1,107 deletions.
1 change: 1 addition & 0 deletions .clabot
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"cordelster",
"george-strother",
"7840vz",
"embusalacchi",
"$$$ Bots $$$",
"dependabot",
"dependabot[bot]",
Expand Down
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/release-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ git push origin release/$RELEASE
| DOCKER_PUBLISH | false |
| RUN_TEST | true |
| OVERWRITE_DOCKER_LATEST_TAG | false |
| RUN_TRIVY_SCAN | true |

- [ ] Create a release branch for the harvest-metrics repo like so:
```bash
Expand Down Expand Up @@ -76,6 +77,7 @@ bin/harvest generate metrics --poller POLLERNAME
| DOCKER_PUBLISH | true |
| RUN_TEST | true |
| OVERWRITE_DOCKER_LATEST_TAG | true |
| RUN_TRIVY_SCAN | true |

- [ ] [Draft a new release](https://github.com/NetApp/harvest/releases). Use `v$RELEASE` for the tag and pick the release/$RELEASE branch.
- [ ] Type `$RELEASE` in the `Release title` text input
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: read environment file
run: cat .harvest.env >> "$GITHUB_ENV"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: wagoid/commitlint-github-action@v6
2 changes: 2 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: read environment file
run: cat .harvest.env >> "$GITHUB_ENV"
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
name: "Lint PR"
on:
pull_request_target:
pull_request:
types:
- opened
- edited
- synchronize
- reopened

permissions:
pull-requests: read

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# https://github.com/woodruffw/zizmor
name: GitHub Actions Security Analysis with Zizmor

on:
push:
branches: ["main"]
pull_request:
branches: ["*"]

jobs:
zizmor:
name: Zizmor latest via Cargo
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Get zizmor
run: cargo install zizmor
- name: Run zizmor
run: zizmor --format sarif . > results.sarif
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
# Path to SARIF file relative to the root of the repository
sarif_file: results.sarif
# Optional category for the results
# Used to differentiate multiple results for one commit
category: zizmor
6 changes: 3 additions & 3 deletions SUPPORT.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Harvest Support and Getting Help

Harvest is an open-source project developed and published by NetApp to collect performance, capacity and hardware metrics from ONTAP clusters. These metrics can then be delivered to a range of databases and displayed in Grafana dashboards. Harvest is not an officially supported NetApp product. NetApp maintains and updates Harvest with bug fixes, security updates, and feature development. For assistance refer [Getting Help](#getting-help)
Harvest is an open-source project developed and published by NetApp to collect performance, capacity and hardware metrics from ONTAP clusters. These metrics can then be delivered to a range of databases and displayed in Grafana dashboards. Harvest is not an officially supported NetApp product. NetApp maintains and updates Harvest with bug fixes, security updates, and feature development. For assistance, refer to [Getting Help](#getting-help)

This document describes Harvest's release and support lifecycle as well as places you can get help.

## Harvest's Release and Support Lifecycle

Harvest's current release schedule is quarterly in January, April, July, and October, but it may change at our discretion.
Harvest's current release schedule is quarterly in February, May, August, and November, but it may change at our discretion.

Each release of Harvest supports the most recently released version of ONTAP. We try our best to also support earlier versions of ONTAP. When that's not possible, breaking changes will be outlined in the changelog.

Expand All @@ -16,7 +16,7 @@ Harvest is constantly being improved with new features and bug fixes. Customers

For example, when `YY.MM` (ex: 21.04) is released, we intend to support it until `YY+1.MM` (ex: 22.04) is released. At the same time, `YY-1.MM` (ex: 20.04) and associated minor releases (ex: 20.04.1) move to limited or no support.

If you are running a version of Harvest that’s more than 12 months old, you must upgrade to a newer version to receive any support then available from NetApp. We always recommend running the latest version.
If you are running a version of Harvest that’s more than 12 months old, you must upgrade to a newer version to receive support from NetApp. We always recommend running the latest version.

We use GitHub for tracking bugs and feature requests.

Expand Down
23 changes: 13 additions & 10 deletions cmd/collectors/commonutils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package collectors

import (
"fmt"
"github.com/netapp/harvest/v2/cmd/tools/rest"
"github.com/netapp/harvest/v2/pkg/errs"
"github.com/netapp/harvest/v2/pkg/matrix"
Expand Down Expand Up @@ -60,7 +61,7 @@ func IsEmbedShelf(model string, moduleType string) bool {
return combinations[embedShelf{model, moduleType}]
}

func InvokeRestCallWithTestFile(client *rest.Client, href string, logger *slog.Logger, testFilePath string) ([]gjson.Result, error) {
func InvokeRestCallWithTestFile(client *rest.Client, href string, testFilePath string) ([]gjson.Result, error) {
if testFilePath != "" {
b, err := os.ReadFile(testFilePath)
if err != nil {
Expand All @@ -69,19 +70,13 @@ func InvokeRestCallWithTestFile(client *rest.Client, href string, logger *slog.L
testData := gjson.Result{Type: gjson.JSON, Raw: string(b)}
return testData.Get("records").Array(), nil
}
return InvokeRestCall(client, href, logger)
return InvokeRestCall(client, href)
}

func InvokeRestCall(client *rest.Client, href string, logger *slog.Logger) ([]gjson.Result, error) {
func InvokeRestCall(client *rest.Client, href string) ([]gjson.Result, error) {
result, err := rest.FetchAll(client, href)
if err != nil {
logger.Error(
"Failed to fetch data",
slogx.Err(err),
slog.String("href", href),
slog.Int("hrefLength", len(href)),
)
return []gjson.Result{}, err
return []gjson.Result{}, fmt.Errorf("failed to fetchAll href=%s, hrefLength=%d err=%w", TruncateURL(href), len(href), err)
}

if len(result) == 0 {
Expand All @@ -91,6 +86,14 @@ func InvokeRestCall(client *rest.Client, href string, logger *slog.Logger) ([]gj
return result, nil
}

func TruncateURL(href string) string {
indexOfQuestionMark := strings.Index(href, "?")
if indexOfQuestionMark == -1 {
return href
}
return href[:indexOfQuestionMark] + "..."
}

func GetClusterTime(client *rest.Client, returnTimeOut *int, logger *slog.Logger) (time.Time, error) {
var (
err error
Expand Down
4 changes: 2 additions & 2 deletions cmd/collectors/ems/ems.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func (e *Ems) InitMatrix() error {
// overwrite from abstract collector
mat.Object = e.Object
// Add system (cluster) name
mat.SetGlobalLabel("cluster", e.Client.Cluster().Name)
mat.SetGlobalLabel("cluster_uuid", e.Client.Cluster().UUID)
mat.SetGlobalLabel("cluster", e.Client.Remote().Name)
mat.SetGlobalLabel("cluster_uuid", e.Client.Remote().UUID)

if e.Params.HasChildS("labels") {
for _, l := range e.Params.GetChildS("labels").GetChildren() {
Expand Down
6 changes: 4 additions & 2 deletions cmd/collectors/keyperf/keyperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ func (kp *KeyPerf) Init(a *collector.AbstractCollector) error {
return err
}

kp.Remote = kp.Client.Remote()

if kp.Prop.TemplatePath, err = kp.LoadTemplate(); err != nil {
return err
}
Expand Down Expand Up @@ -105,7 +107,7 @@ func (kp *KeyPerf) InitMatrix() error {
// overwrite from abstract collector
mat.Object = kp.Prop.Object
// Add system (cluster) name
mat.SetGlobalLabel("cluster", kp.Client.Cluster().Name)
mat.SetGlobalLabel("cluster", kp.Remote.Name)
if kp.Params.HasChildS("labels") {
for _, l := range kp.Params.GetChildS("labels").GetChildren() {
mat.SetGlobalLabel(l.GetNameS(), l.GetContentS())
Expand Down Expand Up @@ -140,7 +142,7 @@ func (kp *KeyPerf) loadParamInt(name string, defaultValue int) int {
}

func (kp *KeyPerf) buildCounters() {
staticCounterDef, err := loadStaticCounterDefinitions(kp.Prop.Object, "cmd/collectors/keyperf/static_counter_definitions.yaml", kp.Logger)
staticCounterDef, err := loadStaticCounterDefinitions(kp.Prop.Object, "conf/keyperf/static_counter_definitions.yaml", kp.Logger)
if err != nil {
// It's acceptable to continue even if there are errors, as the remaining counters will still be processed.
// Any counters that require counter metadata will be skipped.
Expand Down
2 changes: 1 addition & 1 deletion cmd/collectors/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func collectChassisFRU(client *rest.Client, logger *slog.Logger) (map[string]int
if !cn.Exists() {
logger.Warn(
"fru has no connected nodes",
slog.String("cluster", client.Cluster().Name),
slog.String("cluster", client.Remote().Name),
slog.String("fru", r.Get("fru_name").String()),
)
continue
Expand Down
2 changes: 1 addition & 1 deletion cmd/collectors/rest/plugins/aggregate/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,5 @@ func (a *Aggregate) getObjectStoreData() ([]gjson.Result, error) {
Filter([]string{`tier_name=!" "|""`}).
Build()

return collectors.InvokeRestCall(a.client, href, a.SLogger)
return collectors.InvokeRestCall(a.client, href)
}
4 changes: 2 additions & 2 deletions cmd/collectors/rest/plugins/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (c *Certificate) GetAdminVserver() (string, error) {
Filter([]string{"type=admin"}).
Build()

if result, err = collectors.InvokeRestCall(c.client, href, c.SLogger); err != nil {
if result, err = collectors.InvokeRestCall(c.client, href); err != nil {
return "", err
}

Expand All @@ -227,7 +227,7 @@ func (c *Certificate) GetSecuritySsl(adminSvm string) (string, error) {
Filter([]string{"vserver=" + adminSvm}).
Build()

if result, err = collectors.InvokeRestCall(c.client, href, c.SLogger); err != nil {
if result, err = collectors.InvokeRestCall(c.client, href); err != nil {
return "", err
}

Expand Down
Loading

0 comments on commit 6d70cb3

Please sign in to comment.