Skip to content
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

Docker failing with compose.yaml #234

Closed
gtyellow opened this issue Jul 16, 2024 · 2 comments · Fixed by #246
Closed

Docker failing with compose.yaml #234

gtyellow opened this issue Jul 16, 2024 · 2 comments · Fixed by #246

Comments

@gtyellow
Copy link

gtyellow commented Jul 16, 2024

I ran 'docker compose up' in terminal and got the following error 'line 11: mapping key "x-common-variables" already defined at line 3'.

I am using the following docker versions:

Client:
 Version:           27.0.3
 API version:       1.46
 Go version:        go1.21.11
 Git commit:        7d4bcd8
 Built:             Fri Jun 28 23:59:41 2024
 OS/Arch:           darwin/amd64
 Context:           desktop-linux

Server: Docker Desktop 4.32.0 (157355)
 Engine:
  Version:          27.0.3
  API version:      1.46 (minimum version 1.24)
  Go version:       go1.21.11
  Git commit:       662f78c
  Built:            Sat Jun 29 00:02:50 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.18
  GitCommit:        ae71819c4f5e67bb4d5ae76a6b735f29cc25774e
 runc:
  Version:          1.7.18
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker compose version v2.28.1-desktop.1

Proposing the following update to compose.yaml:

https://gist.github.com/gtyellow/b73dd59de0d698c688fb67b8dcd10277.js"

@jwmatthews
Copy link
Member

jwmatthews commented Jul 17, 2024

Running on MacOS x86_64

I installed latest Docker Desktop for testing today.

$ docker compose version
Docker Compose version v2.28.1-desktop.1
$ docker version
Client:
 Version:           27.0.3
 API version:       1.46
 Go version:        go1.21.11
 Git commit:        7d4bcd8
 Built:             Fri Jun 28 23:59:41 2024
 OS/Arch:           darwin/amd64
 Context:           desktop-linux

Server: Docker Desktop 4.32.0 (157355)
 Engine:
  Version:          27.0.3
  API version:      1.46 (minimum version 1.24)
  Go version:       go1.21.11
  Git commit:       662f78c
  Built:            Sat Jun 29 00:02:50 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.18
  GitCommit:        ae71819c4f5e67bb4d5ae76a6b735f29cc25774e
 runc:
  Version:          1.7.18
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

$ time docker compose up
yaml: unmarshal errors:
  line 11: mapping key "x-common-variables" already defined at line 3
docker compose up  0.06s user 0.05s system 110% cpu 0.100 total

Then I tried a small piece of @gtyellow's patch:

$ git diff
diff --git a/compose.yaml b/compose.yaml
index d6357a6..b0b2975 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -1,6 +1,6 @@
 version: "3"
 
-x-common-variables: &kai-variables
+x-kai-variables: &kai-variables
   DEMO_MODE: "False"
   HUB_URL: ${HUB_URL:-https://tackle-konveyor-tackle.apps.example.com/hub}
   IMPORTER_ARGS:
@@ -8,7 +8,7 @@ x-common-variables: &kai-variables
   NUM_WORKERS: 8
   USE_HUB_IMPORTER: ${USE_HUB_IMPORTER:-False}
 
-x-common-variables: &db-variables
+x-db-variables: &db-variables
   POSTGRES_DB: kai
   POSTGRES_PASSWORD: dog8code
   POSTGRES_USER: kai


I ran into: docker/compose#10407

Upon upgrading from Docker Compose version 2.16.0 to Docker Compose version 2.17.2 it seems like 2.17 and above dropped support for merging in yaml, ref: https://yaml.org/type/merge.html

$ time docker compose up
yaml: unmarshal errors:
  line 20: mapping key "<<" already defined at line 19
  line 38: mapping key "<<" already defined at line 37
docker compose up  0.06s user 0.04s system 97% cpu 0.104 total

Looks like related to:
docker/compose#10394 (comment)

YAML parsing was improved in v2.17 - the old behavior of allowing multiple merge keys was a quirk of the parser.

However, as @jorgenader mentioned, you can provide multiple anchors in a single merge key.

This is the expected pattern as documented at https://yaml.org/type/merge.html.

Now I'm running with all of @gtyellow patch

diff --git a/compose.yaml b/compose.yaml
index d6357a6..7b17782 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -1,6 +1,6 @@
 version: "3"
 
-x-common-variables: &kai-variables
+x-kai-variables: &kai-variables
   DEMO_MODE: "False"
   HUB_URL: ${HUB_URL:-https://tackle-konveyor-tackle.apps.example.com/hub}
   IMPORTER_ARGS:
@@ -8,7 +8,7 @@ x-common-variables: &kai-variables
   NUM_WORKERS: 8
   USE_HUB_IMPORTER: ${USE_HUB_IMPORTER:-False}
 
-x-common-variables: &db-variables
+x-db-variables: &db-variables
   POSTGRES_DB: kai
   POSTGRES_PASSWORD: dog8code
   POSTGRES_USER: kai
@@ -16,8 +16,7 @@ x-common-variables: &db-variables
 services:
   kai:
     environment:
-      <<: *db-variables
-      <<: *kai-variables
+      <<: [*db-variables, *kai-variables]
       # Do not edit the variables below otherwise
       # you risk committing keys to a public repo
       # These lines will pass in the environment
@@ -34,8 +33,7 @@ services:
       - kai_db
   kai_hub_importer:
     environment:
-      <<: *db-variables
-      <<: *kai-variables
+      <<: [*db-variables, *kai-variables]
       MODE: importer
     image: ${IMAGE:-quay.io/konveyor/kai}:${TAG:-stable}
     volumes:

With above ^^ I see success with docker compose up as:

  • I see the DB come up
  • I see load-data run for a few minutes and store data
  • I see the REST API come up

YET... I see this message repeatedly mentioned:
kai_db-1 | 2024-07-17 15:05:53.171 UTC [634] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:06:03.240 UTC [641] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:06:13.314 UTC [649] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:06:23.382 UTC [656] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:06:33.449 UTC [664] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:06:43.520 UTC [671] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:06:53.588 UTC [679] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:07:03.655 UTC [686] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:07:13.725 UTC [694] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:07:23.797 UTC [701] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:07:33.892 UTC [708] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:07:43.961 UTC [715] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:07:54.033 UTC [723] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:08:04.100 UTC [730] FATAL: role "root" does not exist kai_db-1 | 2024-07-17 15:08:14.175 UTC [738] FATAL: role "root" does not exist ... ...

@jmontleon
Copy link
Member

#236 will remove the health check. I don't see the role error messages with podman, but I suspect the health check is doing this. It's not really being used for anything. Compose does not delay the starting of pods based on health check anymore, which was the original intention of adding it. If this doesn't clear it I'll set up a VM with docker and dig around to see what's causing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants