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

Generate a unique NATS client id for event msgs #6623

Merged
merged 2 commits into from Jun 6, 2019

Conversation

@afiune
Copy link
Collaborator

commented Jun 5, 2019

After connecting one Habitat supervisor to Automate, all subsequent
connection attempts from Habitat fail with:

[2019-06-05T17:09:34Z ERROR ratsio::nats_client::client] NATS Server - Error - Permissions Violation for Publish to ".habitat"

This is happening because we hardcoded the client identifier used
to connect to the NATS Streaming server inside the Automate server.

From the NATS Streaming server documentation:

As described, clients are not directly connected to the streaming
server. Instead, they send connection requests. The request includes
a client ID which is used by the server to uniquely identify, and
restrict, a given client. That is, no two connections with the same
client ID will be able to run concurrently.

This change is generating a unique client id composed by the keyword
"hab_client_" plus the supervisor id.

New client id example: hab_client_4a5cb023f9274a8d9418bf5f974bdb52

Related resource: https://chefio.atlassian.net/browse/A2-860

Signed-off-by: Salim Afiune afiune@chef.io

Generate a unique NATS client id for event msgs
After connecting one Habitat supervisor to Automate, all subsequent
connection attempts from Habitat fail with:
```
[2019-06-05T17:09:34Z ERROR ratsio::nats_client::client] NATS Server - Error - Permissions Violation for Publish to ".habitat"
```

This is happening because we hard coded the client identifier used
to connect to the NATS Streaming server inside the Automate server.

From the NATS Streaming server [documentation](https://github.com/nats-io/nats-streaming-server#client-connections):
>As described, clients are not directly connected to the streaming
server. Instead, they send connection requests. The request includes
a client ID which is used by the server to uniquely identify, and
restrict, a given client. That is, no two connections with the same
client ID will be able to run concurrently.

This change is generating a unique client id composed by the key word
"hab_client_" plus the supervisor id.

New client id example: `hab_client_4a5cb023f9274a8d9418bf5f974bdb52`

Signed-off-by: Salim Afiune <afiune@chef.io>

@afiune afiune requested review from christophermaier and gpeers Jun 5, 2019

@afiune afiune requested review from baumanj and raskchanky as code owners Jun 5, 2019

@chef-expeditor

This comment has been minimized.

Copy link

commented Jun 5, 2019

Hello afiune! Thanks for the pull request!

Here is what will happen next:

  1. Your PR will be reviewed by the maintainers.
  2. If everything looks good, one of them will approve it, and your PR will be merged.

Thank you for contributing!

@christophermaier
Copy link
Contributor

left a comment

tenor-133935252

@afiune afiune force-pushed the afiune/events/non-uniq-nats-client-id branch from 88645d7 to a789d41 Jun 5, 2019

Fix lint:format errors
Signed-off-by: Salim Afiune <afiune@chef.io>

@afiune afiune force-pushed the afiune/events/non-uniq-nats-client-id branch from a789d41 to 7edef60 Jun 6, 2019

@christophermaier christophermaier merged commit f1c4388 into master Jun 6, 2019

5 checks passed

DCO This commit has a DCO Signed-off-by
Details
buildkite/habitat-sh-habitat-master-verify Build #2171 passed (34 minutes, 14 seconds)
Details
buildkite/habitat-sh-habitat-master-website Build #2382 passed (3 minutes, 35 seconds)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
expeditor/config-validation Validated your Expeditor config file
Details

chef-ci added a commit that referenced this pull request Jun 6, 2019

Update CHANGELOG.md with details from pull request #6623
Obvious fix; these changes are the result of automation not creative thinking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.