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

stack status cmd - add columns for image build date and VCS reference #2057

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@andrewkroh andrewkroh marked this pull request as ready for review August 29, 2024 20:24

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/[email protected]/command.go:985 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc00054af08)
	/home/mariorodriguez/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0xc000078008?)
	/home/mariorodriguez/go/pkg/mod/github.com/spf13/[email protected]/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) │
╰───────────────┴────────────────────────────┴───────────────────╯

@mrodm mrodm requested a review from a team September 19, 2024 15:28
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