Skip to content

Commit 580f0f6

Browse files
leehinmanbelimawr
andauthored
fix templates and docs to use correct -- command line args (#42060)
* fix templates and docs to use correct `--` command line args Co-authored-by: Tiago Queiroz <me@tiago.life>
1 parent 1430cfd commit 580f0f6

File tree

18 files changed

+138
-31
lines changed

18 files changed

+138
-31
lines changed

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
1717
- Drop support for Debian 10 and upgrade statically linked glibc from 2.28 to 2.31 {pull}41402[41402]
1818
- Fix metrics not being ingested, due to "Limit of total fields [10000] has been exceeded while adding new fields [...]". The total fields limit has been increased to 12500. No significant performance impact on Elasticsearch is anticipated. {pull}41640[41640]
1919
- Set default kafka version to 2.1.0 in kafka output and filebeat. {pull}41662[41662]
20+
- Fix templates and docs to use correct `--` version of command line arguments. {issue}42038[42038] {pull}42060[42060]
2021

2122
*Auditbeat*
2223

deploy/kubernetes/metricbeat-kubernetes.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ spec:
295295
args: [
296296
"-c", "/etc/metricbeat.yml",
297297
"-e",
298-
"-system.hostfs=/hostfs",
298+
"--system.hostfs=/hostfs",
299299
]
300300
env:
301301
- name: ELASTICSEARCH_HOST

deploy/kubernetes/metricbeat/metricbeat-daemonset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
args: [
2626
"-c", "/etc/metricbeat.yml",
2727
"-e",
28-
"-system.hostfs=/hostfs",
28+
"--system.hostfs=/hostfs",
2929
]
3030
env:
3131
- name: ELASTICSEARCH_HOST

dev-tools/kubernetes/metricbeat/manifest.debug.multi.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ spec:
298298
args: [
299299
"-c", "/etc/metricbeat.yml",
300300
"-e",
301-
"-system.hostfs=/hostfs",
301+
"--system.hostfs=/hostfs",
302302
]
303303
env:
304304
- name: ELASTICSEARCH_HOST
@@ -403,7 +403,7 @@ spec:
403403
args: [
404404
"-c", "/etc/metricbeat.yml",
405405
"-e",
406-
"-system.hostfs=/hostfs",
406+
"--system.hostfs=/hostfs",
407407
]
408408
ports:
409409
- containerPort: 56268

dev-tools/kubernetes/metricbeat/manifest.debug.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ spec:
298298
args: [
299299
"-c", "/etc/metricbeat.yml",
300300
"-e",
301-
"-system.hostfs=/hostfs",
301+
"--system.hostfs=/hostfs",
302302
]
303303
ports:
304304
- containerPort: 56268

dev-tools/kubernetes/metricbeat/manifest.run.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ spec:
298298
args: [
299299
"-c", "/etc/metricbeat.yml",
300300
"-e",
301-
"-system.hostfs=/hostfs",
301+
"--system.hostfs=/hostfs",
302302
]
303303
env:
304304
- name: ELASTICSEARCH_HOST

dev-tools/mage/pkg.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ func prepareIronbankBuild() error {
172172
}
173173
return nil
174174
})
175-
176175
if err != nil {
177176
return fmt.Errorf("cannot create templates for the IronBank: %w", err)
178177
}
@@ -206,7 +205,7 @@ func saveIronbank() error {
206205

207206
distributionsDir := "build/distributions"
208207
if _, err := os.Stat(distributionsDir); os.IsNotExist(err) {
209-
err := os.MkdirAll(distributionsDir, 0750)
208+
err := os.MkdirAll(distributionsDir, 0o750)
210209
if err != nil {
211210
return fmt.Errorf("cannot create folder for docker artifacts: %w", err)
212211
}
@@ -348,9 +347,7 @@ func TestPackages(options ...TestPackagesOption) error {
348347
args = append(args, "-files", MustExpand("{{.PWD}}/build/distributions/*"))
349348

350349
if out, err := goTest(args...); err != nil {
351-
if !mg.Verbose() {
352-
fmt.Println(out)
353-
}
350+
fmt.Println(out)
354351
return err
355352
}
356353

dev-tools/packaging/package_test.go

Lines changed: 119 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ import (
2626
"bufio"
2727
"bytes"
2828
"compress/gzip"
29+
"context"
2930
"encoding/json"
31+
"errors"
3032
"flag"
3133
"fmt"
3234
"io"
@@ -36,18 +38,20 @@ import (
3638
"slices"
3739
"strings"
3840
"testing"
39-
40-
"errors"
41+
"time"
4142

4243
"github.com/blakesmith/ar"
4344
rpm "github.com/cavaliergopher/rpm"
45+
"github.com/docker/docker/api/types/container"
46+
"github.com/docker/docker/api/types/strslice"
47+
"github.com/docker/docker/client"
4448
)
4549

4650
const (
47-
expectedConfigMode = os.FileMode(0600)
48-
expectedManifestMode = os.FileMode(0644)
51+
expectedConfigMode = os.FileMode(0o600)
52+
expectedManifestMode = os.FileMode(0o644)
4953
expectedModuleFileMode = expectedManifestMode
50-
expectedModuleDirMode = os.FileMode(0755)
54+
expectedModuleDirMode = os.FileMode(0o755)
5155
)
5256

5357
var (
@@ -234,15 +238,15 @@ func checkDocker(t *testing.T, file string) {
234238
t.Errorf("error reading file %v: %v", file, err)
235239
return
236240
}
237-
238241
checkDockerEntryPoint(t, p, info)
239242
checkDockerLabels(t, p, info, file)
240243
checkDockerUser(t, p, info, *rootUserContainer)
241-
checkConfigPermissionsWithMode(t, p, os.FileMode(0644))
242-
checkManifestPermissionsWithMode(t, p, os.FileMode(0644))
244+
checkConfigPermissionsWithMode(t, p, os.FileMode(0o644))
245+
checkManifestPermissionsWithMode(t, p, os.FileMode(0o644))
243246
checkModulesPresent(t, "", p)
244247
checkModulesDPresent(t, "", p)
245248
checkLicensesPresent(t, "licenses/", p)
249+
checkDockerImageRun(t, p, file)
246250
}
247251

248252
// Verify that the main configuration file is installed with a 0600 file mode.
@@ -356,7 +360,7 @@ func checkModulesOwner(t *testing.T, p *packageFile, expectRoot bool) {
356360
// Verify that the systemd unit file has a mode of 0644. It should not be
357361
// executable.
358362
func checkSystemdUnitPermissions(t *testing.T, p *packageFile) {
359-
const expectedMode = os.FileMode(0644)
363+
const expectedMode = os.FileMode(0o644)
360364
t.Run(p.Name+" systemd unit file permissions", func(t *testing.T) {
361365
for _, entry := range p.Contents {
362366
if systemdUnitFilePattern.MatchString(entry.File) {
@@ -443,7 +447,7 @@ func checkLicensesPresent(t *testing.T, prefix string, p *packageFile) {
443447
}
444448

445449
func checkDockerEntryPoint(t *testing.T, p *packageFile, info *dockerInfo) {
446-
expectedMode := os.FileMode(0755)
450+
expectedMode := os.FileMode(0o755)
447451

448452
t.Run(fmt.Sprintf("%s entrypoint", p.Name), func(t *testing.T) {
449453
if len(info.Config.Entrypoint) == 0 {
@@ -511,6 +515,111 @@ func checkDockerUser(t *testing.T, p *packageFile, info *dockerInfo, expectRoot
511515
})
512516
}
513517

518+
func checkDockerImageRun(t *testing.T, p *packageFile, imagePath string) {
519+
t.Run(fmt.Sprintf("%s check docker images runs", p.Name), func(t *testing.T) {
520+
var ctx context.Context
521+
dl, ok := t.Deadline()
522+
if !ok {
523+
ctx = context.Background()
524+
} else {
525+
c, cancel := context.WithDeadline(context.Background(), dl)
526+
ctx = c
527+
defer cancel()
528+
}
529+
f, err := os.Open(imagePath)
530+
if err != nil {
531+
t.Fatalf("failed to open docker image %q: %s", imagePath, err)
532+
}
533+
defer f.Close()
534+
535+
c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
536+
if err != nil {
537+
t.Fatalf("failed to get a Docker client: %s", err)
538+
}
539+
540+
loadResp, err := c.ImageLoad(ctx, f, true)
541+
if err != nil {
542+
t.Fatalf("error loading docker image: %s", err)
543+
}
544+
545+
loadRespBody, err := io.ReadAll(loadResp.Body)
546+
if err != nil {
547+
t.Fatalf("failed to read image load response: %s", err)
548+
}
549+
loadResp.Body.Close()
550+
551+
_, after, found := strings.Cut(string(loadRespBody), "Loaded image: ")
552+
if !found {
553+
t.Fatalf("image load response was unexpected: %s", string(loadRespBody))
554+
}
555+
imageId := strings.TrimRight(after, "\\n\"}\r\n")
556+
557+
var caps strslice.StrSlice
558+
if strings.Contains(imageId, "packetbeat") {
559+
caps = append(caps, "NET_ADMIN")
560+
}
561+
562+
createResp, err := c.ContainerCreate(ctx,
563+
&container.Config{
564+
Image: imageId,
565+
},
566+
&container.HostConfig{
567+
CapAdd: caps,
568+
},
569+
nil,
570+
nil,
571+
"")
572+
if err != nil {
573+
t.Fatalf("error creating container from image: %s", err)
574+
}
575+
defer func() {
576+
err := c.ContainerRemove(ctx, createResp.ID, container.RemoveOptions{Force: true})
577+
if err != nil {
578+
t.Errorf("error removing container: %s", err)
579+
}
580+
}()
581+
582+
err = c.ContainerStart(ctx, createResp.ID, container.StartOptions{})
583+
if err != nil {
584+
t.Fatalf("failed to start container: %s", err)
585+
}
586+
defer func() {
587+
err := c.ContainerStop(ctx, createResp.ID, container.StopOptions{})
588+
if err != nil {
589+
t.Errorf("error stopping container: %s", err)
590+
}
591+
}()
592+
593+
timer := time.NewTimer(15 * time.Second)
594+
defer timer.Stop()
595+
ticker := time.NewTicker(2 * time.Second)
596+
defer ticker.Stop()
597+
598+
var logs []byte
599+
sentinelLog := "Beat ID: "
600+
for {
601+
select {
602+
case <-timer.C:
603+
t.Fatalf("never saw %q within timeout\nlogs:\n%s", sentinelLog, string(logs))
604+
return
605+
case <-ticker.C:
606+
out, err := c.ContainerLogs(ctx, createResp.ID, container.LogsOptions{ShowStdout: true, ShowStderr: true})
607+
if err != nil {
608+
t.Logf("could not get logs: %s", err)
609+
}
610+
logs, err = io.ReadAll(out)
611+
out.Close()
612+
if err != nil {
613+
t.Logf("error reading logs: %s", err)
614+
}
615+
if bytes.Contains(logs, []byte(sentinelLog)) {
616+
return
617+
}
618+
}
619+
}
620+
})
621+
}
622+
514623
// ensureNoBuildIDLinks checks for regressions related to
515624
// https://github.com/elastic/beats/issues/12956.
516625
func ensureNoBuildIDLinks(t *testing.T, p *packageFile) {

dev-tools/packaging/templates/docker/Dockerfile.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,4 @@ ENV LIBBEAT_MONITORING_CGROUPS_HIERARCHY_OVERRIDE=/
244244

245245
WORKDIR {{ $beatHome }}
246246
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-entrypoint"]
247-
CMD ["-environment", "container"]
247+
CMD ["--environment", "container"]

dev-tools/packaging/templates/ironbank/auditbeat/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ ENV ELASTIC_PRODUCT=${ELASTIC_PRODUCT}
8080

8181
# TODO: eventually /tinit will be replaced by /usr/bin/tini
8282
ENTRYPOINT ["/tinit", "--", "/usr/share/auditbeat/auditbeat", "-E", "http.enabled=true", "-E", "http.host=unix:///usr/share/auditbeat/data/auditbeat.sock"]
83-
CMD ["-environment", "container"]
83+
CMD ["--environment", "container"]
8484

8585
# see https://www.elastic.co/guide/en/beats/auditbeat/current/http-endpoint.html
8686
HEALTHCHECK --interval=10s --timeout=5s --start-period=1m --retries=5 CMD curl -I -f --max-time 5 --unix-socket '/usr/share/auditbeat/data/auditbeat.sock' 'http:/stats?pretty'

dev-tools/packaging/templates/ironbank/filebeat/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ ENV ELASTIC_PRODUCT=${ELASTIC_PRODUCT}
8080

8181
# TODO: eventually /tinit will be replaced by /usr/bin/tini
8282
ENTRYPOINT ["/tinit", "--", "/usr/share/filebeat/filebeat", "-E", "http.enabled=true", "-E", "http.host=unix:///usr/share/filebeat/data/filebeat.sock"]
83-
CMD ["-environment", "container"]
83+
CMD ["--environment", "container"]
8484

8585
# see https://www.elastic.co/guide/en/beats/filebeat/current/http-endpoint.html
8686
HEALTHCHECK --interval=10s --timeout=5s --start-period=1m --retries=5 CMD curl -I -f --max-time 5 --unix-socket '/usr/share/filebeat/data/filebeat.sock' 'http:/stats/?pretty'

dev-tools/packaging/templates/ironbank/heartbeat/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ ENV ELASTIC_PRODUCT=${ELASTIC_PRODUCT}
8080

8181
# TODO: eventually /tinit will be replaced by /usr/bin/tini
8282
ENTRYPOINT ["/tinit", "--", "/usr/share/heartbeat/heartbeat", "-E", "http.enabled=true", "-E", "http.host=unix:///usr/share/heartbeat/data/heartbeat.sock"]
83-
CMD ["-environment", "container"]
83+
CMD ["--environment", "container"]
8484

8585
# see https://www.elastic.co/guide/en/beats/heartbeat/current/http-endpoint.html
8686
HEALTHCHECK --interval=10s --timeout=5s --start-period=1m --retries=5 CMD curl -I -f --max-time 5 --unix-socket '/usr/share/heartbeat/data/heartbeat.sock' 'http:/stats/?pretty'

dev-tools/packaging/templates/ironbank/metricbeat/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ENV ELASTIC_PRODUCT=${ELASTIC_PRODUCT}
8181

8282
# TODO: eventually /tinit will be replaced by /usr/bin/tini
8383
ENTRYPOINT ["/tinit", "--", "/usr/share/metricbeat/metricbeat", "-E", "http.enabled=true", "-E", "http.host=unix:///usr/share/metricbeat/data/metricbeat.sock"]
84-
CMD ["-environment", "container"]
84+
CMD ["--environment", "container"]
8585

8686
# see https://www.elastic.co/guide/en/beats/metricbeat/current/http-endpoint.html
8787
HEALTHCHECK --interval=10s --timeout=5s --start-period=1m --retries=5 CMD curl -I -f --max-time 5 --unix-socket '/usr/share/metricbeat/data/metricbeat.sock' 'http:/stats/?pretty'

dev-tools/packaging/templates/ironbank/packetbeat/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ENV ELASTIC_PRODUCT=${ELASTIC_PRODUCT}
8282

8383
# TODO: eventually /tinit will be replaced by /usr/bin/tini
8484
ENTRYPOINT ["/tinit", "--", "/usr/share/packetbeat/packetbeat", "-E", "http.enabled=true", "-E", "http.host=unix:///usr/share/packetbeat/data/packetbeat.sock"]
85-
CMD ["-environment", "container"]
85+
CMD ["--environment", "container"]
8686

8787
# see https://www.elastic.co/guide/en/beats/packetbeat/current/http-endpoint.html
8888
HEALTHCHECK --interval=10s --timeout=5s --start-period=1m --retries=5 CMD curl -I -f --max-time 5 --unix-socket '/usr/share/packetbeat/data/packetbeat.sock' 'http:/stats/?pretty'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/etc/init.d/metricbeat start
22
cd /filebeat
3-
./filebeat -httpprof :6060
3+
./filebeat --httpprof :6060

libbeat/docs/command-reference.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ messages.
926926
*`-e, --e`*::
927927
Logs to stderr and disables syslog/file output.
928928

929-
*`-environment`*::
929+
*`--environment`*::
930930
For logging purposes, specifies the environment that {beatname_uc} is running in.
931931
This setting is used to select a default log output when no log output is configured.
932932
Supported values are: `systemd`, `container`, `macos_service`, and `windows_service`.

metricbeat/docs/running-on-docker.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ docker run \
2222
--env DBUS_SYSTEM_BUS_ADDRESS='unix:path=/hostfs/var/run/dbus/system_bus_socket' \ <4>
2323
--net=host \ <5>
2424
--cgroupns=host \ <6>
25-
{dockerimage} -e -system.hostfs=/hostfs
25+
{dockerimage} -e --system.hostfs=/hostfs
2626
----
2727

2828
<1> Metricbeat's <<metricbeat-module-system,system module>> collects much of its data through the Linux proc

metricbeat/module/kubernetes/_meta/remote-debugger/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ containers:
7272
args: [
7373
"-c", "/etc/metricbeat.yml",
7474
"-e",
75-
"-system.hostfs=/hostfs",
75+
"--system.hostfs=/hostfs",
7676
]
7777
ports:
7878
- containerPort: 56268

0 commit comments

Comments
 (0)