-
Notifications
You must be signed in to change notification settings - Fork 365
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: Add etcd database support #1023
base: master
Are you sure you want to change the base?
Conversation
@hudeng-go Looking good to me. What do you think of this comment on the other ticket? #1022 (comment) |
system/run-etcd.py
Outdated
@@ -0,0 +1,175 @@ | |||
#!/usr/bin/env python |
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 script is almost identical to system/run.py
:
/tmp/aptly etcd-dev ❯ diff system/run.py system/run-etcd.py
97a98,100
> t.configOverride = {
> "databaseEtcd": "127.0.0.1:2379"
> }
It would be much better to have a flag or an env variable to tell the test runner script to use etcd, rather than duplicate the whole script.
Moreover, I suspect that using configOverride
may not work on all cases. Many unittests set their own overrides, so either they will be overwritten with the databaseEtcd
key or viceversa.
Maybe databaseEtcd
could come from the environment, e.g. APTLY_ETCD_DATABASE
and set in lib.py:BaseTest.config
dictionary?
b7b80fd
to
30c5016
Compare
system/lib.py
Outdated
@@ -142,6 +142,7 @@ class BaseTest(object): | |||
"gpgDisableSign": False, | |||
"ppaDistributorID": "ubuntu", | |||
"ppaCodename": "", | |||
"databaseEtcd": "%s" % os.environ["APTLY_ETCD_DATABASE"], |
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 will throw a KeyError
if the env var is not set, which it isn't in the normal system-tests
. Maybe use os.environ.get("APTLY_ETCD_DATABASE") or ""
to make sure we have a valid value in the config?
bab0475
to
c3a4869
Compare
context/context.go
Outdated
@@ -287,7 +288,12 @@ func (context *AptlyContext) _database() (database.Storage, error) { | |||
if context.database == nil { | |||
var err error | |||
|
|||
context.database, err = goleveldb.NewDB(context.dbPath()) | |||
if context.config().DatabaseEtcd != "" { |
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 wonder if we should have a more explicit way to pick the database, rather than look at DatabaseEtcd
.
Maybe having a new config like databaseBackend
to be one of: "leveldb", "etcd", etc.? What do you think?
@hudeng-go Tests failed... https://github.com/aptly-dev/aptly/runs/5140408342?check_suite_focus=true |
Sorry, it took a long time to link etcd when migrating data. We are looking for the reason. |
@hudeng-go I had to stop the CI once again, as it was stuck... Can we make the script so that it would crash at the first error, so we don't continue a clearly failing test? |
I have modified the migration script to exit with an error. Sorry again. |
In my environment, data can be migrated to normally. I don't know why I can't connect to etcd database in GH action environment. |
if context.config().DatabaseBackend.Type == "etcd" { | ||
context.database, err = etcddb.NewDB(context.config().DatabaseBackend.Url) | ||
} else { | ||
context.database, err = goleveldb.NewDB(context.dbPath()) |
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 see the reason for using DatabaseBackend.Type
as recommended. I wonder though if we can adapt dbPath
(i.e. rootPath/db
) into your new DbConfig
structure? We must be backward compatible though. Maybe it's worth raising a separate ticket once this is merged.
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 don't quite understand. At present, this dbpath should be available only for leveldb, and the current processing method should be compatible with it. My idea is that if the dbconfig configuration in the configuration file is empty, the default leveldb is used as the back-end, and leveldb compatibility should not be required in dbconfig. This is also explained in the man document.
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.
Yeah, if we want to be backward compatible that's fine. I was considering the opportunity to fit the current dbPath
behavior in your struct, too, to be "future-proof" (so in the future we can deprecate dbPath
and just stay with your struct implementation). Food for though.
Once #1033 is merged, you can rebase to ensure we have stricter timeouts for CI jobs, and avoid tests wasting our GHA allowance. |
#1033 is merged. Please rebase this branch before carrying out further tests. Thanks! |
@hudeng-go On my humble LXD image, which I use for development, |
ae5456d
to
1122a66
Compare
improve concurrent access and high availability of aptly with the help of the characteristics of etcd
databaseBackend config contains type and url sub config, It can facilitate the expansion of other types of databases in the future.
Is there any update to bring this patch into upstream? |
Howdy, any chance to get this back on track? |
@randombenj As you seem to be the most active reviewer/contributor for Aptly, could you please review this? |
Hi all, maybe we should rebase this on master first, which seems to be a bit of work.. any chance someone could help with this ? |
Hi all, could aomeone have a look at why the test is running into a timeout in #1284 ? |
improve concurrent access and high availability of aptly with the help of the characteristics of etcd
Fixes #
Requirements
All new code should be covered with tests, documentation should be updated. CI should pass.
Description of the Change
Checklist
AUTHORS