Skip to content

Conversation

@mrodm
Copy link
Contributor

@mrodm mrodm commented Sep 21, 2022

Closes elastic/package-spec#318

This PR shows an error when assets are exported from an Elastic stack SNAPSHOT version. Using those assets generated by a snapshot version may lead to use features that are not released at the end, or maybe they are in a different way.

In case developers need to use an SNAPSHOT version, a new parameter has been added --allow-snapshots to allow this export process.

Output using SNAPSHOT Version:

  • Running elastic-package export dashboards:
     $ elastic-package export dashboards 
    elastic-package has been installed.
    Export Kibana dashboards
    Error: exporting dashboards from a SNAPSHOT version of Kibana (8.4.0-SNAPSHOT) is discouraged. It could lead to invalid dashboards (for example if they use features that are reverted or modified before the final release). --allow-snapshot flag can be used to ignore this error
    
  • Running elastic-package export dashboards --allow-snapshot:
     $ elastic-package export dashboards --allow-snapshot
    Export Kibana dashboards
    Warning: exporting dashboards from a SNAPSHOT version of Kibana (8.4.0-SNAPSHOT) is discouraged. It could lead to invalid dashboards (for example if they use features that are reverted or modified before the final release)
    ? Which dashboards would you like to export?  [Use arrows to move, space to select, <right> 
    to all, <left> to none, type to filter]
    ...
    

Tested with 8.0.0, 8.4.0-SNAPSHOT and 7.17.6 and 7.17.0-SNAPSHOT versions.

In this PR, the /api/status endpoint is being tested to retrieve the version information. This includes a dedicated field about whether or not this is a snapshot build (build_snapshot field).

  • Running command elastic-package stack up -v -d --version 8.0.0:
 $ curl -u elastic:changeme -H 'Content-Type: application/json' -H 'kbn-xsrf: true' -k -s https://localhost:5601/api/status? | jq -r .version
{
  "number": "8.0.0",
  "build_hash": "57ca5e139a33dd2eed927ce98d8231a1f217cd15",
  "build_number": 49192,
  "build_snapshot": false
}
  • Running command elastic-package stack up -v -d --version 8.4.0-SNAPSHOT:
 $ curl -u elastic:changeme -H 'Content-Type: application/json' -H 'kbn-xsrf: true' -k -s https://localhost:5601/api/status | jq -r .version
{
  "number": "8.4.0",
  "build_hash": "7ffc375be69ab56267d3fc71bf7f27da6dfacdfb",
  "build_number": 55408,
  "build_snapshot": true
}

In case of build_snapshot true , it must be added the suffix "-SNAPSHOT" to the version.number field.

…ersions

Export dashboards from Elastic stack SNAPSHOT verions is discouraged.
Added new parameter "export dashboards --allow-snapshots" command, to
allow exporting those dashboards or it will show an error.
Version information is now retrieved from /api/status endpoint that also
includes information about whether or not is a snapshot build
(build_snapshot field).
@elasticmachine
Copy link
Collaborator

elasticmachine commented Sep 21, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-09-21T15:13:28.636+0000

  • Duration: 37 min 54 sec

Test stats 🧪

Test Results
Failed 0
Passed 831
Skipped 0
Total 831

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Sep 21, 2022

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (34/34) 💚
Files 66.142% (84/127) 👎 -0.787
Classes 61.111% (110/180) 👎 -0.556
Methods 48.77% (357/732) 👎 -0.273
Lines 32.135% (3218/10014) 👎 -0.096
Conditionals 100.0% (0/0) 💚

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

👍 some nitpicking in the error messages.

}

// Version method returns the version of Kibana (Elastic stack)
func (c *Client) Version() (string, bool, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Version method from internal/kibana/injected_metadata.go deleted in favor of this one.

This new method uses the /api/status endpoint, and it has a dedicated field to indicate whether or not the version is a snapshot one (build_snapshot).

Copy link
Member

Choose a reason for hiding this comment

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

Wdyt about returning an object with the version information instead of multiple values?

Suggested change
func (c *Client) Version() (string, bool, error) {
func (c *Client) Version() (VersionInfo, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! Added that new object.

Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
Comment on lines 41 to 45
stackVersion := status.Version.Number
if status.Version.BuildSnapshot {
stackVersion = fmt.Sprintf("%s%s", stackVersion, SNAPSHOT_SUFFIX)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This API returns the version without -SNAPSHOT. https://github.com/elastic/kibana/blob/main/packages/core/status/core-status-server-internal/src/routes/status.ts#L120-L123

That's why it is needed to be added here.

Example of output (Elastic stack 7.17.0-SNAPSHOT):

 $ curl -u elastic:changeme -H 'Content-Type: application/json' -H 'kbn-xsrf: true' -k -s https://localhost:5601/api/status | jq -r .version
{
  "number": "7.17.0",
  "build_hash": "0ab325e4b36168a264907fbc84f6913519671acf",
  "build_number": 46537,
  "build_snapshot": true
}

@mrodm mrodm marked this pull request as ready for review September 21, 2022 14:47
@mrodm mrodm merged commit c642a30 into elastic:main Sep 21, 2022
@mrodm mrodm deleted the export_dashboards_snapshots branch September 21, 2022 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team:Ecosystem Label for the Packages Ecosystem team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warning when assets are built with a stack SNAPSHOT version

3 participants