Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HostsDeleteByIds request due to documentation #11

Merged
merged 4 commits into from
Sep 28, 2022

Conversation

scytem
Copy link

@scytem scytem commented Sep 27, 2022

Hello! Due to official documentation, we don't need "hostids" key. Probably it's the root cause of this issue claranet/terraform-provider-zabbix#34

https://www.zabbix.com/documentation/6.0/en/manual/api/reference/host/delete#:~:text=%22params%22%3A,%5D%2C

@scytem scytem marked this pull request as ready for review September 27, 2022 15:04
Copy link
Member

@pdecat pdecat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @scytem, thanks for this PR!

This change indeed looks correct, and seems backward compatible with older versions of Zabbix server at least down to v2.2:

I'm unsure how we did not face this issue before 🤔

host.go Outdated Show resolved Hide resolved
Artem Kravchenko and others added 2 commits September 28, 2022 12:18
Copy link
Member

@pdecat pdecat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@pdecat pdecat merged commit 6f429ab into claranet:master Sep 28, 2022
@pdecat
Copy link
Member

pdecat commented Sep 28, 2022

Oh, turns out this change broke support for Zabbix versions older than v2.2, e.g.:

I'm unsure how we did not face this issue before

I should have expanded the code below before reviewing, there's fallback code to retry without hostid in case of an error with a -32500 code: https://github.com/claranet/go-zabbix-api/pull/11/files#diff-7717c52956f97079739dd32cd1d2c7a9ff80173a3895ac11d9e845d1b6c5ca41R151

With Zabbix 6.0, the error seems to have changed from -32500 to -32602.

@pdecat
Copy link
Member

pdecat commented Sep 28, 2022

We should probably favor newer Zabbix versions, and reverse the calls to first try without hostid, then fallback with hostid in case of error.

pdecat added a commit that referenced this pull request Sep 28, 2022
@pdecat pdecat mentioned this pull request Sep 28, 2022
pdecat added a commit that referenced this pull request Oct 3, 2022
@pdecat pdecat mentioned this pull request Oct 3, 2022
6 tasks
pdecat added a commit that referenced this pull request Oct 3, 2022
Revert "Fix HostsDeleteByIds request due to documentation (#11)"

This reverts commit 6f429ab.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants