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

[Feature Request] Support multi-tenanted Zeebe workers #171

Closed
warnellw opened this issue Jun 3, 2024 · 5 comments
Closed

[Feature Request] Support multi-tenanted Zeebe workers #171

warnellw opened this issue Jun 3, 2024 · 5 comments
Assignees

Comments

@warnellw
Copy link

warnellw commented Jun 3, 2024

SDK Component

Zeebe

Expected Behavior

When creating a Zeebe worker via zeebe.createWorker in a multi-tenanted environment, the worker options should accept a single tenantId or an array of tenantIds.

Current Behavior

When creating a Zeebe worker via zeebe.createWorker, the tenantId property is missing in the typings. Adding it anyway (ignoring Typescript), does work and allows the worker to be single-tenanted. However, the SDK only seems to support a single tenant.

Possible Solution

Expose/create a tenantIds property on the ZBWorkerBase class, and update the following implementation that forces a single tenant: https://github.com/camunda/camunda-8-js-sdk/blob/main/src/zeebe/lib/ZBWorkerBase.ts#L563

Steps to Reproduce

  1. Enable multi-tenancy
  2. Create a Zeebe worker and force the tenantId into the zeebe.createWorker options - the worker connects successfully
  3. Try to pass multiple tenants into the zeebe.createWorker options with the tenantIds property via an array, note it does not work

Context (Environment)

While it's possible to force a worker to be single-tenanted (despite the missing type), it's not possible to have a worker multi-tenanted. Meaning, if multiple tenants share the same job, a separate worker must be created per tenant per job.

@warnellw warnellw changed the title [Feature Request] Support tenanted Zeebe workers [Feature Request] Support multi-tenanted Zeebe workers Jun 3, 2024
@jwulf
Copy link
Member

jwulf commented Jun 4, 2024

At the moment, the worker inherits the process environment CAMUNDA_TENANT_ID value.

You can override this by supplying a specific tenantId to the createWorker call (and yes, it is undocumented at the moment).

You really want a multi-tenanted worker?

I had avoided supporting this scenario because it seems like you would want to enforce data segregation in the worker.

We could make the tenantId explicit, and accept an array of values; it would be optional, and if not supplied it would default to the CAMUNDA_TENANT_ID value from the client constructor or environment.

How does that sound?

@warnellw
Copy link
Author

warnellw commented Jun 4, 2024

We could make the tenantId explicit, and accept an array of values; it would be optional, and if not supplied it would default to the CAMUNDA_TENANT_ID value from the client constructor or environment.

How does that sound?

This sounds great! Thank you! 🙂

Our use case for multi-tenanted workers is that many of our products have relatively similar BPMNs/jobs, with the only input difference being the tenantId when executed. We enforce segregation at the application-level via RLS and some other methods, so the worker itself is less of a concern.

Thanks again!

jwulf added a commit that referenced this issue Jun 5, 2024
* feat(zeebe): add updateJobTimeout method

fixes #171
github-actions bot pushed a commit that referenced this issue Jun 5, 2024
## [8.5.5-alpha.1](v8.5.4...v8.5.5-alpha.1) (2024-06-05)

### Features

* **zeebe:** add updateJobTimeout method ([#172](#172)) ([5eff624](5eff624)), closes [#171](#171)
* **zeebe:** support StreamActivatedJobs RPC ([#160](#160)) ([258296a](258296a)), closes [#17](#17)
github-actions bot pushed a commit that referenced this issue Jun 5, 2024
## [8.5.5-alpha.1](v8.5.4...v8.5.5-alpha.1) (2024-06-05)

### Features

* **zeebe:** add updateJobTimeout method ([#172](#172)) ([5eff624](5eff624)), closes [#171](#171)
* **zeebe:** support StreamActivatedJobs RPC ([#160](#160)) ([258296a](258296a)), closes [#17](#17)
@jwulf jwulf closed this as completed in 5151eb0 Jun 5, 2024
@warnellw
Copy link
Author

warnellw commented Jun 5, 2024

@jwulf I think this was accidentally closed - the linked PR looks unrelated

@jwulf jwulf reopened this Jun 6, 2024
github-actions bot pushed a commit that referenced this issue Jun 6, 2024
## [8.5.5](v8.5.4...v8.5.5) (2024-06-06)

### Features

* **zeebe:** add updateJobTimeout method ([#172](#172)) ([5eff624](5eff624)), closes [#171](#171)
* **zeebe:** support StreamActivatedJobs RPC ([#160](#160)) ([258296a](258296a)), closes [#17](#17)
github-actions bot pushed a commit that referenced this issue Jun 6, 2024
## [8.5.5](v8.5.4...v8.5.5) (2024-06-06)

### Features

* **zeebe:** add updateJobTimeout method ([#172](#172)) ([5eff624](5eff624)), closes [#171](#171)
* **zeebe:** support StreamActivatedJobs RPC ([#160](#160)) ([258296a](258296a)), closes [#17](#17)
@jwulf jwulf self-assigned this Jun 6, 2024
jwulf added a commit that referenced this issue Jun 7, 2024
adds tenantIds: string[] to stream and polling worker config

fixes #171
jwulf added a commit that referenced this issue Jun 7, 2024
adds tenantIds: string[] to stream and polling worker config

fixes #171
jwulf added a commit that referenced this issue Jun 7, 2024
adds tenantIds: string[] to stream and polling worker config

fixes #171
github-actions bot pushed a commit that referenced this issue Jun 7, 2024
## [8.6.1-alpha.1](v8.6.0...v8.6.1-alpha.1) (2024-06-07)

### Features

* **zeebe:** add multi-tenant support to workers ([#175](#175)) ([28450a5](28450a5)), closes [#171](#171)
* **zeebe:** add updateJobTimeout method ([#172](#172)) ([5eff624](5eff624)), closes [#171](#171)
* **zeebe:** support StreamActivatedJobs RPC ([#160](#160)) ([258296a](258296a)), closes [#17](#17)
github-actions bot pushed a commit that referenced this issue Jun 7, 2024
## [8.6.1-alpha.1](v8.6.0...v8.6.1-alpha.1) (2024-06-07)

### Features

* **zeebe:** add multi-tenant support to workers ([#175](#175)) ([28450a5](28450a5)), closes [#171](#171)
* **zeebe:** add updateJobTimeout method ([#172](#172)) ([5eff624](5eff624)), closes [#171](#171)
* **zeebe:** support StreamActivatedJobs RPC ([#160](#160)) ([258296a](258296a)), closes [#17](#17)
github-actions bot pushed a commit that referenced this issue Jun 10, 2024
## [8.5.6](v8.5.5...v8.5.6) (2024-06-10)

### Features

* **zeebe:** add multi-tenant support to workers ([#176](#176)) ([434f697](434f697)), closes [#171](#171)
github-actions bot pushed a commit that referenced this issue Jun 10, 2024
## [8.5.6](v8.5.5...v8.5.6) (2024-06-10)

### Features

* **zeebe:** add multi-tenant support to workers ([#176](#176)) ([434f697](434f697)), closes [#171](#171)
@jwulf jwulf closed this as completed in 05b3ecb Jun 10, 2024
@jwulf
Copy link
Member

jwulf commented Jun 10, 2024

Out in 8.6.1

@jwulf
Copy link
Member

jwulf commented Jun 10, 2024

Example use:

client.createWorker({
   taskHandler: (job) => {
      console.log(job.tenantId) // '<default>' | 'green'
      return job.complete()
   },
   taskType: 'multi-tenant-work',
   tenantIds: ['<default>', 'green'],
})

client.streamJobs({
   taskHandler: async (job) => {
      console.log(job.tenantId) // '<default>' | 'green'
      return job.complete()
   },
   type: 'multi-tenant-stream-work',
   tenantIds: ['<default>', 'green'],
   worker: 'stream-worker',
   timeout: 2000,
})

github-actions bot pushed a commit that referenced this issue Jun 12, 2024
## [8.6.2](v8.6.1...v8.6.2) (2024-06-12)

### Bug Fixes

* **zeebe:** security fix for grpc-js dependency update ([#180](#180)) ([f43d956](f43d956))

### Features

* **zeebe:** add deployResources method ([165862f](165862f)), closes [#173](#173)
* **zeebe:** add multi-tenant support to workers ([#175](#175)) ([28450a5](28450a5)), closes [#171](#171)
* **zeebe:** add updateJobTimeout method ([#172](#172)) ([5eff624](5eff624)), closes [#171](#171)
* **zeebe:** support StreamActivatedJobs RPC ([#160](#160)) ([258296a](258296a)), closes [#17](#17)
github-actions bot pushed a commit that referenced this issue Jun 12, 2024
## [8.6.2](v8.6.1...v8.6.2) (2024-06-12)

### Bug Fixes

* **zeebe:** security fix for grpc-js dependency update ([#180](#180)) ([f43d956](f43d956))

### Features

* **zeebe:** add deployResources method ([165862f](165862f)), closes [#173](#173)
* **zeebe:** add multi-tenant support to workers ([#175](#175)) ([28450a5](28450a5)), closes [#171](#171)
* **zeebe:** add updateJobTimeout method ([#172](#172)) ([5eff624](5eff624)), closes [#171](#171)
* **zeebe:** support StreamActivatedJobs RPC ([#160](#160)) ([258296a](258296a)), closes [#17](#17)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

No branches or pull requests

2 participants