-
Notifications
You must be signed in to change notification settings - Fork 242
Add namespace to pins #856
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #856 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 299 299
Lines 19388 19379 -9
=========================================
- Hits 19388 19379 -9
Continue to review full report at Codecov.
|
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
peterbroadhurst
left a comment
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.
Code looks great to me. I did have a couple of questions for you to ponder whether there's more to do before this merges.
| @@ -0,0 +1,5 @@ | |||
| BEGIN; | |||
| ALTER TABLE pins ADD COLUMN namespace VARCHAR(64); | |||
| UPDATE pins SET namespace = 'ff_system'; | |||
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.
I've added a migration_consideration tag, as we've chosen ff_system really only because it's a reserved namespace name that can be used to query these values back (definitely not because these pre-upgrade pins were all for the ff_system namespace).
So we should document 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.
Yea, originally I was going to leave it blank but then realized the API would give you no way to query them (and that seemed bad).
Pins were treated as "global" in 1.0, and the aggregator loop that processes pins even logs them as if they are part of ff_system (see here), so it didn't feel terribly wrong to pick ff_system for this purpose. But it was always a bit inaccurate, as they are specific to a namespace even if they weren't treated that way.
Anyway, bit of a ramble but I agree we need to document it.
| @@ -0,0 +1,2 @@ | |||
| ALTER TABLE pins ADD COLUMN namespace VARCHAR(64); | |||
| UPDATE pins SET namespace = "ff_system"; | |||
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.
Do you think we should we update the indexes to have namespace as a dimension?
I've noticed we did that elsewhere when we introduced a namespace, and I guess it should help with isolation of performance considerations between namespaces in the case of a shared DB.
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.
As part of answering this, I think it would be good to look at this code:
firefly/internal/events/aggregator.go
Lines 224 to 232 in eb61c4c
| func (ag *aggregator) getPins(ctx context.Context, filter database.Filter, offset int64) ([]core.LocallySequenced, error) { | |
| log.L(ctx).Tracef("Reading page of pins > %d (first pin would be %d)", offset, offset+1) | |
| pins, _, err := ag.database.GetPins(ctx, filter) | |
| ls := make([]core.LocallySequenced, len(pins)) | |
| for i, p := range pins { | |
| ls[i] = p | |
| } | |
| return ls, err | |
| } |
If the event aggregator is to become namespace aware, then I would expect the filter passed into this function by the parent to include a namespace filter. I'm not sure if that's true today.
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 catch, and I think this should be rolled into #855 where the aggregator becomes namespace-aware.
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 do that without introducing yet another migration file?
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.
Yes, can do. We've said migrations aren't guaranteed to be stable in mainline (only between releases).
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.
See here
| Name: "getStatusPins", | ||
| Path: "status/pins", | ||
| var getPins = &ffapi.Route{ | ||
| Name: "getPins", |
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.
Also need to cover the moving of the API in the migration docs
peterbroadhurst
left a comment
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.
Added approval - note my request to see if when #855 merges we can re-use the migration file, rather than adding a new one.
Existing pins will all be categorized against "ff_system", just so the field has a non-null value.