Repository navigation
Conversation
|
Please sign your commits following these rules: $ git clone -b "swift-plus" [email protected]:sapcc/distribution.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842354442760
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -fAmending updates the existing PR. You DO NOT need to open a new one. |
Codecov Report
@@ Coverage Diff @@
## master #2441 +/- ##
==========================================
- Coverage 50.52% 49.21% -1.32%
==========================================
Files 125 130 +5
Lines 13855 12385 -1470
==========================================
- Hits 7000 6095 -905
+ Misses 6157 5528 -629
- Partials 698 762 +64
Continue to review full report at Codecov.
|
Signed-off-by: Stefan Majewsky <[email protected]>
The Swift storage driver famously has problems with eventual consistency (see also the heuristics that I added last year). In our team, we switched to CoreOS's competing product Quay instead, which works around the eventual consistency problems by storing most metadata in Postgres, putting only long-lived blobs into Swift. Since we now want to make a new deployment where Quay is not an option, I implemented a new storage driver, currently called "swift-plus", which does the same: Metadata and small files (below 256 bytes) are stored in a Postgres instance, and large files (mostly image layers) go into Swift. I have yet to run any load tests on this, but the design would suggest that there should be no eventual consistency problems with this driver. Some notes on the implementation: - The `swift-plus` driver lives in the same Go package as the existing `swift` driver because of code sharing (related to config validation and driver initialization). Furthermore, the plus driver uses the original driver for Swift operations (via a private interface), so that the DB-related code (in the plus driver) is separated from the Swift-related code (in the original driver). - The configuration for `swift-plus` is nearly identical to `swift`, with the only difference being the required `postgresuri` configuration value. - There is *no upgrade path* from the `swift` driver to `swift-plus`, other than standing up a new registry instance and mirroring all images into it (i.e. `for image; do docker pull && docker tag && docker push; done`). I initially considered offering an upgrade path for all those existing users suffering from distribution#1013, but it turned out to constrain the design too much. Signed-off-by: Stefan Majewsky <[email protected]>
|
it will bring much more complexity to operate registry with a database, storage driver is only about storage, not database. However, I do agree that this is a place where registry should enhance, but should in a way that would benefit all the use cases no matter which storage driver is in use. At my first thought, the cache layer is something that should be in, currently, it plays a role where we need to check existence of a certain blob by digest. Well, what if the cache layer can also serve small blobs directly, actually, I mean the manifests, if this can be served directly without hitting storage, then this is no difference with a database setup probably. And, to complete the idea, we should also know when the manifest is removed from storage, but this should not be a big problem to detect/hook. This is my naive idea though. |
|
If one result of this discussion is to enhance the caching logic somewhere else in the Registry, and that alleviates the problems in #1013, then I'm all for it. I'm not certain, though. The biggest source of eventual consistency issues was with chunked uploading of layers, which swift-plus fixes by tracking segments in Postgres during upload (and also by using the more reliable SLOs instead of DLOs to merge segments into whole objects on the Swift side).
In my experience, a Postgres instance is much easier to operate than a Swift cluster, by multiple orders of magnitude. (Also, this is not about replacing the original |
…tes/migrate Signed-off-by: Stefan Majewsky <[email protected]>
I thought about this some more and came to the conclusion that implementing deleteUpwards() safely without any race conditions is not worth the trouble. If there are some more DB entries for now-empty directories, so what? Signed-off-by: Stefan Majewsky <[email protected]>
Signed-off-by: Stefan Majewsky <[email protected]>
|
I completed a load test with this driver on our infrastructure, using a similar setup with which I investigated the eventual inconsistency problems in the original Swift storage driver:
This ran for about 6 hours, totalling over 8,000 images pushed and pulled, and while Swift was visibly strained from the load according to our Grafana dashboards, not a single error occurred in the registry's log, and not a single request to Swift resulted in an error response (HTTP status code 400+). For comparison, the old Swift driver would have at least one or two errors per hour, and that's after all the patches that I contributed. And even then, there would be a ton of backoffs and retries because Swift would send 404 responses all the time. |
|
@majewsky . Thanks a lot !!!! . Can we use the new swift driver ? If yes what all changes we need to make from the existing setup and Do you have any short document for the new driver setup? |
| //PostgresURI is only used by the swift-plus driver. The value is a libpq | ||
| //connection URI (starting with "postgres://") as described here: | ||
| //https://www.postgresql.org/docs/9.6/static/libpq-connect.html#LIBPQ-CONNSTRING | ||
| PostgresURI string |
There was a problem hiding this comment.
I may be missing something, but I don't see this used anywhere.
There was a problem hiding this comment.
Look at the swift-plus.go file. It's collapsed by default by Github's UI because it's fairly large.
|
@majewsky Thanks for the proposal! I think this is an interesting approach, especially for those that are willing to add postgres to a registry deployment. Addressing this issue at the driver level, rather than the metadata level leaves room for making any driver more consistent (maybe) while avoiding the cost of upgrading. Even though you say there is no upgrade path, I am not so sure its something that couldn't be achieved. Have you compared this approach to simply adding a store that makes the metadata consistent, avoiding hits to the storage driver? There would be a lot more code, but all drivers would benefit. The results you got in your tests would make me think that postgres is already in use. However, I don't see any commits that call out to postgres. Am I missing something? Is there some changes we make on the existing driver to address these issues? Looking forward to hearing your response. |
|
@stevvooe could you comment on this as well?
|
I have looked into this, both expanding redis' role and employing something like groupcache. That would address performance issues for slow backends (:eyes: s3). I am not sure what effect it would have on consistency, but I can't see addressing the same problems this PR is attempting to address, which is read-after-write consistency. That said, it would be great to explore complementary patches that address this. |
|
Sorry for not replying earlier. I have been off work for two weeks.
It's difficult. I initially tried to use the same file layout on the Swift side, in order to enable an upgrade path, but gave up when trying to implement
I have not looked at this level yet. I'm only familiar with the storagedriver interface, and the swift implementation of that interface in particular. I may have a look when time permits. Do you have a particular place where I can start reading? |
|
TBH I am not a big fan of this solution, It add more complexity, has no migration path. This solution is the only one that works for swift. I vote to make this driver part of the distribution, until a better solution is provided. p.s. |
Signed-off-by: Stefan Majewsky <[email protected]>
Signed-off-by: Stefan Majewsky <[email protected]>
|
There is no plan to support new storage driver in |
|
Currently not accepting new storage drivers. If you are maintaining a fork for swift support, you could consider adding it here: https://github.com/distribution/distribution/blob/main/docs/storage-drivers/index.md#driver-contribution To join in discussion around storage drivers, see #3988. |
The Swift storage driver famously has problems with eventual consistency (tracked in issue #1013, see also the heuristics that I added in PRs #1605, #1650 and #1710). In our team, we switched to CoreOS's competing product Quay instead, which works around the eventual consistency problems by storing most metadata in Postgres, putting only long-lived blobs into Swift.
Since we now want to make a new deployment where Quay is not an option, I implemented a new storage driver, currently called "swift-plus", which does the same: Metadata and small files (below 256 bytes) are stored in a Postgres instance, and large files (mostly image layers) go into Swift. I have yet to run any load tests on this, but the design would suggest that there should be no eventual consistency problems with this driver.
This is very WIP at the moment, but I'm putting up the PR now already to get some early feedback. Current status:
Some notes on the implementation:
swift-plusdriver lives in the same Go package as the existingswiftdriver because of code sharing (related to config validation and driver initialization). Furthermore, the plus driver uses the original driver for Swift operations (via a private interface), so that the DB-related code (in the plus driver) is separated from the Swift-related code (in the original driver).swift-plusis nearly identical toswift, with the only difference being the requiredpostgresuriconfiguration value that typically looks likepostgres://user:password@hostname/databasename(see doc here).swiftdriver toswift-plus, other than standing up a new registry instance and mirroring all images into it (i.e.for image; do docker pull && docker tag && docker push; done). I initially considered offering an upgrade path for all those existing users suffering from Swift eventual consistency problems? #1013, but it turned out to constrain the design too much.