Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rg2-change-log
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulguptajss committed Aug 22, 2023
2 parents 86d7411 + ecaaa0b commit 6cac8fd
Show file tree
Hide file tree
Showing 149 changed files with 8,838 additions and 3,387 deletions.
20 changes: 16 additions & 4 deletions .github/ISSUE_TEMPLATE/release-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,23 @@ git checkout origin/HEAD
git switch --create release/$RELEASE
git push origin release/$RELEASE
```
- [ ] If any changes are made in the [harvest autosupport](https://github.com/NetApp/harvest-private/tree/main/harvest-asup) repository, please update the harvest-metrics repository `main` branch with the latest `asup_linux_amd64` binary. This binary can be generated using Jenkins with the following parameters:

| Field | Value |
|-----------------------------|-----------------|
| VERSION | 23.02.0 |
| RELEASE | 1 |
| BRANCH | release/23.02.0 |
| ASUP_MAKE_TARGET | production |
| DOCKER_PUBLISH | false |
| RUN_TEST | true |
| OVERWRITE_DOCKER_LATEST_TAG | false |

- [ ] Create a release branch for the harvest-metrics repo like so:
```bash
RELEASE=23.02.0
git clone https://github.com/NetApp/harvest-metrics.git
cd harvest-metrics
git checkout origin/HEAD
git switch --create release/$RELEASE
git push origin release/$RELEASE
Expand All @@ -32,7 +45,7 @@ git push origin release/$RELEASE
- [ ] Create changelog
- [ ] [Draft a new release](https://github.com/NetApp/harvest/releases). Use `v$RELEASE` for the tag and pick the release/$RELEASE branch. Click the `Generate release notes` button and double check, at the bottom of the release notes, that the commits are across the correct range. For example: `https://github.com/NetApp/harvest/compare/v22.11.1...v23.02.0`
- [ ] Copy/paste the generated release notes and save them in a file `pbpaste > ghrn_$RELEASE.md`
- [ ] Hand-write list of release highlights `vi highlights_$RELEASE.md` ([example content](https://github.com/NetApp/harvest/blob/main/CHANGELOG.md#23020--2023-02-21))
- [ ] Generate draft release highlights by executing `go run pkg/changelog/main.go new`. This will create a file named `releaseHighlights_$RELEASE.md`. Edit that file to add content ([example content](https://github.com/NetApp/harvest/blob/main/CHANGELOG.md#23020--2023-02-21))
- [ ] Ensure all notable features are highlighted
- [ ] Ensure any breaking changes are highlighted
- [ ] Ensure any deprecations are highlighted
Expand All @@ -42,11 +55,10 @@ go run pkg/changelog/main.go --title $RELEASE --highlights releaseHighlights_$RE
```
- [ ] Open a PR against the release branch with the generated release notes for review
- [ ] PR approval
- [ ] Update metrics repo if needed

#### Update Metrics Documentation
```bash
bin/harvest generate metrics
bin/harvest generate metrics --poller POLLERNAME
```
- [ ] Make sure docs look good and open a PR for review with `docs/ontap-metrics.md` changes

Expand Down Expand Up @@ -79,4 +91,4 @@ bin/harvest generate metrics
```bash
mike deploy --push --update-aliases $SHORT latest
```
- [ ] Merge Release Branch into Main
- [ ] Merge release branch into main. The PR should use the `chore: ` prefix
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build, Test, Lint License

env:
GO_VERSION: "1.20.7"
GO_VERSION: "1.21.0"

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.20.7'
go-version: '1.21.0'
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
18 changes: 18 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
linters:
disable-all: true
enable:
- asasalint
- bidichk
- bodyclose
- contextcheck
- dogsled
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- gocheckcompilerdirectives
- gosec
- gosimple
- govet
- ineffassign
- makezero
- mirror
- nilerr
- nolintlint
- nonamedreturns
- nosprintfhostport
- reassign
- revive
- staticcheck
- stylecheck
- tenv
- thelper
- testableexamples
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- zerologlint

issues:
max-issues-per-linter: 0
Expand All @@ -38,3 +53,6 @@ linters-settings:
thelper:
test:
begin: false
gocritic:
disabled-tags:
- style
260 changes: 260 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
###############################################################################
SHELL := /bin/bash
GCC_EXISTS := $(shell which gcc)
REQUIRED_GO_VERSION := 1.20
REQUIRED_GO_VERSION := 1.21
ifneq (, $(shell which go))
FOUND_GO_VERSION := $(shell go version | cut -d" " -f3 | cut -d"o" -f 2)
CORRECT_GO_VERSION := $(shell expr `go version | cut -d" " -f3 | cut -d"o" -f 2` \>= ${REQUIRED_GO_VERSION})
Expand Down Expand Up @@ -73,7 +73,9 @@ endif

clean: header ## Cleanup the project binary (bin) folders
@echo "Cleaning harvest files"
@if test -d bin; then ls -d ./bin/* | grep -v "asup" | xargs rm -f; fi
@if [ -d bin ]; then \
ls -d ./bin/* | grep -v "asup" | xargs rm -f; \
fi

test: ## run tests
@echo "Running tests"
Expand Down Expand Up @@ -127,10 +129,6 @@ harvest: deps
@echo "Building harvest"
@GOOS=$(GOOS) GOARCH=$(GOARCH) $(FLAGS) go build -trimpath -o bin -ldflags=$(LD_FLAGS) ./cmd/harvest ./cmd/poller

@# Build the daemonize for the pollers
@echo "Building daemonize"
@cd cmd/tools/daemonize; gcc daemonize.c -o ../../../bin/daemonize

@cp service/contrib/grafana bin; chmod +x bin/grafana

###############################################################################
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ and GitHub [discussions](https://github.com/NetApp/harvest/discussions). Come jo

:closed_book: https://netapp.github.io/harvest/

# Videos

- [Why Harvest](https://youtu.be/04-66_9egJc)
- [Harvest Quick Start: Docker Compose](https://youtu.be/4cbDKzwjGHI)

---

<p align="center">
Expand Down
12 changes: 6 additions & 6 deletions cmd/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ func (a *Admin) APISD(w http.ResponseWriter, r *http.Request) {
return
}
}
if r.Method == "PUT" {
if r.Method == http.MethodPut {
a.apiPublish(w, r)
} else if r.Method == "GET" {
w.WriteHeader(200)
} else if r.Method == http.MethodGet {
w.WriteHeader(http.StatusOK)
_, _ = w.Write(a.makeTargets())
} else {
w.WriteHeader(400)
w.WriteHeader(http.StatusBadRequest)
}
}

func (a *Admin) setupLogger() {
zerolog.SetGlobalLevel(zerolog.InfoLevel)
zerolog.ErrorStackMarshaler = logging.MarshalStack
zerolog.ErrorStackMarshaler = logging.MarshalStack //nolint:reassign

a.logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).
With().Caller().Timestamp().Logger()
Expand All @@ -128,7 +128,7 @@ func (a *Admin) apiPublish(w http.ResponseWriter, r *http.Request) {
err := decoder.Decode(&publish)
if err != nil {
a.logger.Err(err).Msg("Unable to parse publish json")
w.WriteHeader(400)
w.WriteHeader(http.StatusBadRequest)
return
}
a.pollerToPromAddr.Set(publish.Name, publish, a.expireAfter)
Expand Down
72 changes: 18 additions & 54 deletions cmd/collectors/commonutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ func testWithoutGroupType(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("group_type", "")
UpdateProtectedFields(instance)

if instance.GetLabel("protectedBy") == "" && instance.GetLabel("protectionSourceType") == "" {
// OK
} else {
if instance.GetLabel("protectedBy") != "" || instance.GetLabel("protectionSourceType") != "" {
t.Errorf("Labels protectedBy= %s, expected empty and protectionSourceType= %s, expected empty", instance.GetLabel("protectedBy"), instance.GetLabel("protectionSourceType"))
}
}
Expand All @@ -57,9 +55,7 @@ func testSvmdr(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("source_volume", "")
UpdateProtectedFields(instance)

if instance.GetLabel("protectedBy") == "storage_vm" && instance.GetLabel("protectionSourceType") == "storage_vm" {
// OK
} else {
if instance.GetLabel("protectedBy") != "storage_vm" || instance.GetLabel("protectionSourceType") != "storage_vm" {
t.Errorf("Labels protectedBy= %s, expected: storage_vm and protectionSourceType= %s, expected: storage_vm", instance.GetLabel("protectedBy"), instance.GetLabel("protectionSourceType"))
}
}
Expand All @@ -71,9 +67,7 @@ func testConstituentVolumeWithinSvmdr(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("destination_location", "test1")
UpdateProtectedFields(instance)

if instance.GetLabel("protectedBy") == "storage_vm" && instance.GetLabel("protectionSourceType") == "volume" {
// OK
} else {
if instance.GetLabel("protectedBy") != "storage_vm" || instance.GetLabel("protectionSourceType") != "volume" {
t.Errorf("Labels protectedBy= %s, expected: storage_vm and protectionSourceType= %s, expected: volume", instance.GetLabel("protectedBy"), instance.GetLabel("protectionSourceType"))
}
}
Expand All @@ -83,9 +77,7 @@ func testCg(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("destination_location", "test123:/cg/")
UpdateProtectedFields(instance)

if instance.GetLabel("protectedBy") == "cg" && instance.GetLabel("protectionSourceType") == "cg" {
// OK
} else {
if instance.GetLabel("protectedBy") != "cg" || instance.GetLabel("protectionSourceType") != "cg" {
t.Errorf("Labels protectedBy= %s, expected: cg and protectionSourceType= %s, expected: cg", instance.GetLabel("protectedBy"), instance.GetLabel("protectionSourceType"))
}
}
Expand All @@ -95,9 +87,7 @@ func testConstituentVolumeWithinCg(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("destination_location", "test123")
UpdateProtectedFields(instance)

if instance.GetLabel("protectedBy") == "cg" && instance.GetLabel("protectionSourceType") == "volume" {
// OK
} else {
if instance.GetLabel("protectedBy") != "cg" || instance.GetLabel("protectionSourceType") != "volume" {
t.Errorf("Labels protectedBy= %s, expected: cg and protectionSourceType= %s, expected: volume", instance.GetLabel("protectedBy"), instance.GetLabel("protectionSourceType"))
}
}
Expand All @@ -106,9 +96,7 @@ func testNegativeCase1(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("group_type", "infinitevol")
UpdateProtectedFields(instance)

if instance.GetLabel("protectedBy") == "volume" && instance.GetLabel("protectionSourceType") == "not_mapped" {
// OK
} else {
if instance.GetLabel("protectedBy") != "volume" || instance.GetLabel("protectionSourceType") != "not_mapped" {
t.Errorf("Labels protectedBy= %s, expected: volume and protectionSourceType= %s, expected: not_mapped", instance.GetLabel("protectedBy"), instance.GetLabel("protectionSourceType"))
}
}
Expand All @@ -120,9 +108,7 @@ func testNegativeCase2(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("destination_location", "test123:")
UpdateProtectedFields(instance)

if instance.GetLabel("protectedBy") == "volume" && instance.GetLabel("protectionSourceType") == "not_mapped" {
// OK
} else {
if instance.GetLabel("protectedBy") != "volume" || instance.GetLabel("protectionSourceType") != "not_mapped" {
t.Errorf("Labels protectedBy= %s, expected: volume and protectionSourceType= %s, expected: not_mapped", instance.GetLabel("protectedBy"), instance.GetLabel("protectionSourceType"))
}
}
Expand All @@ -131,9 +117,7 @@ func testGroupTypeNone(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("group_type", "none")
UpdateProtectedFields(instance)

if instance.GetLabel("protectedBy") == "volume" && instance.GetLabel("protectionSourceType") == "volume" {
// OK
} else {
if instance.GetLabel("protectedBy") != "volume" || instance.GetLabel("protectionSourceType") != "volume" {
t.Errorf("Labels protectedBy= %s, expected: volume and protectionSourceType= %s, expected: volume", instance.GetLabel("protectedBy"), instance.GetLabel("protectionSourceType"))
}
}
Expand All @@ -142,9 +126,7 @@ func testGroupTypeFlexgroup(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("group_type", "flexgroup")
UpdateProtectedFields(instance)

if instance.GetLabel("protectedBy") == "volume" && instance.GetLabel("protectionSourceType") == "volume" {
// OK
} else {
if instance.GetLabel("protectedBy") != "volume" || instance.GetLabel("protectionSourceType") != "volume" {
t.Errorf("Labels protectedBy= %s, expected: volume and protectionSourceType= %s, expected: volume", instance.GetLabel("protectedBy"), instance.GetLabel("protectionSourceType"))
}
}
Expand All @@ -155,9 +137,7 @@ func testStrictSyncMirror(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("policy_type", "strict_sync_mirror")
UpdateProtectedFields(instance)

if instance.GetLabel("derived_relationship_type") == "sync_mirror_strict" {
// OK
} else {
if instance.GetLabel("derived_relationship_type") != "sync_mirror_strict" {
t.Errorf("Labels derived_relationship_type= %s, expected: sync_mirror_strict", instance.GetLabel("derived_relationship_type"))
}
}
Expand All @@ -167,9 +147,7 @@ func testSyncMirror(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("policy_type", "sync_mirror")
UpdateProtectedFields(instance)

if instance.GetLabel("derived_relationship_type") == "sync_mirror" {
// OK
} else {
if instance.GetLabel("derived_relationship_type") != "sync_mirror" {
t.Errorf("Labels derived_relationship_type= %s, expected: sync_mirror", instance.GetLabel("derived_relationship_type"))
}
}
Expand All @@ -179,9 +157,7 @@ func testMirrorVault(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("policy_type", "mirror_vault")
UpdateProtectedFields(instance)

if instance.GetLabel("derived_relationship_type") == "mirror_vault" {
// OK
} else {
if instance.GetLabel("derived_relationship_type") != "mirror_vault" {
t.Errorf("Labels derived_relationship_type= %s, expected: mirror_vault", instance.GetLabel("derived_relationship_type"))
}
}
Expand All @@ -191,9 +167,7 @@ func testAutomatedFailover(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("policy_type", "automated_failover")
UpdateProtectedFields(instance)

if instance.GetLabel("derived_relationship_type") == "sync_mirror" {
// OK
} else {
if instance.GetLabel("derived_relationship_type") != "sync_mirror" {
t.Errorf("Labels derived_relationship_type= %s, expected: sync_mirror", instance.GetLabel("derived_relationship_type"))
}
}
Expand All @@ -203,9 +177,7 @@ func testOtherPolicyType(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("policy_type", "vault")
UpdateProtectedFields(instance)

if instance.GetLabel("derived_relationship_type") == "vault" {
// OK
} else {
if instance.GetLabel("derived_relationship_type") != "vault" {
t.Errorf("Labels derived_relationship_type= %s, expected: vault", instance.GetLabel("derived_relationship_type"))
}
}
Expand All @@ -215,9 +187,7 @@ func testWithNoPolicyType(t *testing.T, instance *matrix.Instance) {
instance.SetLabel("policy_type", "")
UpdateProtectedFields(instance)

if instance.GetLabel("derived_relationship_type") == "extended_data_protection" {
// OK
} else {
if instance.GetLabel("derived_relationship_type") != "extended_data_protection" {
t.Errorf("Labels derived_relationship_type= %s, expected: extended_data_protection", instance.GetLabel("derived_relationship_type"))
}
}
Expand All @@ -227,9 +197,7 @@ func testWithNoPolicyTypeNoRelationshipType(t *testing.T, instance *matrix.Insta
instance.SetLabel("policy_type", "")
UpdateProtectedFields(instance)

if instance.GetLabel("derived_relationship_type") == "" {
// OK
} else {
if instance.GetLabel("derived_relationship_type") != "" {
t.Errorf("Labels derived_relationship_type= %s, expected: \"\"(empty)", instance.GetLabel("derived_relationship_type"))
}
}
Expand All @@ -240,9 +208,7 @@ func testOlderTimestampThanDuration(t *testing.T) {
duration := 5 * time.Minute
isOlder := IsTimestampOlderThanDuration(time.Now(), timestamp, duration)

if isOlder {
// OK
} else {
if !isOlder {
t.Errorf("timestamp= %f is older than duration %s", timestamp, duration.String())
}
}
Expand All @@ -252,9 +218,7 @@ func testNewerTimestampThanDuration(t *testing.T) {
duration := 2 * time.Hour
isOlder := IsTimestampOlderThanDuration(time.Now(), timestamp, duration)

if !isOlder {
// OK
} else {
if isOlder {
t.Errorf("timestamp= %f is newer than duration %s", timestamp, duration.String())
}
}
Expand Down
Loading

0 comments on commit 6cac8fd

Please sign in to comment.