Skip to content

Commit

Permalink
feat: pollers should allow customers to opt out of REST upgrade (#1744)
Browse files Browse the repository at this point in the history
Fixes: #1732
  • Loading branch information
cgrinds committed Feb 21, 2023
1 parent 26f1846 commit d8d0a5c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cmd/poller/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ func (p *Poller) negotiateAPI(c conf.Collector, clusterVersion string, checkZAPI
// For ONTAP versions 9.12.1+ use REST unless the HARVEST_NO_COLLECTOR_UPGRADE environment variable is set.
// When the environment variable is set, honor that request unless the cluster no longer speaks ZAPI.
noUpgrade = os.Getenv(NoUpgrade)
if noUpgrade == "" {
if noUpgrade == "" && !p.params.PreferZAPI {
logger.Info().Str("collector", c.Name).Str("v", clusterVersion).Msg("Use REST")
upgradeCollector := strings.ReplaceAll(c.Name, "Zapi", "Rest")
return conf.Collector{
Expand All @@ -1195,7 +1195,9 @@ func (p *Poller) negotiateAPI(c conf.Collector, clusterVersion string, checkZAPI
logger.Info().
Str("collector", c.Name).
Str("v", clusterVersion).
Msg("ZAPIs exist and no-upgrade ENVVAR set. Use ZAPIs")
Str(NoUpgrade, noUpgrade).
Bool("preferZAPI", p.params.PreferZAPI).
Msg("Use ZAPIs")
return c
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/poller/poller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestPublishUrl(t *testing.T) {
}

func TestCollectorUpgrade(t *testing.T) {
poller := Poller{}
poller := Poller{params: &conf.Poller{}}

type test struct {
name string
Expand Down
1 change: 1 addition & 0 deletions docs/configure-harvest-basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ All pollers are defined in `harvest.yml`, the main configuration file of Harvest
| `log_max_bytes` | | Maximum size of the log file before it will be rotated | `5_242_880` (5 MB) |
| `log_max_files` | | Number of rotated log files to keep | `5` |
| `log` | optional, list of collector names | Matching collectors log their ZAPI request/response | |
| `prefer_zapi` | optional, bool | Use the ZAPI API if the cluster supports it, otherwise allow Harvest to choose REST or ZAPI, whichever is appropriate to the ONTAP version. See [rest-strategy](https://github.com/NetApp/harvest/blob/main/docs/architecture/rest-strategy.md) for details. | |

## Defaults

Expand Down
1 change: 1 addition & 0 deletions pkg/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ type Poller struct {
TLSMinVersion string `yaml:"tls_min_version,omitempty"`
UseInsecureTLS *bool `yaml:"use_insecure_tls,omitempty"`
Username string `yaml:"username,omitempty"`
PreferZAPI bool `yaml:"prefer_zapi,omitempty"`
promIndex int
Name string
}
Expand Down

0 comments on commit d8d0a5c

Please sign in to comment.