-
Notifications
You must be signed in to change notification settings - Fork 360
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
Add continuous export #949
Conversation
529ddbf
to
c52eefe
Compare
Codecov Report
@@ Coverage Diff @@
## master #949 +/- ##
==========================================
- Coverage 44.46% 44.23% -0.23%
==========================================
Files 143 143
Lines 11486 11560 +74
==========================================
+ Hits 5107 5114 +7
- Misses 5743 5807 +64
- Partials 636 639 +3
Continue to review full report at Codecov.
|
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.
Looks Good
export/export.go
Outdated
exportConfiguration, err := c.GetExportConfigurationForBranch(repo, branch) | ||
if errors.Is(err, pgx.ErrNoRows) { |
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 think it would be better to return and check a cataloger error instead.
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.
Yup! It actually returns a db
error, the old code was incorrect. Thanks, good catch!
export/export_handler.go
Outdated
isContinuous, err := hasContinuousExport(h.cataloger, repo, branch) | ||
if err != nil { | ||
// FAIL this merge: if we were meant to export it and did not then in practice | ||
// there was no merge. | ||
return fmt.Errorf("check continuous export for merge %+v: %w", *merge, err) | ||
} | ||
if !isContinuous { | ||
return nil | ||
} | ||
_, err = ExportBranchStart(h.parade, h.cataloger, repo, branch) | ||
if errors.Is(err, ErrExportInProgress) { | ||
err = nil | ||
} |
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.
It might be nice to take it out to a function, given that exportCommitHook does the same
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, that's a good idea! I thought it would be too hard because of logging and error messages, but it was actually easy...
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!
Finishing CI, rebasing (might be painful) and merging...
export/export.go
Outdated
exportConfiguration, err := c.GetExportConfigurationForBranch(repo, branch) | ||
if errors.Is(err, pgx.ErrNoRows) { |
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.
Yup! It actually returns a db
error, the old code was incorrect. Thanks, good catch!
export/export_handler.go
Outdated
isContinuous, err := hasContinuousExport(h.cataloger, repo, branch) | ||
if err != nil { | ||
// FAIL this merge: if we were meant to export it and did not then in practice | ||
// there was no merge. | ||
return fmt.Errorf("check continuous export for merge %+v: %w", *merge, err) | ||
} | ||
if !isContinuous { | ||
return nil | ||
} | ||
_, err = ExportBranchStart(h.parade, h.cataloger, repo, branch) | ||
if errors.Is(err, ErrExportInProgress) { | ||
err = nil | ||
} |
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, that's a good idea! I thought it would be too hard because of logging and error messages, but it was actually easy...
737b336
to
b1621a9
Compare
Handles a commit or merge occurring concurrently with an export.
Hook onto commits and merges to start an export. This export will attempt to export to the branch tip.
This is actually in [the docs](https://golang.org/pkg/time/#pkg-constants): To convert an integer number of units to a Duration, multiply: ``` seconds := 10 fmt.Print(time.Duration(seconds)*time.Second) // prints 10s ``` That's due to shortcomings of the Go type system. But this way is safer, it avoids conversion to an int type.
Most notably, avoid double updates in ExportBranchDone.
Yup, it ends up checking for the line length. 132 columns are back!!?! (http://www.righto.com/2019/01/accounting-machines-ibm-1403-and-why.html)
Also extract a smaller interface `cataloger.Exporter`
Package `scany` depends on a different version of `pgx` than the rest of lakeFS. So `errors.Is(err, pgx.ErrNoRows)` fails. Luckily it (sort-of) knows of this issue and wraps this call inside it as `pgxscan.NotFound`. Also make `ErrNotFound` wrap `pgx.ErrNoRows` rather than a new error.
Catalog methods do not support transactions anyway. So there is no way for a hook to use its transaction. OTOH, running inside the transaction means all catalog methods that the hook calls will NOT see the commit or merge. So fix that.
b1621a9
to
74527c9
Compare
@nopcoder please verify the rebase went well, I made a few changes (but fewer than I expected...). |
Co-authored-by: Barak Amar <barak.amar@treeverse.io>
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!
…into feature/534-continuous
4a3a5ce
to
eeeed6d
Compare
No description provided.