-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat: resource log #16522
feat: resource log #16522
Conversation
5224902
to
c036ee2
Compare
f9214ac
to
266bce6
Compare
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.
Awesome stuff! I added some clarifying comments for future readers as to why I like this design based on the fact that we will be storing this data in a columnar store 👍
@@ -8,6 +8,21 @@ import ( | |||
icontext "github.com/influxdata/influxdb/context" | |||
) | |||
|
|||
func TestGetAuthorizer(t *testing.T) { |
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.
💯
func ErrInternalBucketServiceError(op string, err error) *Error { | ||
return &Error{ | ||
Code: EInternal, | ||
Msg: fmt.Sprintf("unexpected error in buckets; Err: %v", err), | ||
Op: op, | ||
Err: err, | ||
} | ||
} |
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.
This is a great addition 🥇
if err := s.putBucket(ctx, tx, b); err != nil { | ||
v, err := json.Marshal(b) | ||
if err != nil { | ||
return influxdb.ErrInternalBucketServiceError(influxdb.OpCreateBucket, err) |
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 ❤️ the distinct errors
type Change struct { | ||
// Type of change. | ||
Type ChangeType | ||
// ResourceID of the changed resource. | ||
ResourceID influxdb.ID | ||
// ResourceType that was changed. | ||
ResourceType influxdb.ResourceType | ||
// OrganizationID of the organization owning the changed resource. | ||
OrganizationID influxdb.ID | ||
// UserID of the user changing the resource. | ||
UserID influxdb.ID | ||
// ResourceBody after the change. | ||
ResourceBody []byte | ||
// Time when the resource was changed. | ||
Time time.Time | ||
} |
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.
Wanted to state the design here, for my own clarification and thinking aloud. tl;dr is this approach is sound 👍
To know the specific changes made to a resource over time, we read its entire history and look at each prior ResourceBody
to determine the deltas. Knowing that we will store the change history in InfluxDB, this approach is more efficient. Why? Prior values will be in the same column as the ResourceBody
field and very likely stored in the same TSM block, so will be decompressed together. 💯
For posterity, the alternative would be to include the PreviousResourceBody
as an additional value as a separate column. Whilst this approach may be better for a row-based data store, it will require separate reads for a columnar-based store like InfluxDB.
💯
266bce6
to
9697b60
Compare
This change introduces a resource audit logger to track changes to resources in the system. The operations on tasks, buckets and organizations are augmented to use this logger.
No implementation is currently provided.