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

Introduce Tenant ID field to Plugin Context #669

Closed
wants to merge 9 commits into from
Closed

Conversation

wbrowne
Copy link
Member

@wbrowne wbrowne commented Apr 17, 2023

What this PR does / why we need it:
Adds a new tenant ID field as part of the plugin request. This can be immediately used as supplementary info to the instance cache key for instance management

Special notes for your reviewer:

Related refactor which will eventually use this work

@wbrowne wbrowne added the enhancement New feature or request label Apr 17, 2023
@wbrowne wbrowne self-assigned this Apr 17, 2023
@wbrowne wbrowne requested a review from a team as a code owner April 17, 2023 10:24
@wbrowne wbrowne requested review from andresmgot, xnyo and marefr and removed request for a team April 17, 2023 10:24
Copy link
Member

@marefr marefr left a comment

Choose a reason for hiding this comment

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

LGTM This looks nice and make sense

Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

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

Thinking about this, from a protocol perspective, the missing information that you will need is probably just a tenantID.

Whoever is handling a cache (or similar) is the one that should generatee a valid key (as it's done here with pluginID + OrgID for example). It's a bit weird that the client (plugin) is setting a key that's only used in the server (grafana), isn't it?

@marefr
Copy link
Member

marefr commented Apr 17, 2023

Thinking about this, from a protocol perspective, the missing information that you will need is probably just a tenantID.

Whoever is handling a cache (or similar) is the one that should generatee a valid key (as it's done here with pluginID + OrgID for example). It's a bit weird that the client (plugin) is setting a key that's only used in the server (grafana), isn't it?

Tend to agree, but it only make sense in a Grafana Cloud context :) That might be fine, but could also confuse SDK consumers. Guess cache key could confuse as well, but maybe not as much 🤷 I don't have any strong opinions really and open for any suggestion

@wbrowne
Copy link
Member Author

wbrowne commented Apr 17, 2023

Thinking about this, from a protocol perspective, the missing information that you will need is probably just a tenantID.
Whoever is handling a cache (or similar) is the one that should generatee a valid key (as it's done here with pluginID + OrgID for example). It's a bit weird that the client (plugin) is setting a key that's only used in the server (grafana), isn't it?

Tend to agree, but it only make sense in a Grafana Cloud context :) That might be fine, but could also confuse SDK consumers. Guess cache key could confuse as well, but maybe not as much 🤷 I don't have any strong opinions really and open for any suggestion

Sorry for the delay on this - also no strong opinions on this, but I feel less inclined towards using the term "tenantID" as it might give the wrong impression at this early stage.

It's a bit weird that the client (plugin) is setting a key that's only used in the server (grafana), isn't it?

Just to correct, Grafana is the client in this case, and the plugin is the server. Given this relationship, and the plugin acting as virtually an extension of Grafana, it makes sense to me that Grafana can dictate control over how a plugin's resources are managed, when it is the one managing and orchestrating across all plugins 🤷

@marefr
Copy link
Member

marefr commented Apr 18, 2023

but I feel less inclined towards using the term "tenantID" as it might give the wrong impression at this early stage.

Good point. But at the same time it's not like something we can change it a later stage when changing the protobuf definition so something we have to live with :)

@andresmgot
Copy link
Contributor

I feel less inclined towards using the term "tenantID" as it might give the wrong impression at this early stage.

IMO I think that's fine if we mark it as "experimental"/optional/not-in-use

it makes sense to me that Grafana can dictate control over how a plugin's resources are managed, when it is the one managing and orchestrating across all plugins shrug

I am not sure I agree with this, even if Grafana is the orchestrator, is setting implementation details of things that doesn't manage (if I understood this correctly). If both use this key then it would be fine, but if it's only the plugin I still think that the plugin should decide how to build it, to avoid breaking changes in the API in the future.

But at the same time it's not like something we can change it a later stage

This is what I think too, it's probably going to remain however we set it.

If "tenantID" is too specific / potentially incorrect, what about "UID"? That would make also more sense for a field that identifies a plugin + instance and it could be helpful in Grafana for things like telemetry.

In any case, it's just a naming thing so feel free to go ahead with whatever you think is best (you know better :P) Naming is hard 😅

@wbrowne
Copy link
Member Author

wbrowne commented Apr 18, 2023

I feel less inclined towards using the term "tenantID" as it might give the wrong impression at this early stage.

IMO I think that's fine if we mark it as "experimental"/optional/not-in-use

it makes sense to me that Grafana can dictate control over how a plugin's resources are managed, when it is the one managing and orchestrating across all plugins shrug

I am not sure I agree with this, even if Grafana is the orchestrator, is setting implementation details of things that doesn't manage (if I understood this correctly). If both use this key then it would be fine, but if it's only the plugin I still think that the plugin should decide how to build it, to avoid breaking changes in the API in the future.

But at the same time it's not like something we can change it a later stage

This is what I think too, it's probably going to remain however we set it.

If "tenantID" is too specific / potentially incorrect, what about "UID"? That would make also more sense for a field that identifies a plugin + instance and it could be helpful in Grafana for things like telemetry.

In any case, it's just a naming thing so feel free to go ahead with whatever you think is best (you know better :P) Naming is hard 😅

I think you're right and I'll stick with what I originally had in mind. Let's go with simplicity 🥇

Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@wbrowne wbrowne changed the title Introduce dedicated request field for instance management caching Introduce Tenant ID field to Plugin Context Apr 18, 2023
@wbrowne wbrowne requested a review from marefr April 18, 2023 11:28
Copy link
Member

@marefr marefr left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@xnyo xnyo left a comment

Choose a reason for hiding this comment

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

LGTM great work!! 🚀

Copy link
Contributor

@bergquist bergquist left a comment

Choose a reason for hiding this comment

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

It's a bit weird that the client (plugin) is setting a key that's only used in the server (grafana), isn't it?

I think its weird if you just focus on the cache generation part. Any multi tenant system pass some kind of unique identifier per tenant used by other system to distinguished them. Ex ops.grafana.net and bergquist.grafana.net

In this case used to generate different cache keys when we want to separate them. Other caches in the SDK might not use the tenantID.

@wbrowne
Copy link
Member Author

wbrowne commented Apr 19, 2023

It's a bit weird that the client (plugin) is setting a key that's only used in the server (grafana), isn't it?

I think its weird if you just focus on the cache generation part. Any multi tenant system pass some kind of unique identifier per tenant used by other system to distinguished them. Ex ops.grafana.net and bergquist.grafana.net

In this case used to generate different cache keys when we want to separate them. Other caches in the SDK might not use the tenantID.

@bergquist, @andresmgot's comment probably makes more sense with the context prior to to this commit in case you missed it 9fc02a0.

Which would have meant that Grafana controls specifically what the entire cache key is - we did talk about this before and either way works, but this latest change feels like a simpler step for now if we want to move this direction.

@bergquist
Copy link
Contributor

@wbrowne thanks for clearing that up! :)

@andresmgot sorry for the confusion.

@wbrowne
Copy link
Member Author

wbrowne commented May 12, 2023

Closing in favour of #676

@wbrowne wbrowne closed this May 12, 2023
@wbrowne wbrowne deleted the plugin-context-key branch May 12, 2023 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants