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

Replace docker-compose by 'docker compose' #40890

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ The list below covers the major changes between 7.0.0-rc2 and main only.
- Debug log entries from the acker (`stateful ack ...` or `stateless ack ...`) removed. {pull}39672[39672]
- Rename x-pack/filebeat websocket input to streaming. {issue}40264[40264] {pull}40421[40421]
- Journald input now calls `journalctl` instead of using `github.com/coreos/go-systemd/[email protected]/sdjournal`, the CGO dependency has been removed from Filebeat {pull}40061[40061]
- Use Docker Compose V2 (`docker compose`) instead of Compose V1 (`docker-compose`) {pull}40890[40890]

==== Bugfixes

Expand Down
6 changes: 3 additions & 3 deletions dev-tools/mage/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"errors"
"fmt"
"io"
"io/ioutil"

Check failure on line 35 in dev-tools/mage/common.go

View workflow job for this annotation

GitHub Actions / lint (linux)

SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)
"log"
"net/http"
"os"
Expand Down Expand Up @@ -216,12 +216,12 @@
return &info, nil
}

// HaveDockerCompose returns an error if docker-compose is not found on the
// HaveDockerCompose returns an error if docker is not found on the
// PATH.
func HaveDockerCompose() error {
_, err := exec.LookPath("docker-compose")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also make sure that compose plugin is installed by runnigg (docker compose version)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also make sure that compose plugin is installed by runnigg (docker compose version)

What do you mean? Call docker compose version, parse the output and ensure the compose plugin is installed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this makes sense if the plugin is installed separately than docker itself. Otherwise, you are just testing that docker is available here, and not compose.

_, err := exec.LookPath("docker")
if err != nil {
return fmt.Errorf("docker-compose is not available")
return fmt.Errorf("docker is not available")
}
return nil
}
Expand Down Expand Up @@ -283,7 +283,7 @@
func DownloadFile(url, destinationDir string) (string, error) {
log.Println("Downloading", url)

resp, err := http.Get(url)

Check failure on line 286 in dev-tools/mage/common.go

View workflow job for this annotation

GitHub Actions / lint (linux)

G107: Potential HTTP request made with variable url (gosec)
if err != nil {
return "", fmt.Errorf("http get failed: %w", err)
}
Expand Down Expand Up @@ -338,7 +338,7 @@
}
defer innerFile.Close()

path := filepath.Join(destinationDir, f.Name)

Check failure on line 341 in dev-tools/mage/common.go

View workflow job for this annotation

GitHub Actions / lint (linux)

G305: File traversal when extracting zip/tar archive (gosec)
if !strings.HasPrefix(path, destinationDir) {
return fmt.Errorf("illegal file path in zip: %v", f.Name)
}
Expand All @@ -357,7 +357,7 @@
}
defer out.Close()

if _, err = io.Copy(out, innerFile); err != nil {

Check failure on line 360 in dev-tools/mage/common.go

View workflow job for this annotation

GitHub Actions / lint (linux)

G110: Potential DoS vulnerability via decompression bomb (gosec)
return err
}

Expand Down Expand Up @@ -390,7 +390,7 @@
tw := tar.NewWriter(zr)

// walk through every file in the folder
filepath.Walk(src, func(file string, fi os.FileInfo, errFn error) error {

Check failure on line 393 in dev-tools/mage/common.go

View workflow job for this annotation

GitHub Actions / lint (linux)

Error return value of `filepath.Walk` is not checked (errcheck)
if errFn != nil {
return fmt.Errorf("error traversing the file system: %w", errFn)
}
Expand Down Expand Up @@ -477,13 +477,13 @@
for {
header, err := tarReader.Next()
if err != nil {
if err == io.EOF {

Check failure on line 480 in dev-tools/mage/common.go

View workflow job for this annotation

GitHub Actions / lint (linux)

comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
break
}
return err
}

path := filepath.Join(destinationDir, header.Name)

Check failure on line 486 in dev-tools/mage/common.go

View workflow job for this annotation

GitHub Actions / lint (linux)

G305: File traversal when extracting zip/tar archive (gosec)
if !strings.HasPrefix(path, destinationDir) {
return fmt.Errorf("illegal file path in tar: %v", header.Name)
}
Expand All @@ -499,7 +499,7 @@
return err
}

if _, err = io.Copy(writer, tarReader); err != nil {

Check failure on line 502 in dev-tools/mage/common.go

View workflow job for this annotation

GitHub Actions / lint (linux)

G110: Potential DoS vulnerability via decompression bomb (gosec)
return err
}

Expand Down Expand Up @@ -800,7 +800,7 @@

var files []string
for _, s := range sources {
filepath.Walk(s, func(path string, info os.FileInfo, err error) error {

Check failure on line 803 in dev-tools/mage/common.go

View workflow job for this annotation

GitHub Actions / lint (linux)

Error return value of `filepath.Walk` is not checked (errcheck)
if err != nil {
if os.IsNotExist(err) {
return nil
Expand Down Expand Up @@ -896,7 +896,7 @@
matches := parseVersionRegex.FindStringSubmatch(version)
if len(matches) == 0 {
err = fmt.Errorf("failed to parse version '%v'", version)
return

Check failure on line 899 in dev-tools/mage/common.go

View workflow job for this annotation

GitHub Actions / lint (linux)

naked return in func `ParseVersion` with 16 lines of code (nakedret)
}

data := map[string]string{}
Expand Down
20 changes: 10 additions & 10 deletions dev-tools/mage/integtest_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ func (d *DockerIntegrationTester) Test(dir string, mageTarget string, env map[st
composeEnv,
os.Stdout,
os.Stderr,
"docker-compose",
args...,
"docker",
append([]string{"compose"}, args...)...,
)

err = saveDockerComposeLogs(dir, mageTarget)
Expand Down Expand Up @@ -313,8 +313,8 @@ func BuildIntegTestContainers() error {
composeEnv,
out,
os.Stderr,
"docker-compose", args...,
)
"docker",
append([]string{"compose"}, args...)...)

// This sleep is to avoid hitting the docker build issues when resources are not available.
if err != nil {
Expand All @@ -324,8 +324,8 @@ func BuildIntegTestContainers() error {
composeEnv,
out,
os.Stderr,
"docker-compose", args...,
)
"docker",
append([]string{"compose"}, args...)...)
}
return err
}
Expand All @@ -348,8 +348,8 @@ func StartIntegTestContainers() error {
composeEnv,
os.Stdout,
os.Stderr,
"docker-compose",
args...,
"docker",
append([]string{"compose"}, args...)...,
)
return err
}
Expand All @@ -370,7 +370,7 @@ func StopIntegTestContainers() error {
composeEnv,
ioutil.Discard,
out,
"docker-compose",
"docker", "compose",
"-p", DockerComposeProjectName(),
"rm", "--stop", "--force",
)
Expand Down Expand Up @@ -428,7 +428,7 @@ func saveDockerComposeLogs(rootDir string, mageTarget string) error {
composeEnv,
composeLogFile, // stdout
composeLogFile, // stderr
"docker-compose",
"docker", "compose",
"-p", DockerComposeProjectName(),
"logs",
"--no-color",
Expand Down
6 changes: 5 additions & 1 deletion libbeat/tests/compose/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,16 @@ func (d *wrapperDriver) cmd(ctx context.Context, command string, arg ...string)
}
args = append(args, command)
args = append(args, arg...)
cmd := exec.CommandContext(ctx, "docker-compose", args...)
cmd := exec.CommandContext(ctx, "docker", append([]string{"compose"}, args...)...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if len(d.Environment) > 0 {
cmd.Env = append(os.Environ(), d.Environment...)
}

// Debug message
fmt.Println(">>>>", "docker", strings.Join(append([]string{"compose"}, args...), " "))

return cmd
}

Expand Down
2 changes: 1 addition & 1 deletion testing/environments/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ENV?=snapshot.yml
BASE_COMMAND=docker-compose -f ${ENV} -f local.yml
BASE_COMMAND=docker compose -f ${ENV} -f local.yml

start:
# This is run every time to make sure the environment is up-to-date
Expand Down
2 changes: 1 addition & 1 deletion x-pack/winlogbeat/module/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func testIngestPipeline(t *testing.T, pipeline, pattern string, p *params) {
t.Fatal(err)
}
if *wintest.KeepRunning {
fmt.Fprintln(os.Stdout, "Use this to manually cleanup containers: docker-compose", "-p", devtools.DockerComposeProjectName(), "rm", "--stop", "--force")
fmt.Fprintln(os.Stdout, "Use this to manually cleanup containers: docker compose", "-p", devtools.DockerComposeProjectName(), "rm", "--stop", "--force")
}
t.Cleanup(func() {
stop := !*wintest.KeepRunning
Expand Down
5 changes: 3 additions & 2 deletions x-pack/winlogbeat/module/wintest/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func saveLogs(env map[string]string, root, target string) error {
env,
f, // stdout
f, // stderr
"docker-compose",
"docker", "compose",
"-p", devtools.DockerComposeProjectName(),
"logs",
"--no-color",
Expand Down Expand Up @@ -140,7 +140,8 @@ func dockerCompose(env map[string]string, verbose bool) error {
env,
out,
os.Stderr,
"docker-compose", args...,
"docker",
append([]string{"compose"}, args...)...,
)
if err == nil {
break
Expand Down
2 changes: 1 addition & 1 deletion x-pack/winlogbeat/module/wintest/simulate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestSimulate(t *testing.T) {
t.Fatal(err)
}
if *wintest.KeepRunning {
fmt.Fprintln(os.Stdout, "docker-compose", "-p", devtools.DockerComposeProjectName(), "rm", "--stop", "--force")
fmt.Fprintln(os.Stdout, "docker compose", "-p", devtools.DockerComposeProjectName(), "rm", "--stop", "--force")
}
t.Cleanup(func() {
stop := !*wintest.KeepRunning
Expand Down
Loading