Fix always fetch Zabbix version before issuing new requests (#2133)
Previously we were only fetching the version when the version was `0`. This generally worked, but posed some problems when customers were updating their Zabbix version, specifically when upgrading from a version < `7.2.x` to `7.2.x` or above. Before `7.2.x`, an `auth` parameter was still supported when issuing a zabbix request, this was deprecated in `6.4.x` and later removed in `7.2.x`. When a user was on a version < `7.2.x` all the outgoing requests would add this `auth` parameter. When upgrading to `7.2.x` this was a problem, because the version was not `0`, hence, not requiring getting the version again, but also because we were still building the request considering an older version and adding the `auth` parameter, when this was no longer supported. This PR removes the check for `version == 0`, though this now means that every request that goes out will check the version before hand, I think this will give us a more accurate representation of the version that needs to be used. fixes https://github.com/orgs/grafana/projects/457/views/40?pane=issue&itemId=3683181283&issue=grafana%7Coss-big-tent-squad%7C135
This commit is contained in:
committed by
GitHub
parent
3da36ec2bb
commit
e073382983
@@ -83,15 +83,23 @@ func TestNonCachedQuery(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestItemTagCache(t *testing.T) {
|
||||
zabbixClient, _ := MockZabbixClient(
|
||||
BasicDatasourceInfo,
|
||||
`{"result":[{"itemid":"1","name":"test1"}]}`,
|
||||
200,
|
||||
)
|
||||
callCount := 0
|
||||
zabbixClient := NewZabbixClientWithHandler(t, func(payload ApiRequestPayload) string {
|
||||
switch payload.Method {
|
||||
case "apiinfo.version":
|
||||
return `{"result":"6.4.0"}`
|
||||
case "item.get":
|
||||
callCount++
|
||||
if callCount == 1 {
|
||||
return `{"result":[{"itemid":"1","name":"test1"}]}`
|
||||
}
|
||||
return `{"result":[{"itemid":"2","name":"test2"}]}`
|
||||
default:
|
||||
return `{"result":null}`
|
||||
}
|
||||
})
|
||||
// tag filtering is on >= 54 version
|
||||
zabbixClient.version = 64
|
||||
zabbixClient.settings.AuthType = settings.AuthTypeToken
|
||||
zabbixClient.api.SetAuth("test")
|
||||
items, err := zabbixClient.GetAllItems(
|
||||
context.Background(),
|
||||
nil,
|
||||
|
||||
Reference in New Issue
Block a user