-
Notifications
You must be signed in to change notification settings - Fork 56
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
Configurable timeout for custom operation handler #1917
Configurable timeout for custom operation handler #1917
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole timeout logic has to be rewritten. But fist, add tests for this new feature.
let outcome_fut = self.inner_child.wait_with_output();
// first attempt
tokio::select! {
outcome = outcome_fut => {
return self.finalize(outcome)
}
_ = tokio::time::sleep(duration) => {
send_term
}
}
// 2nd attempt
tokio::select! {
outcome = outcome_fut => {
return self.finalize(outcome)
}
_ = tokio::time::sleep(duration) => {
send_kill
}
}
outcome = outcome_fut.wait();
return self.finalize(outcome);
82c4b6a
to
1f86ffd
Compare
Robot Results
Passed Tests
|
b42a25a
to
0036b6d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would really avoid to add new config settings in tedge.toml
. For many reasons:
- This will have to be re-implemented soon with the new config under implementation.
- This is not urgent. This is for default values. We can hard-code them. Users can set timeout values to each operations if not happy with the defaults.
@@ -634,13 +635,15 @@ fn create_supported_operations(path: &Path) -> Result<Message, ConversionError> | |||
|
|||
Ok(Message::new( | |||
&Topic::new_unchecked(&stopic), | |||
Operations::try_new(path)?.create_smartrest_ops_message()?, | |||
Operations::try_new(path, Duration::from_secs(0), Duration::from_secs(0))? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does it mean to have a timeout of 0 seconds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests do not need any timeout options, but the API needs those parameters. I can make them optional, but this will make the code more complicated. So, I went this way.
The user can set only |
You added For testing purpose, it makes sense to pass default timeout values when building |
Passing can be done in case of unit tests, what about the integration tests? |
ed7d5d1
to
eeba9eb
Compare
3e39585
to
cb93957
Compare
cb93957
to
bc224eb
Compare
bc224eb
to
b4f11d0
Compare
Codecov Report
Additional details and impacted files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments.
tests/RobotFramework/tests/cumulocity/Operation/c8y_Command_Fails
Outdated
Show resolved
Hide resolved
tests/RobotFramework/tests/cumulocity/Operation/c8y_Command_Fails
Outdated
Show resolved
Hide resolved
5ddb343
to
b1a5580
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main point of this PR is now correct.
Still some small points to be fix. Most importantly the test in c8y mapper converter that is now green for bad reasons.
outcome | ||
} | ||
|
||
fn send_sigal_to_stop_child(child: Option<u32>, signal_type: CmdStatus) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why an Option
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To send the signal
if the child is present.
Signed-off-by: Pradeep Kumar K J <pradeepkumar.kj@softwareag.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved - Thank you.
f9aaf77
to
fcd4141
Compare
Proposed changes
The custom operation must timeout if not completed successfully within the given timeout period.
The
timeout
will be passed as part of the operation file, for example as below.As in the above operation file, if the operation does not complete within mentioned timeout then it will be gracefully killed by sending the
sigterm
and will wait for some time.If the operation is not stopped even after sending the
sigterm
then it will be killed forcefully by sending thesigkill
.Types of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments