Skip to content

Allowing custom timeouts for Manage.up(), Test.ping() and on a generic LocalCall - #195

Merged
meaksh merged 8 commits into
masterfrom
manage-runner-fix
Mar 24, 2017
Merged

meaksh merged 8 commits into
masterfrom
manage-runner-fix

Conversation

@meaksh

@meaksh meaksh commented Mar 15, 2017 •

Copy link
Copy Markdown
Member

This PR allows to set custom timeout and timeout_job_timeout salt attributes when calling Manage.up(), Test.ping() or a generic LocalCall.

This is very useful when some minions are unreachable and we want to get a presence report in a short and fixed amount of time.

Salt upstream PR: saltstack/salt#40018

@meaksh meaksh changed the title [WIP] Adds support for calling 'manage.up' runner with timeouts parameters Allowing custom timeouts for Manage.up(), Test.ping() and on a generic LocalCall Mar 16, 2017
@meaksh

meaksh commented Mar 17, 2017

Copy link
Copy Markdown
Member Author

@lucidd @mbologna - This is ready to get some feedback. Please, take a look if you have some time.

@mbologna

Copy link
Copy Markdown
Member

Looks good to me, only thing missing are junit tests (which can be trivial).

@moio

moio commented Mar 20, 2017

Copy link
Copy Markdown
Member

Tests added, this also LGTM. Assigning to @lucidd to get his ultimate approval.

arg.ifPresent(arg -> payload.put("arg", arg));
kwarg.ifPresent(kwarg -> payload.put("kwarg", kwarg));
metadata.ifPresent(m -> payload.put("metadata", m));
timeout.ifPresent(timeout -> payload.put("timeout", timeout));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is timeout and gather_job_timeout supported on every local_* client?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well, these two parameters are now handled inside salt.client.LocalClient class of Salt, which is the class that handles all local_* clients.

The local, local_async clients will work as expected, but looking now at local_batch in the Salt side, it seems that kwargs won't be propagated to the Batch object so I'll expect that timeouts parameters won't work on this case. I'll fix this on Salt ASAP. Thanks! 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would say that the Batch case should be fixed in Salt, as ATM it is a Salt bug. That should not block this PR anyway, as the library is doing the right thing FMPOV.

Is that OK with you @lucidd?

@lucidd lucidd Mar 22, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if it will be fixed in salt then its ok. Only in case it will not or cant be fixed in salt we should make sure in the library that you cant end up configuring something that will never work the way you expect.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@lucidd - This PR fixes local_batch client: saltstack/salt#40300

return PING;
}

public static LocalCall<Boolean> ping(Optional<Integer> timeout,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i don't think we should make ping a special case here if those parameters are supported on every function. We should rather do something along the lines of withMetadata.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the record, we discussed this with @meaksh and he will adjust this PR as per your suggestion. Thanks

}

public static RunnerCall<List<String>> up(Optional<Integer> timeout,
Optional<Integer> gatherJobTimeout) {

@lucidd lucidd Mar 21, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is there a semantical difference between the parameters to up and the now generally introduced ones?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No, their semantics are the same - but in this case we cannot introduce this in a general way for all RunnerCalls, simply because those two parameters have been added "ad hoc" for manage.up and manage.status.

@lucidd: is it OK to add them as Optionals or would method overloading make more sense here to be backwards compatible?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using Optional in most module functions is more because of lazyness. Overloading is always preferred but gets quickly out of hand in case of many optional parameters. We don't promise backwards compatibility before 1.0 but if its easy to provide in this case we should go for it.

@meaksh

meaksh commented Mar 22, 2017 •

Copy link
Copy Markdown
Member Author

@lucidd - Thank you for your feedback in this PR. I've added a few more commits to address the discussion here:

  • Added withTimeouts and withoutTimeouts in a similar way as withMetadata.
  • Fixed withMetadata to preserve timeouts values if they exists.
  • Got rid of Test.ping(timeout, gatherJobTimeout).
  • Fixed unit test.

Please, take a look when you have time.

Still pending to fix the Batch issue. I would expect a PR to upstream Salt in the following days since I pointed this out in a Trello card.

UPDATE:
Batch issue PR: saltstack/salt#40300

@lucidd lucidd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@meaksh
meaksh merged commit 855f3af into master Mar 24, 2017
@meaksh
meaksh deleted the manage-runner-fix branch March 24, 2017 16:50
@renner renner added this to the Version 0.11.0 milestone Mar 27, 2017
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.

5 participants