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

show only logs with a severity level of ERROR or higher in the stderr. #4882

Closed
wants to merge 15 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:

- id: go-paths
run: |
echo ::set-output name=mod_cache::$(go env GOMODCACHE)
echo ::set-output name=build_cache::$(go env GOCACHE)
echo "mod_cache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
echo "build_cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT

- name: Go modules cache
uses: actions/cache@v3.3.1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ jobs:
PR_URL="${{ github.event.issue.pull_request.url }}"
PR_NUM=${PR_URL##*/}
echo "Checking out from PR #$PR_NUM based on URL: $PR_URL"
echo "::set-output name=pr_num::$PR_NUM"
echo "pr_num=$PR_NUM" >> $GITHUB_OUTPUT
# Get commit SHA
git config --global --add safe.directory "$GITHUB_WORKSPACE"
gh pr checkout $PR_NUM
SHA=$(git log -n 1 --pretty=format:"%H")
echo "::set-output name=commit_sha::$SHA"
echo "commit_sha=$SHA" >> $GITHUB_OUTPUT

build-test-images:
needs: triage
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
- name: Set Go paths
id: go-paths
run: |
echo ::set-output name=mod_cache::$(go env GOMODCACHE)
echo ::set-output name=build_cache::$(go env GOCACHE)
echo "mod_cache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
echo "build_cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT

- name: Go modules cache
uses: actions/cache@v3.3.1
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:

- id: go-paths
run: |
echo ::set-output name=mod_cache::$(go env GOMODCACHE)
echo ::set-output name=build_cache::$(go env GOCACHE)
echo "mod_cache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
echo "build_cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT

- name: Go modules cache
uses: actions/cache@v3.3.1
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

- name: Release Deployment YAML file
run: make release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/template-arm64-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
with:
runs-on: ARM64
kubernetesVersion: v1.26
kindImage: kindest/node:v1.26.0@sha256:691e24bd2417609db7e589e1a479b902d2e209892a10ce375fab60a8407c7352
kindImage: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb
2 changes: 1 addition & 1 deletion .github/workflows/template-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
fetch-depth: 1

- name: Create k8s ${{ inputs.kubernetesVersion }} Kind Cluster
uses: helm/kind-action@v1.7.0
uses: helm/kind-action@v1.8.0
Copy link

Choose a reason for hiding this comment

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

An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.

Ignore this finding from third-party-action-not-pinned-to-commit-sha.

with:
node_image: ${{ inputs.kindImage }}
cluster_name: smoke-tests-cluster-${{ inputs.kubernetesVersion }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/template-versions-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
kubernetesVersion: [v1.26, v1.25, v1.24, v1.23]
include:
- kubernetesVersion: v1.26
kindImage: kindest/node:v1.26.0@sha256:691e24bd2417609db7e589e1a479b902d2e209892a10ce375fab60a8407c7352
kindImage: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb
- kubernetesVersion: v1.25
kindImage: kindest/node:v1.25.0@sha256:428aaa17ec82ccde0131cb2d1ca6547d13cf5fdabcc0bbecf749baa935387cbf
- kubernetesVersion: v1.24
Expand Down
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ repos:
entry: golangci-lint run
types: [go]
pass_filenames: false
- id: validate-changelog
name: Validate Changelog
language: system
entry: "bash hack/validate-changelog.sh"
pass_filenames: false
410 changes: 210 additions & 200 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ For more installation options visit the [pre-commits](https://pre-commit.com).

Before running pre-commit, you must install the [golangci-lint](https://golangci-lint.run/) tool as a static check tool for golang code (contains a series of linter)
```shell script
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2
# or
brew install golangci/tap/golangci-lint
```
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,7 @@ help: ## Display this help.
.PHONY: docker-build-dev-containers
docker-build-dev-containers: ## Build dev-containers image
docker build -f .devcontainer/Dockerfile .

.PHONY: validate-changelog
validate-changelog: ## Validate changelog
./hack/validate-changelog.sh
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resource definition.
KEDA can run on both the cloud and the edge, integrates natively with Kubernetes components such as the Horizontal
Pod Autoscaler, and has no external dependencies.

We are a Cloud Native Computing Foundation (CNCF) incubation project.
We are a Cloud Native Computing Foundation (CNCF) graduated project.
<p align="center"><img src="https://raw.githubusercontent.com/kedacore/keda/main/images/logo-cncf.svg" height="75px"></p>

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
Expand All @@ -32,6 +32,7 @@ We are a Cloud Native Computing Foundation (CNCF) incubation project.
- [Releases](#releases)
- [Contributing](#contributing)
- [Building & deploying locally](#building--deploying-locally)
- [Testing strategy](#testing-strategy)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -83,3 +84,6 @@ You can find contributing guide [here](./CONTRIBUTING.md).

### Building & deploying locally
Learn how to build & deploy KEDA locally [here](./BUILD.md).

### Testing strategy
Learn more about our testing strategy [here](./TESTING.md).
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Here is an overview of our current release estimations:

| Version | Estimated Release Date |
|:--------|:-----------------------------------------------------|
| v2.12 | September 12th, 2023 |
| v2.12 | September 26th, 2023 |
| v2.13 | January 11th, 2024 *(planned later due to holidays)* |
| v2.14 | April 12th, 2024 |

Expand Down
22 changes: 22 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Testing strategy

## Unit tests / code coverage

There are unit tests present for each scaler implementation, and for the majority of the core.
Code coverage “is something that we need to work on” constantly.

However, using a code coverage tooling is not useful for the KEDA project in the current state given a lot of functionality is covered by end-to-end tests, which are not considered and thus our code coverage metrics will be misleading.

For each PR, we automatically build and run our unit test suite but also build Docker images for both amd64 and arm64 architectures. As part of our CI process, we also perform various security checks for which you can learn more in our security section.

Lastly, we automatically perform code quality analysis with golangci-lint and check licenses of our dependencies with FOSSA.

## End-to-end tests

There are end-to-end tests for the core functionality and majority of features of KEDA as well as the scalers that it offers. These tests are required for every PR and run in the CI (however, maintainers trigger them as a security precaution). Additionally, we run our e2e test suite for every merged commit to the main branch as well as during our nightly CI schedule ([link](https://github.com/kedacore/keda/actions/workflows/nightly-e2e.yml)). Implementing end-to-end tests is a requirement for adding a new scaler, as per [our policy](https://github.com/kedacore/governance/blob/main/SCALERS.md#requirements-for-a-built-in-scaler).

The project runs two Kubernetes clusters on which all e2e tests are ran automatically. Microsoft Azure has donated a dedicated Azure subscription so that all maintainers can manage these cloud resources and allow us to run our automated tesing and automation. This is in addition to CNCF’s Cloud Credits program which we use to provision test resources in AWS & GCP for scaler e2e tests as well.

Both the cluster management as well as the cloud resources required for our automated tests are managed by Terraform and [available on GitHub](https://github.com/kedacore/testing-infrastructure) so that every contributor can open a PR with the infrastructure changes that they require. Everything is automatically deployed by using GitHub Actions to ensure we are running the latest configuration and can easily migrate to other infrastructure, if we have to.

Additionally, CNCF sponsors KEDA by providing arm64 machines on which we build our ARM64 image and Vexxhost sponsors an OpenStack instance to run tests on these as well.
2 changes: 1 addition & 1 deletion apis/keda/v1alpha1/scaledobject_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func validateWorkload(so *ScaledObject, action string) (admission.Warnings, erro
}

func verifyTriggers(incomingSo *ScaledObject, action string) error {
err := ValidateTriggers(scaledobjectlog.WithValues("name", incomingSo.Name), incomingSo.Spec.Triggers)
err := ValidateTriggers(incomingSo.Spec.Triggers)
if err != nil {
scaledobjectlog.WithValues("name", incomingSo.Name).Error(err, "validation error")
prommetrics.RecordScaledObjectValidatingErrors(incomingSo.Namespace, action, "incorrect-triggers")
Expand Down
115 changes: 0 additions & 115 deletions apis/keda/v1alpha1/scaledobject_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,133 +18,18 @@ package v1alpha1

import (
"context"
"crypto/tls"
"fmt"
"net"
"path/filepath"
"testing"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
admissionv1beta1 "k8s.io/api/admission/v1beta1"
appsv1 "k8s.io/api/apps/v1"
v2 "k8s.io/api/autoscaling/v2"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"k8s.io/utils/pointer"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
//+kubebuilder:scaffold:imports
)

// These tests use Ginkgo (BDD-style Go testing framework). Refer to
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.

var cfg *rest.Config
var k8sClient client.Client
var testEnv *envtest.Environment
var ctx context.Context
var cancel context.CancelFunc

const (
workloadName = "deployment-name"
soName = "test-so"
)

func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecs(t, "Webhook Suite")
}

var _ = BeforeSuite(func() {
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))

ctx, cancel = context.WithCancel(context.Background())

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")},
ErrorIfCRDPathMissing: false,
WebhookInstallOptions: envtest.WebhookInstallOptions{
Paths: []string{filepath.Join("..", "..", "..", "config", "webhooks")},
},
}

var err error
// cfg is defined in this file globally.
done := make(chan interface{})
go func() {
defer GinkgoRecover()
cfg, err = testEnv.Start()
close(done)
}()
Eventually(done).WithTimeout(time.Minute).Should(BeClosed())
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

scheme := runtime.NewScheme()
err = AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

err = clientgoscheme.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

err = admissionv1beta1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

//+kubebuilder:scaffold:scheme

k8sClient, err = client.New(cfg, client.Options{Scheme: scheme})
Expect(err).NotTo(HaveOccurred())
Expect(k8sClient).NotTo(BeNil())

// start webhook server using Manager
webhookInstallOptions := &testEnv.WebhookInstallOptions
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
Host: webhookInstallOptions.LocalServingHost,
Port: webhookInstallOptions.LocalServingPort,
CertDir: webhookInstallOptions.LocalServingCertDir,
LeaderElection: false,
MetricsBindAddress: "0",
})
Expect(err).NotTo(HaveOccurred())

err = (&ScaledObject{}).SetupWebhookWithManager(mgr)
Expect(err).NotTo(HaveOccurred())

//+kubebuilder:scaffold:webhook

go func() {
defer GinkgoRecover()
err = mgr.Start(ctx)
Expect(err).NotTo(HaveOccurred())
}()

// wait for the webhook server to get ready
dialer := &net.Dialer{Timeout: time.Second}
addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort)
Eventually(func() error {
conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true})
if err != nil {
return err
}
conn.Close()
return nil
}).Should(Succeed())

})

var _ = It("should validate the so creation when there isn't any hpa", func() {

namespaceName := "valid"
Expand Down
10 changes: 1 addition & 9 deletions apis/keda/v1alpha1/scaletriggers_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package v1alpha1
import (
"fmt"

"github.com/go-logr/logr"
autoscalingv2 "k8s.io/api/autoscaling/v2"
)

Expand Down Expand Up @@ -50,7 +49,7 @@ type AuthenticationRef struct {
// ValidateTriggers checks that general trigger metadata are valid, it checks:
// - triggerNames in ScaledObject are unique
// - useCachedMetrics is defined only for a supported triggers
func ValidateTriggers(logger logr.Logger, triggers []ScaleTriggers) error {
func ValidateTriggers(triggers []ScaleTriggers) error {
triggersCount := len(triggers)
if triggers != nil && triggersCount > 0 {
triggerNames := make(map[string]bool, triggersCount)
Expand All @@ -63,13 +62,6 @@ func ValidateTriggers(logger logr.Logger, triggers []ScaleTriggers) error {
}
}

// FIXME: DEPRECATED to be removed in v2.12
_, hasMetricName := trigger.Metadata["metricName"]
// aws-cloudwatch, huawei-cloudeye and azure-monitor have a meaningful use of metricName
if hasMetricName && trigger.Type != "aws-cloudwatch" && trigger.Type != "huawei-cloudeye" && trigger.Type != "azure-monitor" {
logger.Info("\"metricName\" is deprecated and will be removed in v2.12, please do not set it anymore", "trigger.type", trigger.Type)
}

name := trigger.Name
if name != "" {
if _, found := triggerNames[name]; found {
Expand Down
3 changes: 1 addition & 2 deletions apis/keda/v1alpha1/scaletriggers_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package v1alpha1
import (
"testing"

"github.com/go-logr/logr"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -90,7 +89,7 @@ func TestValidateTriggers(t *testing.T) {
for _, test := range tests {
tt := test
t.Run(test.name, func(t *testing.T) {
err := ValidateTriggers(logr.Discard(), tt.triggers)
err := ValidateTriggers(tt.triggers)
if test.expectedErrMsg == "" {
assert.NoError(t, err)
} else {
Expand Down
Loading