-
Notifications
You must be signed in to change notification settings - Fork 11.7k
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
Storage: Read desired mode from config instead of feature flags #88353
Conversation
d8fc6d1
to
0448adf
Compare
0448adf
to
1462e7f
Compare
pkg/apiserver/builder/common.go
Outdated
// Get the desired dual writing mode. These are modes 1, 2, 3 and 4 if | ||
// the feature flag `unifiedStorage` is enabled and mode 0 if it is not enabled. | ||
// #TODO add type for map[string]grafanarest.DualWriterMode? | ||
GetDesiredDualWriterMode(dualWrite bool, modeMap map[string]grafanarest.DualWriterMode) grafanarest.DualWriterMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have the key of the map be something like (Group, Resource)? Just to make sure we use all qualified names and there are no second ways to refer to the same thing. Example: ("playlist.grafana.app", "playlists")
or could be in JSON format: {"group": "playlist.grafana.app", "resource": "playlists"}
, or a URL (but I don't recall how they are built to give an example, sorry). Anything would work, I would just like to have a consistent way to refer to the resource that we set the dual writing mode for. IMO we don't care about the version, and that would complicate further, so we can skip that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call-out, in k8s a GroupResource is represented as <resource>.<group>
when written as a string, though that can be confusing so using something more like a url path representation <group>/<resource>
would also make sense to me (and is unambiguous because the forward slash is not an allowed character in either group or resource, while dot is a legal character in group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed it here 0ae476a. Thank you both for the suggestions!
@@ -80,7 +79,8 @@ type DualWriter interface { | |||
type DualWriterMode int | |||
|
|||
const ( | |||
Mode1 DualWriterMode = iota + 1 | |||
Mode0 DualWriterMode = iota |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make sure this still works when mode is set to 0?
I'm afraid we will end up in a weird situation id DW mode is 0 and we inevitably call NewDualWrite
with no option for 0.
I wonder if it would be better to just assume if we have a dualWriterMode
defined, we will have to be in one of the 4 (1-4) modes. And if it's not defined, we know we are not in the realm of any sort of dualwriter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! I added integration tests for mode 0 to make sure we are taking it into account.
Mode 0 will only function as a way of representing whether unifiedStorage
is enabled or not. I think this is fine because it too represents one of the dual writing states, that of not being enabled. To me dual writing doesn't have to mean literally writing to both storages. The advantage of this approach is that it allows us to simplify the signature of GetAPIGroupInfo
, which was suggested in #87668 (comment). This was the best way I found to do so but happy to consider other options of course.
6a02330
to
88cffd3
Compare
0e0c922
to
d5d74e3
Compare
df579f3
to
d822240
Compare
0ae476a
to
b4b9b6d
Compare
c509565
to
b4b9b6d
Compare
…ana#88353) * Read desired mode from config * Update playlist integration tests * Add mode 1 playlist integration tests * Add mode 0 dual writing to playlist integration tests * Add documentation for the different dual writing modes
* Read desired mode from config * Update playlist integration tests * Add mode 1 playlist integration tests * Add mode 0 dual writing to playlist integration tests * Add documentation for the different dual writing modes
What is this feature?
Read desired dual writing mode from config rather than feature toggles. Counterpart to https://github.com/grafana/grafana-enterprise/pull/6689
Why do we need this feature?
Addresses this PR comment: #87668 (comment)
Who is this feature for?
U.S. users, devs
Which issue(s) does this PR fix?:
Relates to https://github.com/grafana/search-and-storage-team/issues/15
Special notes for your reviewer:
InstallAPIs
isn't in the scope of any specific builder. Would be interested in hearing suggestions for approaching this part differently.Please check that: