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

feat(common.opcua): Add session timeout as configuration option #15341

Conversation

maxime-jolliet-airseas
Copy link
Contributor

@maxime-jolliet-airseas maxime-jolliet-airseas commented May 13, 2024

Summary

Adding the parameter "session_timeout" to OPCUA plugins configuration.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #15258

@telegraf-tiger
Copy link
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label May 13, 2024
@maxime-jolliet-airseas
Copy link
Contributor Author

maxime-jolliet-airseas commented May 13, 2024 via email

@srebhan srebhan changed the title feat: add session_timeout configuration option for OPCUA input plugins feat(common.opcua): Add session timeout as configuration option May 14, 2024
Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Thanks @maxime-jolliet-airseas for your contribution! I do have some comments in the code. It would also be nice to see a unit-test for the new option if possible...

plugins/common/opcua/opcua_util.go Outdated Show resolved Hide resolved
plugins/inputs/opcua/README.md Outdated Show resolved Hide resolved
plugins/inputs/opcua/sample.conf Outdated Show resolved Hide resolved
plugins/inputs/opcua_listener/README.md Outdated Show resolved Hide resolved
plugins/inputs/opcua_listener/sample.conf Outdated Show resolved Hide resolved
@srebhan srebhan self-assigned this May 14, 2024
@srebhan srebhan added the plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins label May 14, 2024
@maxime-jolliet-airseas
Copy link
Contributor Author

Hi srebhan, thank you for taking care of this PR.
I took into account your remarks, except for the unit test.
I know nothing about Go, and I didn't found anything testing config parameters that I could use as template. Could you point me to some tests if they do exist ?

Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

@maxime-jolliet-airseas thanks for the quick update!

Please do not change existing tests (see comments in the code) as we are using those to check backward compatibility of changes... I also do have a suggestion to only convert the timeout if set.

Regarding tests, the only way I see is to set the session timeout to a very low value (e.g. 100 millisecond), establish a session and then check if it actually timed out... But not a must...

plugins/common/opcua/input/input_client_test.go Outdated Show resolved Hide resolved
plugins/common/opcua/opcua_util.go Outdated Show resolved Hide resolved
plugins/inputs/opcua/opcua_test.go Outdated Show resolved Hide resolved
@maxime-jolliet-airseas
Copy link
Contributor Author

Ok, I removed the tests modifications.
As for adding a test; I did what you suggested, and created a Client with a very low session timeout. The client is still able to read data from the server; even when adding a time.Sleep. I suspect it reconnects automatically.
I did manually check on my server that the client connected with the configured session timeout, as my server exposes in OPCUA the list of connected clients along with their config. But the server used in the integration tests does not exposes connected clients, so I can't check like that in a test.

Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks @maxime-jolliet-airseas!

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label May 15, 2024
@srebhan srebhan assigned powersj and DStrand1 and unassigned srebhan May 15, 2024
Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I am going to remove the "default is..." statement as the value in the config is the default.

plugins/inputs/opcua/README.md Outdated Show resolved Hide resolved
plugins/inputs/opcua/sample.conf Outdated Show resolved Hide resolved
plugins/inputs/opcua_listener/README.md Outdated Show resolved Hide resolved
plugins/inputs/opcua_listener/sample.conf Outdated Show resolved Hide resolved
@telegraf-tiger
Copy link
Contributor

@powersj powersj merged commit c3c6189 into influxdata:master May 15, 2024
27 checks passed
@github-actions github-actions bot added this to the v1.31.0 milestone May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/opcua feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OPCUA - Access session timeout parameter from Telegraf
4 participants