-
Notifications
You must be signed in to change notification settings - Fork 129
stack status cmd - add columns for image build date and VCS reference #2057
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
stack status cmd - add columns for image build date and VCS reference #2057
Conversation
4eceda3 to
580af78
Compare
When dealing with snapshot builds that are constantly updated, it's difficult to know what build of a service is really running. When viewing historic build logs from CI this information is important to know. This adds information about the service to the output of `elastic-package stack status`. The data is read from http://label-schema.org/rc1/ labels. It uses the org.label-schema.build-date and org.label-schema.vcs-ref labels. ``` BEFORE: ╭──────────────────┬─────────────────┬─────────────────────╮ │ SERVICE │ VERSION │ STATUS │ ├──────────────────┼─────────────────┼─────────────────────┤ │ elastic-agent │ 8.16.0-SNAPSHOT │ running (unhealthy) │ │ elasticsearch │ 8.16.0-SNAPSHOT │ running (healthy) │ │ fleet-server │ 8.16.0-SNAPSHOT │ running (healthy) │ │ kibana │ 8.16.0-SNAPSHOT │ running (healthy) │ │ package-registry │ latest │ running (healthy) │ ╰──────────────────┴─────────────────┴─────────────────────╯ ``` ``` AFTER: ╭──────────────────┬─────────────────┬─────────────────────┬───────────────────┬────────────╮ │ SERVICE │ VERSION │ STATUS │ IMAGE BUILD DATE │ VCS REF │ ├──────────────────┼─────────────────┼─────────────────────┼───────────────────┼────────────┤ │ elastic-agent │ 8.16.0-SNAPSHOT │ running (unhealthy) │ 2024-08-22T02:44Z │ b96a4ca8fa │ │ elasticsearch │ 8.16.0-SNAPSHOT │ running (healthy) │ 2024-08-22T13:26Z │ 1362d56865 │ │ fleet-server │ 8.16.0-SNAPSHOT │ running (healthy) │ 2024-08-22T02:44Z │ b96a4ca8fa │ │ kibana │ 8.16.0-SNAPSHOT │ running (healthy) │ 2024-08-22T11:09Z │ cdcdfddd3f │ │ package-registry │ latest │ running (healthy) │ │ │ ╰──────────────────┴─────────────────┴─────────────────────┴───────────────────┴────────────╯ ```
ce0cbeb to
ff8b012
Compare
cmd/stack.go
Outdated
|
|
||
| for _, service := range servicesStatus { | ||
| t.AppendRow(table.Row{service.Name, service.Version, service.Status}) | ||
| t.AppendRow(table.Row{service.Name, service.Version, service.Status, formatTime(service.Labels.BuildDate), truncate(service.Labels.VCSRef, 10)}) |
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.
When creating a serverless project, there are no local containers at least for elasticsearch, kibana and fleet. For that scenario, service.Labels field is nil.
Here there is an example of the panic error that it is raised because of that:
$ elastic-package stack status
2024/09/19 17:21:03 WARN Elastic Serverless provider is in technical preview
Status of Elastic stack services:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x3516bd3]
goroutine 1 [running]:
github.com/elastic/elastic-package/cmd.printStatus(0xc000546c08, {0xc0008fc460, 0x4, 0x0?})
/home/mariorodriguez/Coding/work/elastic-package-stack-status-vcs-ref/cmd/stack.go:357 +0x233
github.com/elastic/elastic-package/cmd.setupStackCommand.func6(0xc000546c08, {0x5ba26a0?, 0x0?, 0x0?})
/home/mariorodriguez/Coding/work/elastic-package-stack-status-vcs-ref/cmd/stack.go:299 +0x167
github.com/spf13/cobra.(*Command).execute(0xc000546c08, {0x5ba26a0, 0x0, 0x0})
/home/mariorodriguez/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc00054af08)
/home/mariorodriguez/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0xc000078008?)
/home/mariorodriguez/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041 +0x13
main.main()
/home/mariorodriguez/Coding/work/elastic-package-stack-status-vcs-ref/main.go:26 +0x66
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.
This would be an example of that command with one of the latest elastic-package versions:
$ elastic-package stack status
2024/09/19 17:36:22 WARN Elastic Serverless provider is in technical preview
Status of Elastic stack services:
╭───────────────┬────────────────────────────┬───────────────────╮
│ SERVICE │ VERSION │ STATUS │
├───────────────┼────────────────────────────┼───────────────────┤
│ elasticsearch │ serverless (observability) │ healthy │
│ kibana │ serverless (observability) │ healthy │
│ fleet │ serverless (observability) │ healthy │
│ elastic-agent │ 8.15.0 │ running (healthy) │
╰───────────────┴────────────────────────────┴───────────────────╯
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.
Addressed in d3eaa74.
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.
Thanks!
Just checked using other providers like Serverless and Environment, and it worked successfully
$ elastic-package stack status
2025/11/14 10:32:11 WARN Elastic Serverless provider is in technical preview
Status of Elastic stack services:
╭───────────────┬────────────────────────────┬───────────────────┬───────────────────┬────────────╮
│ SERVICE │ VERSION │ STATUS │ IMAGE BUILD DATE │ VCS REF │
├───────────────┼────────────────────────────┼───────────────────┼───────────────────┼────────────┤
│ fleet │ serverless (observability) │ healthy │ │ │
│ elasticsearch │ serverless (observability) │ healthy │ │ │
│ kibana │ serverless (observability) │ healthy │ │ │
│ elastic-agent │ 9.2.1 │ running (healthy) │ 2025-11-07T09:16Z │ db3bfa212a │
╰───────────────┴────────────────────────────┴───────────────────┴───────────────────┴────────────╯
$ elastic-package stack status
Status of Elastic stack services:
╭───────────────┬────────────────┬───────────────────┬───────────────────┬────────────╮
│ SERVICE │ VERSION │ STATUS │ IMAGE BUILD DATE │ VCS REF │
├───────────────┼────────────────┼───────────────────┼───────────────────┼────────────┤
│ elasticsearch │ 9.3.0-SNAPSHOT │ healthy │ │ │
│ kibana │ 9.3.0 │ healthy │ │ │
│ elastic-agent │ 9.2.1 │ running (healthy) │ 2025-11-07T09:16Z │ db3bfa212a │
│ fleet-server │ 9.2.1 │ running (healthy) │ 2025-11-07T09:16Z │ db3bfa212a │
╰───────────────┴────────────────┴───────────────────┴───────────────────┴────────────╯
713f825 to
ff8b012
Compare
…-vcs-ref Resolved conflicts by: - Keeping the new "Image Build Date" and "VCS Ref" columns in stack status output - Adopting the new tablewriter implementation from main - Updating test expectations to include EXPECTED_AGENT_VERSION variable
When creating a serverless project, there are no local containers
for elasticsearch, kibana and fleet. For that scenario, the
service.Labels field is nil.
This commit adds a nil check before accessing service.Labels.BuildDate
and service.Labels.VCSRef to prevent a panic in serverless environments.
When Labels is nil, empty strings are used for both the build date
and VCS ref columns.
Fixes the panic:
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x3516bd3]
goroutine 1 [running]:
github.com/elastic/elastic-package/cmd.printStatus(0xc000546c08, {0xc0008fc460, 0x4, 0x0?})
/home/mariorodriguez/Coding/work/elastic-package-stack-status-vcs-ref/cmd/stack.go:357 +0x233
```
|
/test |
1 similar comment
|
/test |
💚 Build Succeeded
History
|
mrodm
left a comment
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.
👍
| # This removes the 'IMAGE BUILD DATE" and 'VCS REF' columns and | ||
| # removes the whitespace between columns. | ||
| grep "│" "${output_file}" \ | ||
| | sed 's/│/|/g' \ | ||
| | cut -d '|' -f 1-4,7- \ | ||
| | tr -d ' ' |
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.
This looks good 👍
Before:
│SERVICE│VERSION│STATUS│
│elastic-agent│9.3.0-6f40f4f1-SNAPSHOT│running(healthy)│
│elasticsearch│9.3.0-6f40f4f1-SNAPSHOT│running(healthy)│
│fleet-server│9.3.0-6f40f4f1-SNAPSHOT│running(healthy)│
│kibana│9.3.0-6f40f4f1-SNAPSHOT│running(healthy)│
│package-registry│latest│running(healthy)│
Now:
|SERVICE|VERSION|STATUS|
|elastic-agent|9.3.0-6f40f4f1-SNAPSHOT|running(healthy)|
|elasticsearch|9.3.0-6f40f4f1-SNAPSHOT|running(healthy)|
|fleet-server|9.3.0-6f40f4f1-SNAPSHOT|running(healthy)|
|kibana|9.3.0-6f40f4f1-SNAPSHOT|running(healthy)|
|package-registry|latest|running(healthy)|
cmd/stack.go
Outdated
|
|
||
| for _, service := range servicesStatus { | ||
| t.AppendRow(table.Row{service.Name, service.Version, service.Status}) | ||
| t.AppendRow(table.Row{service.Name, service.Version, service.Status, formatTime(service.Labels.BuildDate), truncate(service.Labels.VCSRef, 10)}) |
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.
Thanks!
Just checked using other providers like Serverless and Environment, and it worked successfully
$ elastic-package stack status
2025/11/14 10:32:11 WARN Elastic Serverless provider is in technical preview
Status of Elastic stack services:
╭───────────────┬────────────────────────────┬───────────────────┬───────────────────┬────────────╮
│ SERVICE │ VERSION │ STATUS │ IMAGE BUILD DATE │ VCS REF │
├───────────────┼────────────────────────────┼───────────────────┼───────────────────┼────────────┤
│ fleet │ serverless (observability) │ healthy │ │ │
│ elasticsearch │ serverless (observability) │ healthy │ │ │
│ kibana │ serverless (observability) │ healthy │ │ │
│ elastic-agent │ 9.2.1 │ running (healthy) │ 2025-11-07T09:16Z │ db3bfa212a │
╰───────────────┴────────────────────────────┴───────────────────┴───────────────────┴────────────╯
$ elastic-package stack status
Status of Elastic stack services:
╭───────────────┬────────────────┬───────────────────┬───────────────────┬────────────╮
│ SERVICE │ VERSION │ STATUS │ IMAGE BUILD DATE │ VCS REF │
├───────────────┼────────────────┼───────────────────┼───────────────────┼────────────┤
│ elasticsearch │ 9.3.0-SNAPSHOT │ healthy │ │ │
│ kibana │ 9.3.0 │ healthy │ │ │
│ elastic-agent │ 9.2.1 │ running (healthy) │ 2025-11-07T09:16Z │ db3bfa212a │
│ fleet-server │ 9.2.1 │ running (healthy) │ 2025-11-07T09:16Z │ db3bfa212a │
╰───────────────┴────────────────┴───────────────────┴───────────────────┴────────────╯
When dealing with snapshot builds that are constantly updated, it's difficult to know what build of a service is really running. When viewing historic build logs from CI this information is important to know.
This adds information about the service to the output of
elastic-package stack status. The data is read from http://label-schema.org/rc1/ labels. It uses the org.label-schema.build-date and org.label-schema.vcs-ref labels.