Skip to content

Conversation

@andrewkroh
Copy link
Member

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)   │                   │            │
╰──────────────────┴─────────────────┴─────────────────────┴───────────────────┴────────────╯

@andrewkroh andrewkroh added the enhancement New feature or request label Aug 29, 2024
@andrewkroh andrewkroh force-pushed the feature/stack-status-vcs-ref branch from 4eceda3 to 580af78 Compare August 29, 2024 17:35
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)   │                   │            │
╰──────────────────┴─────────────────┴─────────────────────┴───────────────────┴────────────╯
```
@andrewkroh andrewkroh force-pushed the feature/stack-status-vcs-ref branch from ce0cbeb to ff8b012 Compare August 29, 2024 19:31
@andrewkroh andrewkroh marked this pull request as ready for review August 29, 2024 20:24
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)})
Copy link
Contributor

@mrodm mrodm Sep 19, 2024

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

Copy link
Contributor

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) │
╰───────────────┴────────────────────────────┴───────────────────╯

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in d3eaa74.

Copy link
Contributor

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 │
╰───────────────┴────────────────┴───────────────────┴───────────────────┴────────────╯

@mrodm mrodm requested a review from a team September 19, 2024 15:28
@andrewkroh andrewkroh force-pushed the feature/stack-status-vcs-ref branch from 713f825 to ff8b012 Compare November 12, 2025 13:35
…-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
```
@andrewkroh
Copy link
Member Author

/test

1 similar comment
@andrewkroh
Copy link
Member Author

/test

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@andrewkroh andrewkroh requested a review from mrodm November 12, 2025 17:19
Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

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

👍

Comment on lines +52 to +57
# 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 ' '
Copy link
Contributor

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)})
Copy link
Contributor

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 │
╰───────────────┴────────────────┴───────────────────┴───────────────────┴────────────╯

@andrewkroh andrewkroh merged commit 25c8701 into elastic:main Nov 14, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants