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(inputs.opcua): Fix opcua and opcua-listener for servers using password-based auth #12529

Merged
merged 12 commits into from
Jan 30, 2023

Conversation

vsinha
Copy link
Contributor

@vsinha vsinha commented Jan 20, 2023

The Gopcua/opcua client was never properly initialized, which meant that authentication to the opcua server was never configured. My guess is this got lost in the shuffle of the addition of the opcua_listener plugin.

In testing before this change, without calling init, the server gave an error like

2023-01-20T20:27:06Z E! [inputs.opcua] Error in plugin: error in Client Connection: The user identity token is not valid. StatusBadIdentityTokenInvalid (0x80200000)

After Init(), the plugin works and is able to ingest data as expected.

@telegraf-tiger telegraf-tiger bot added area/opcua fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Jan 20, 2023
@vsinha
Copy link
Contributor Author

vsinha commented Jan 20, 2023

@LarsStegman does this look right to you? There's a few layers of abstraction and several different things called Init in the telegraf codebase, but it looks like OpcUAClient.Init is specifically configuring options (and not eg starting a subscription), and further on telegraf/plugins/common/opcua/client.go:74 the log line even claims to be initializing OpcUAClient and sets some other state inside the struct.

@LarsStegman
Copy link
Contributor

Hi,

yeah this looks right. Thanks! Looks like it fell through the cracks during the refactor.

Interesting we got no bug reports for this. Maybe almost everybody is using it without the auth part.

Could you look into adding a test for this? I'm not sure if the test container with the OPC server also supports a config with authentication required.

@powersj powersj added the waiting for response waiting for response from contributor label Jan 23, 2023
@vsinha
Copy link
Contributor Author

vsinha commented Jan 24, 2023

@LarsStegman done!

Took some digging around in how open62541 is structured but happily they have a binary packaged in the existing docker container which sets itself up with password auth.

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Jan 24, 2023
@vsinha vsinha changed the title fix(inputs.opcua): Call Init() on the opcua client fix(inputs.opcua): Fix opcua and opcua-listener for servers using password-based auth Jan 24, 2023
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 taking the time to put up a PR!

@powersj powersj 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 Jan 26, 2023
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 for your fix @vsinha. I have one comment regarding the placement of the call to Init(). Furthermore, I would prefer to split this PR into the fix, which is the missing call to Init() AFAICS, and the cleanup of the test and read_client.
What do you think?

plugins/common/opcua/client.go Outdated Show resolved Hide resolved
@telegraf-tiger
Copy link
Contributor

@vsinha
Copy link
Contributor Author

vsinha commented Jan 28, 2023

I made these changes and split out the refactor for a future PR! Thanks for the feedback @srebhan

@srebhan
Copy link
Contributor

srebhan commented Jan 30, 2023

Thanks for the nice fix and the splitting @vsinha! @powersj can you please take another look and merge if you agree to the changes made!

@srebhan srebhan removed their assignment Jan 30, 2023
@powersj powersj merged commit e96a49e into influxdata:master Jan 30, 2023
srebhan pushed a commit that referenced this pull request Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/opcua fix pr to fix corresponding bug 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.

None yet

4 participants