Skip to content

Trying to handle the changes that came with werk #16466. #734

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

Merged
merged 17 commits into from
Mar 13, 2025

Conversation

lgetwan
Copy link
Contributor

@lgetwan lgetwan commented Feb 21, 2025

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

The discovery module is not handling the changes that came with Werk #16466

What is the new behavior?

The discovery module works with all supported Checkmk versions up to to 2.4.0

@lgetwan lgetwan added the module:discovery This affects the discovery module label Feb 21, 2025
@lgetwan lgetwan self-assigned this Feb 21, 2025
@lgetwan lgetwan requested a review from Max-checkmk as a code owner February 21, 2025 08:00
@lgetwan lgetwan changed the title Trying top handle the changes that came with werk #16466. Trying to handle the changes that came with werk #16466. Feb 21, 2025
@lgetwan lgetwan marked this pull request as draft February 21, 2025 13:28
@lgetwan
Copy link
Contributor Author

lgetwan commented Feb 21, 2025

The "Wait for completion" mechanism changed with the 2.4.0.
We have to adapt the changes in the discovery module.

@lgetwan
Copy link
Contributor Author

lgetwan commented Feb 28, 2025

Ok, the integration tests are now also successful. And they are quite extensive for the discovery module.
Who can review the PR from a coding perspective, @Max-checkmk, @msekania (even though it was a complete rewrite, It still contains some lines of code from you. ;-)), @robin-checkmk?

@lgetwan lgetwan marked this pull request as ready for review February 28, 2025 10:07
@msekania
Copy link
Contributor

msekania commented Mar 3, 2025

@lgetwan,

I will review the code today, tomorrow at the latest.

Copy link
Contributor

@msekania msekania left a comment

Choose a reason for hiding this comment

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

@lgetwan,

First of all, I like very much the idea to split module in version dependent parts!
The logic of the code is clearer and easier to follow in this form!

I commented on discovery_240.py file mainly, for the moment, in order to clarify the logic change introduced by the "wait" concept.
Otherwise, the comments would be very similar to other version-parts of the code.

Comment on lines +235 to +239
if self.single_mode and result.http_code != 200:
result = self._wait_for_completion("current")
elif self.bulk_mode:
job_id = json.loads(result.content).get("id")
result = self._wait_for_completion("current", job_id=job_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

again, it might timeout here, but it does not mean that the process will not be finished successfully after some time without intervention from the user side.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true, and that was by intention (see my use-case "1." in the other comment).

Comment on lines 201 to 204
if now > deadline:
return generate_result(
msg="Timeout reached while waiting for %s discovery" % what
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand the idea of timeout and it might be appealing but I see couple of issues which should be clarified:

  • when it timeouts here it does not mean that process is still not running in background,
  • it does not return failed state and next call of rediscovery might fail.

If one still decides to go with timeout concept, then one should also make clear in documentation that in essence it might take up to twice the timeout before plugin returns timeout, but it also does not mean that the process will not be finished successfully after some time without intervention from the user side.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The use-cases I had in mind, were:

  1. I only want to trigger the discovery, and I don't mind if it finishes successfully. I might check later in the playbook
  2. I want to wait for the discovery to finish, and the play should only continue if the discovery was successful.
  3. A mix: 99% of my discoveries finish within 30s. I don't want to wait longer in my playbook. The 1% that fails (or succeeds in background), I will check manually, later or in another playbook. (~ Pareto principle. ;-))

After implementing the default "infinite", these should be possible, with "2." being the default, to make the change non-breaking.

Does that make sense to you? Are there other use-cases that you can think of?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does that make sense to you? Are there other use-cases that you can think of?

Yes! I think that's it!

I will check the changed implementation more closely today, with a quick glance something is wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

@lgetwan,

v2.2 and v2.1 have not yet received the updates (wait_time: -1 treatment), right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, 2.2 and 2.1 were missing, but I had to leave into Feierabend. ;-)
Fixed that this morning.

@msekania
Copy link
Contributor

@lgetwan,

It's fine from my point of view!

@lgetwan
Copy link
Contributor Author

lgetwan commented Mar 13, 2025

Thanks a lot, @msekania!

@robin-checkmk,
Looks like we can merge this PR. :-)

@robin-checkmk robin-checkmk merged commit 71ebf30 into build/checkmk-24-support Mar 13, 2025
23 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2025
@robin-checkmk robin-checkmk deleted the fix/discovery_werk16466 branch March 13, 2025 14:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
module:discovery This affects the discovery module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants