-
Notifications
You must be signed in to change notification settings - Fork 2
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
use docker compose v2 #163
base: master
Are you sure you want to change the base?
Conversation
docker compose v2 is part of Docker nowadays. Rather than calling a separate Python lib that calls `docker-compose`, call `docker compose` and use v2. Fix the `-` and `_` difference between v1 and v2. This will need THOROUGH testing PFM-827
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 doubt this is going to work as-is. It would be very lucky that all of the features of docker-compose
that kubetools
uses are fully backwards-compatible in docker compose
.
This is why it's only in draft, it still needs a thorough test across all dev machine OSes, architectures and with as many packages/services as possible. |
I'm also seeing
from running |
the old type, `network.external.name` is deprecated on v2. It still works but it may be removed in future. Change to new format. See: docker-archive/compose-cli#1856
this code will only ever be used in this version of the tool, and the `__version__` only checks the version of the _tool_ anyways. Also remove redundant print statements
if we create a container using compose v1 and we want to use or remove it using compose v2, we will need to convert its name to use the new format
there are times where the container name consists of multiple names or a name and then a number; for example, composename-container-name-1-1. We want to keep only `container-name-1`. Ensure this is possible
1591eec
to
b2958d3
Compare
force push because the previous code was weird - it was just to deal with the cases where there was more than one middle name |
we can test this locally using something like |
Use the most logical version number for the next major version of this. This version of Kubetools introduces some unavoidable breaking changes that we can work around. Document these in the README.
add incompatible version of Docker Desktop to CHANGELOG and add more detail to README as to why we need to be careful with this update
I have put this up for a |
suggest migrating to secure Docker registries, reword the suggestion to use the legacy builder Co-authored-by: Germain Chazot <[email protected]>
make the code easier to test by moving the name conversion into its own function and add test coverage also add test coverage for `dockerise_label`
d7f3207
to
b9cc5a4
Compare
force push only to clean up some mistakes I made with linting and syntax 🤦♂️ |
add `TROUBLESHOOTING` section to README to document the issue with `insecure-registries` and link this to ticket which is open and relevant, for `buildx`. remove anything from the CHANGELOG which belongs here
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.
Just realised I had all those comments pending from months ago.
'external': { | ||
'name': 'dev', | ||
}, | ||
'name': 'dev', |
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'm wondering if we should take this opportunity to rename this "default" network used by ktd
.
default
here in the config is from the point of view of the project/container. This declares the default network for the project to be "external" (i.e. pre-existing outside this compose
project) and named dev
.
I think we should replace dev
by something that clearly identifies it as used by ktd
. Maybe ktd_dev
could be an option.
Also, from a few tests I've run, it seems like other "environments" as created with --env
option (or test
in the case of ktd test
), end up with a "temporary" network name (i.e. it's not "external" and IS deleted by the destroy operation) which looks like <appname>_<env>_default
. I think it would be cool if that network name ended up being similarly, something like ktd_<env>
.
This aspect probably requires a lot of work to implement, However it could be the base for a feature allowing to create "multi-app" environments, in a similar way as we can today do with the "default" environment.
If you try and run `ktd up` with reference to an unsecure registry, e.g. `http://docker-registry.example.net` and are affected by this bug, you will get an error message that is | ||
similar to the following: |
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.
If you try and run `ktd up` with reference to an unsecure registry, e.g. `http://docker-registry.example.net` and are affected by this bug, you will get an error message that is | |
similar to the following: | |
If you try and run `ktd up` with reference to an unsecure registry, e.g. `http://docker-registry.example.net` and are affected by this bug, you will get an error message that is similar to the following: |
|
||
|
||
class TestDockerComposeNameConversion(TestCase): | ||
# we need to check this works for dashes and underscores |
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.
# we need to check this works for dashes and underscores |
from kubetools.dev.backends.docker_compose.docker_util import _get_container_name_from_full_name | ||
|
||
|
||
def generate_long_names(number_of_separators, separator): |
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 comment below, this function probably will disappear. But if it had to stay, then it needs to be renamed because it's confusing::
- It is generating ONE name, not (several)
_names
- Why do they have to be "long" ? Is it important for the tests? What would not be tested if the names were "short" ? Note that this aspect of making tests more understandable does not belong in this function's name only, but in how/why the result of it is used in tests.
for i in range(5): | ||
long_name = generate_long_names(i, '-') | ||
dockerised_name = dockerise_label(long_name) | ||
self.assertEqual(dockerised_name, ascii_lowercase[:i+1]) |
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'm not quite sure but I have a feeling that we're using ascii_lowercase
here as a "long string", which "could look like an app name". If that the case, then in my opinion it's a bad idea. It's a case of "wrong abstraction". Instead here we want to use names that could really be what they stand for, so that it's obvious to the reader what we're talking about. Put them in a list and iterate over them. If you're worried about repeating that list too much, extract it in a constant and reuse it in each place.
# if the container was made in v1, it will be composename_container_N | ||
converted_name = full_name.replace('_', '-') |
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.
Just to check, are we trying to create logic that is backwards compatible with compose V2?
I think that, in line with the change to README and with the major version change, we don´t need to support any backwards compatible logic here.
dockerised_name = dockerise_label(long_name) | ||
self.assertEqual(dockerised_name, ascii_lowercase[:i+1]) | ||
|
||
def test_container_name_from_full_name_dashes(self): |
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.
These test names don't explain the scenario that we're testing here.
What are the cases where this logic might be relevant?
docker compose v2 is part of Docker nowadays. Rather than calling a separate Python lib that calls
docker-compose
, calldocker compose
and use v2.Fix the
-
and_
difference between v1 and v2.This will need THOROUGH testing
PFM-827
Purpose of PR
Upgrade to use Docker Compose V2
Parts of the app this will impact
docker compose
Todos
Test on Linux machines, different CI builds with different packages
Additional information
This will require Docker with Compose v2
Related links