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

[BUG] Test :test:fixtures:azure-fixture:composeBuild fails due to invalid reference format #16839

Open
ArranDengate-Netapp opened this issue Dec 12, 2024 · 0 comments
Labels
bug Something isn't working Build Build Tasks/Gradle Plugin, groovy scripts, build tools, Javadoc enforcement. untriaged

Comments

@ArranDengate-Netapp
Copy link

Describe the bug

I encounter a failure when I run tests:

./gradlew test
(...lots of output...)
> Task :test:fixtures:azure-fixture:composeBuild FAILED
time="2024-12-05T10:29:45+11:00" level=warning msg="buildx: failed to get git commit: "
invalid tag "8a6d57b53415578aaf23306eab866aac_azure-fixture_-azure-fixture-other": invalid reference format

If I run with haltonfailure=false, the following tasks fail:

  • :test:fixtures:azure-fixture:composeBuild
  • :test:fixtures:gcs-fixture:composeBuild
  • :test:fixtures:krb5kdc-fixture:composeBuild

Debug logs (eg from ./gradlew :test:fixtures:azure-fixture:composeBuild) show that a particular docker-compose command is failing:

2024-12-05T11:12:52.188+1100 [INFO] [org.gradle.process.internal.DefaultExecHandle] Starting process 'command 'docker''. Working directory: /Users/arrandengate/src/OpenSearch/test/fixtures/azure-fixture Command: docker compose -f docker-compose.yml --ansi never -p 8a6d57b53415578aaf23306eab866aac_azure-fixture_ build

I am able to reproduce the issue by running that command by itself.

arrandengate@arran-mac-0 azure-fixture % cd /Users/arrandengate/src/OpenSearch/test/fixtures/azure-fixture
arrandengate@arran-mac-0 azure-fixture % docker compose -f docker-compose.yml --ansi never -p 8a6d57b53415578aaf23306eab866aac_azure-fixture_ build
[+] Building 0.0s (0/0)                                                                                                                                                                          docker:desktop-linux
invalid tag "8a6d57b53415578aaf23306eab866aac_azure-fixture_-azure-fixture-other": invalid reference format

It is caused by an invalid project name provided to docker-compose with the -p flag. (It seems like the project name can't end with an underscore, or contain a hyphen followed by an underscore. I've seen project names like both 8a6d57b53415578aaf23306eab866aac_azure-fixture_-azure-fixture-other and 8a6d57b53415578aaf23306eab866aac_azure-fixture_ passed into docker-compose in the failing tests.)

In our code, it seems that this project name isn't specified directly - it is constructed by the Gradle docker-compose plugin.

The plugin has existing Github issues for this problem:

How can the problem be fixed?

We could upgrade to the version of the gradle docker compose plugin where this issue is fixed. We are currently on 0.17.6. We would need to upgrade to at least 0.17.10.

Alternatively, there is a workaround mentioned in avast/gradle-docker-compose-plugin#404 - we could set a nested name in the docker compose gradle plugin.

I tried this and it seems to work - eg, if I add the following to test/fixtures/azure-fixture/build.gradle, the test succeeds:

dockerCompose {
    nestedName = "fixture"
}

The value of the nestedName could be anything, it doesn't matter. To my understanding, the problem is caused by the plugin generating project names that use hyphens and underscores as separators. These characters are legal, but they cannot be adjacent to each other, or at the end. Adding another component to the name means the project name won't have these characters in illegal positions.

Related component

Build

To Reproduce

Run the following:
./gradlew :test:fixtures:azure-fixture:composeBuild

Expected behavior

The test should succeed.

Additional Details

I encountered this issue under the following conditions:

OS: OSX Sonoma 14.7.1
JDK: Temurin 21.0.5 (tried several others)
OpenSearch: 2.18.0 (tried also 2.10.0)
docker-compose: v2.22.0-desktop.2
Gradle: 8.10.2

@ArranDengate-Netapp ArranDengate-Netapp added bug Something isn't working untriaged labels Dec 12, 2024
@github-actions github-actions bot added the Build Build Tasks/Gradle Plugin, groovy scripts, build tools, Javadoc enforcement. label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Build Build Tasks/Gradle Plugin, groovy scripts, build tools, Javadoc enforcement. untriaged
Projects
None yet
Development

No branches or pull requests

1 participant