Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 22 additions & 33 deletions .buildkite/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -320,20 +320,12 @@ delete_kind_cluster() {
}

kibana_version_manifest() {
local kibana_version
kibana_version=$(cat manifest.yml | yq ".conditions.kibana.version")
if [ "${kibana_version}" != "null" ]; then
echo "${kibana_version}"
return
fi

kibana_version=$(cat manifest.yml | yq ".conditions.\"kibana.version\"")
if [ "${kibana_version}" != "null" ]; then
echo "${kibana_version}"
return
local kibana_version=""
if ! kibana_version=$(mage -d "${WORKSPACE}" -w . kibanaConstraintPackage) ; then
return 1
fi

echo "null"
echo "${kibana_version}"
return 0
}

capabilities_manifest() {
Expand Down Expand Up @@ -459,35 +451,25 @@ is_supported_stack() {
return 0
fi

local kibana_version
kibana_version=$(kibana_version_manifest)
if [ "${kibana_version}" == "null" ]; then
return 0
fi
if [[ ( ! "${kibana_version}" =~ \^7\. ) && "${STACK_VERSION}" =~ ^7\. ]]; then
return 1
fi
if [[ ( ! "${kibana_version}" =~ \^8\. ) && "${STACK_VERSION}" =~ ^8\. ]]; then
return 1
fi

# TODO: Allowed temporarily to test packages with stack version 9.0 if they have as constraint ^8.0 defined too.
# This workaround should be removed once packages have been updated their constraints for 9.0 stack.
if [[ ( ! ( "${kibana_version}" =~ \^9\. || "${kibana_version}" =~ \^8\. ) ) && "${STACK_VERSION}" =~ ^9\. ]]; then
Comment on lines -474 to -476
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As there are already 317 packages out of 330 packages (at the moment of creating this PR), it looks like this workaround could be removed.

The packages that would not be tested in the daily jobs for 9.1.0-SNAPSHOT are listed in the PR description.

WDYT @elastic/ecosystem ?

Copy link
Collaborator Author

@mrodm mrodm Apr 10, 2025

Choose a reason for hiding this comment

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

The problem of applying this PR now is there are some packages that had failed tests in 9.1.0-SNAPSHOT:

If we merge this PR, should we close those issues ?

juniper_junos and juniper_network are deprecated and they have some comments that they are not going to be fixed, so I think they could be closed.

So what should we do with the enteprisesearch issues if this PR is merged?

Copy link
Member

Choose a reason for hiding this comment

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

If we merge this PR, should we close those issues ?

Yes, maybe these packages are not intended to ever work in 9.x.

So what should we do with the enteprisesearch issues if this PR is merged?

@elastic/stack-monitoring is the enterprisesearch package intended to be supported in 9.x? Its constraints haven't been updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jsoriano Due to the Enterprise Search deprecation, it won't be available in Stack 9, which is why the constraints haven't been updated, i.e. there won't be an Enterprise Search 9 server to monitor

Copy link
Member

Choose a reason for hiding this comment

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

Ah, that's right, you already mentioned it in an internal comment. Thanks for the confirmation!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Perfect, so then I think those related issues can be closed after merging this PR.
Thanks!

local supported
if ! supported=$(mage -d "${WORKSPACE}" -w . isSupportedStack "${STACK_VERSION}"); then
return 1
fi

echo "${supported}"
return 0
}

oldest_supported_version() {
local kibana_version
kibana_version=$(kibana_version_manifest)
if ! kibana_version=$(kibana_version_manifest); then
return 1
fi
if [ "$kibana_version" != "null" ]; then
python3 "${SCRIPTS_BUILDKITE_PATH}/find_oldest_supported_version.py" --manifest-path manifest.yml
return
return 0
fi
echo "null"
return 0
}

create_elastic_package_profile() {
Expand All @@ -509,7 +491,9 @@ prepare_stack() {
version_set="${STACK_VERSION}"
else
local version
version=$(oldest_supported_version)
if ! version=$(oldest_supported_version); then
return 1
fi
if [[ "${requiredLogsDB}" == "true" ]]; then
# If LogsDB index mode is enabled, the required Elastic stack should be at least 8.17.0
# In 8.17.0 LogsDB index mode was made GA.
Expand Down Expand Up @@ -724,7 +708,12 @@ is_pr_affected() {
local from="${2}"
local to="${3}"

if ! is_supported_stack ; then
local stack_supported=""
if ! stack_supported=$(is_supported_stack) ; then
echo "${FATAL_ERROR}"
return 1
fi
if [[ "${stack_supported}" == "false" ]]; then
echo "[${package}] PR is not affected: unsupported stack (${STACK_VERSION})"
return 1
fi
Expand Down
50 changes: 50 additions & 0 deletions dev/citools/kibana.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package citools

import (
"fmt"
"strings"

"github.com/Masterminds/semver/v3"
)

func KibanaConstraintPackage(path string) (*semver.Constraints, error) {
manifest, err := readPackageManifest(path)
if err != nil {
return nil, fmt.Errorf("failed to read package manifest: %w", err)
}

kibanaVersion := manifest.Conditions.Kibana.Version
if kibanaVersion == "" {
return nil, nil
}

constraint, err := semver.NewConstraint(kibanaVersion)
if err != nil {
return nil, fmt.Errorf("failed to parse kibana constraint: %w", err)
}
return constraint, nil
}

func IsPackageSupportedInStackVersion(stackVersion string, path string) (bool, error) {
stackVersion = strings.TrimSuffix(stackVersion, "-SNAPSHOT")

stackSemVersion, err := semver.NewVersion(stackVersion)
if err != nil {
return false, fmt.Errorf("failed to parse stack version: %w", err)
}

packageConstraint, err := KibanaConstraintPackage(path)
if err != nil {
return false, err
}

if packageConstraint == nil {
return true, nil
}

return packageConstraint.Check(stackSemVersion), nil
}
141 changes: 141 additions & 0 deletions dev/citools/kibana_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package citools

import (
"os"
"path/filepath"
"testing"

"github.com/Masterminds/semver/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestKibanaConstraintPackage(t *testing.T) {
constraintTest, err := semver.NewConstraint("^8.0.0")
require.NoError(t, err)

cases := []struct {
title string
contents string
expected *semver.Constraints
}{
{
title: "kibana constrasint defined",
contents: `name: "version"
conditions:
kibana:
version: "^8.0.0"
`,
expected: constraintTest,
},
{
title: "kibana constraint defined with dotted field",
contents: `name: "version"
conditions:
kibana.version: "^8.0.0"
`,
expected: constraintTest,
},
{
title: "kibana constraint not defined",
contents: `name: "version"
`,
expected: nil,
},
}

for _, c := range cases {
t.Run(c.title, func(t *testing.T) {
directory := t.TempDir()
pkgManifestPath := filepath.Join(directory, "manifest.yml")
err := os.WriteFile(pkgManifestPath, []byte(c.contents), 0o644)
require.NoError(t, err)
constraint, err := KibanaConstraintPackage(pkgManifestPath)
require.NoError(t, err)
assert.Equal(t, c.expected, constraint)
})
}
}

func TestIsPackageSupportedInStackVersion(t *testing.T) {
cases := []struct {
title string
contents string
stackVersion string
supported bool
}{
{
title: "Test simple kibana constraint",
stackVersion: "8.18.0",
contents: `name: "stack"
conditions:
kibana:
version: "^8.0.0"
`,
supported: true,
},
{
title: "Test or condition",
stackVersion: "8.18.0",
contents: `name: "stack"
conditions:
kibana:
version: "^8.0.0 || ^9.0.0"
`,
supported: true,
},
{
title: "Test snapshot",
stackVersion: "8.18.0-SNAPSHOT",
contents: `name: "stack"
conditions:
kibana:
version: "^8.0.0 || ^9.0.0"
`,
supported: true,
},
{
title: "Test greater or equal",
stackVersion: "8.18.0-SNAPSHOT",
contents: `name: "stack"
conditions:
kibana:
version: ">=8.0.0"
`,
supported: true,
},
{
title: "Test not supported",
stackVersion: "8.18.0-SNAPSHOT",
contents: `name: "stack"
conditions:
kibana:
version: "^9.0.0"
`,
supported: false,
},
{
title: "Test missing kibana version",
stackVersion: "8.18.0-SNAPSHOT",
contents: `name: "stack"
`,
supported: true,
},
}

for _, c := range cases {
t.Run(c.title, func(t *testing.T) {
directory := t.TempDir()
pkgManifestPath := filepath.Join(directory, "manifest.yml")
err := os.WriteFile(pkgManifestPath, []byte(c.contents), 0o644)
require.NoError(t, err)
supported, err := IsPackageSupportedInStackVersion(c.stackVersion, pkgManifestPath)
require.NoError(t, err)
assert.Equal(t, c.supported, supported)
})
}
}
38 changes: 36 additions & 2 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,41 @@ func IsSubscriptionCompatible() error {
return nil
}

// IsLogsDBSupportedInPackage checks wheter or not the package in the current directory supports LogsDB
// KibanaConstraintPackage returns the Kibana version constraint defined in the package manifest
func KibanaConstraintPackage() error {
constraint, err := citools.KibanaConstraintPackage("manifest.yml")
if err != nil {
return fmt.Errorf("faile")
}
if constraint == nil {
fmt.Println("null")
return nil
}
fmt.Println(constraint)
return nil
}

// IsSupportedStack checks whether or not the package in the current directory is allowed to be installed in the given stack version
func IsSupportedStack(stackVersion string) error {
if stackVersion == "" {
fmt.Println("true")
return nil
}

supported, err := citools.IsPackageSupportedInStackVersion(stackVersion, "manifest.yml")
if err != nil {
return err
}

if supported {
fmt.Println("true")
return nil
}
fmt.Println("false")
return nil
}

// IsLogsDBSupportedInPackage checks whether or not the package in the current directory supports LogsDB
func IsLogsDBSupportedInPackage() error {
supported, err := citools.IsLogsDBSupportedInPackage("manifest.yml")
if err != nil {
Expand All @@ -249,7 +283,7 @@ func IsLogsDBSupportedInPackage() error {
return nil
}

// IsVersionLessThanLogsDBGA checks wheter or not the given version supports LogsDB. Minimum version that supports LogsDB as GA 8.17.0.
// IsVersionLessThanLogsDBGA checks whether or not the given version supports LogsDB. Minimum version that supports LogsDB as GA 8.17.0.
func IsVersionLessThanLogsDBGA(version string) error {
stackVersion, err := semver.NewVersion(version)
if err != nil {
Expand Down