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

chore: bump deps #4942

Merged
merged 11 commits into from
Sep 6, 2023
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ GO_LDFLAGS="-X=github.com/kedacore/keda/v2/version.GitCommit=$(GIT_COMMIT) -X=gi
COSIGN_FLAGS ?= -y -a GIT_HASH=${GIT_COMMIT} -a GIT_VERSION=${VERSION} -a BUILD_DATE=${DATE}

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.26
ENVTEST_K8S_VERSION = 1.28

# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
Expand Down Expand Up @@ -320,7 +320,7 @@ $(CONTROLLER_GEN): $(LOCALBIN)
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Install kustomize from vendor dir if necessary.
$(KUSTOMIZE): $(LOCALBIN)
test -s $(LOCALBIN)/kustomize || GOBIN=$(LOCALBIN) go install sigs.k8s.io/kustomize/kustomize/v4
test -s $(LOCALBIN)/kustomize || GOBIN=$(LOCALBIN) go install sigs.k8s.io/kustomize/kustomize/v5

.PHONY: envtest
envtest: $(ENVTEST) ## Install envtest-setup from vendor dir if necessary.
Expand Down
24 changes: 12 additions & 12 deletions apis/keda/v1alpha1/scaledobject_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

var _ = It("should validate the so creation when there isn't any hpa", func() {
Expand Down Expand Up @@ -116,7 +116,7 @@ var _ = It("should validate the so update when it's own hpa is already generated
err = k8sClient.Create(context.Background(), so)
Expect(err).ToNot(HaveOccurred())

so.Spec.MaxReplicaCount = pointer.Int32(7)
so.Spec.MaxReplicaCount = ptr.To[int32](7)
Eventually(func() error {
return k8sClient.Update(context.Background(), so)
}).ShouldNot(HaveOccurred())
Expand Down Expand Up @@ -467,9 +467,9 @@ func createScaledObject(name, namespace, targetName, targetAPI, targetKind strin
APIVersion: targetAPI,
Kind: targetKind,
},
IdleReplicaCount: pointer.Int32(1),
MinReplicaCount: pointer.Int32(5),
MaxReplicaCount: pointer.Int32(10),
IdleReplicaCount: ptr.To[int32](1),
MinReplicaCount: ptr.To[int32](5),
MaxReplicaCount: ptr.To[int32](10),
Triggers: triggers,
Advanced: advancedConfig,
},
Expand All @@ -485,14 +485,14 @@ func createHpa(name, namespace, targetName, targetAPI, targetKind string, owner
APIVersion: targetAPI,
Kind: targetKind,
},
MinReplicas: pointer.Int32(5),
MinReplicas: ptr.To[int32](5),
MaxReplicas: 10,
Metrics: []v2.MetricSpec{
{
Resource: &v2.ResourceMetricSource{
Name: v1.ResourceCPU,
Target: v2.MetricTarget{
AverageUtilization: pointer.Int32(30),
AverageUtilization: ptr.To[int32](30),
Type: v2.AverageValueMetricType,
},
},
Expand Down Expand Up @@ -527,7 +527,7 @@ func createDeployment(namespace string, hasCPU, hasMemory bool) *appsv1.Deployme
return &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{Name: workloadName, Namespace: namespace},
Spec: appsv1.DeploymentSpec{
Replicas: pointer.Int32(1),
Replicas: ptr.To[int32](1),
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"test": "test",
Expand Down Expand Up @@ -572,7 +572,7 @@ func createStatefulSet(namespace string, hasCPU, hasMemory bool) *appsv1.Statefu
return &appsv1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{Name: workloadName, Namespace: namespace},
Spec: appsv1.StatefulSetSpec{
Replicas: pointer.Int32(1),
Replicas: ptr.To[int32](1),
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"test": "test",
Expand Down Expand Up @@ -639,9 +639,9 @@ func createScaledObjectSTZ(name string, namespace string, targetName string, min
ScaleTargetRef: &ScaleTarget{
Name: targetName,
},
MinReplicaCount: pointer.Int32(minReplicas),
MaxReplicaCount: pointer.Int32(maxReplicas),
CooldownPeriod: pointer.Int32(1),
MinReplicaCount: ptr.To[int32](minReplicas),
MaxReplicaCount: ptr.To[int32](maxReplicas),
CooldownPeriod: ptr.To[int32](1),
Triggers: triggers,
},
}
Expand Down
18 changes: 12 additions & 6 deletions apis/keda/v1alpha1/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/envtest"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

// These tests use Ginkgo (BDD-style Go testing framework). Refer to
Expand Down Expand Up @@ -102,12 +104,16 @@ var _ = BeforeSuite(func() {
// 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",
Scheme: scheme,
WebhookServer: webhook.NewServer(webhook.Options{
Host: webhookInstallOptions.LocalServingHost,
Port: webhookInstallOptions.LocalServingPort,
CertDir: webhookInstallOptions.LocalServingCertDir,
}),
LeaderElection: false,
Metrics: server.Options{
BindAddress: "0",
},
})
Expect(err).NotTo(HaveOccurred())

Expand Down
10 changes: 7 additions & 3 deletions apis/keda/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 8 additions & 21 deletions cmd/adapter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"k8s.io/klog/v2/klogr"
ctrl "sigs.k8s.io/controller-runtime"
ctrlcache "sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
basecmd "sigs.k8s.io/custom-metrics-apiserver/pkg/cmd"
"sigs.k8s.io/custom-metrics-apiserver/pkg/provider"

Expand Down Expand Up @@ -65,7 +66,7 @@ func (a *Adapter) makeProvider(ctx context.Context) (provider.ExternalMetricsPro
logger.Error(err, "failed to add keda scheme to runtime scheme")
return nil, nil, fmt.Errorf("failed to add keda scheme to runtime scheme (%s)", err)
}
namespace, err := getWatchNamespace()
namespaces, err := kedautil.GetWatchNamespaces()
if err != nil {
logger.Error(err, "failed to get watch namespace")
return nil, nil, fmt.Errorf("failed to get watch namespace (%s)", err)
Expand All @@ -89,12 +90,6 @@ func (a *Adapter) makeProvider(ctx context.Context) (provider.ExternalMetricsPro
return nil, nil, fmt.Errorf("invalid KEDA_METRICS_LEADER_ELECTION_RETRY_PERIOD (%s)", err)
}

useMetricsServiceGrpc, err := kedautil.ResolveOsEnvBool("KEDA_USE_METRICS_SERVICE_GRPC", true)
if err != nil {
logger.Error(err, "Invalid KEDA_USE_METRICS_SERVICE_GRPC")
return nil, nil, fmt.Errorf("invalid KEDA_USE_METRICS_SERVICE_GRPC (%s)", err)
}

// Get a config to talk to the apiserver
cfg := ctrl.GetConfigOrDie()
cfg.QPS = adapterClientRequestQPS
Expand All @@ -103,10 +98,12 @@ func (a *Adapter) makeProvider(ctx context.Context) (provider.ExternalMetricsPro

metricsBindAddress := fmt.Sprintf(":%v", metricsAPIServerPort)
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
MetricsBindAddress: metricsBindAddress,
Scheme: scheme,
Metrics: server.Options{
BindAddress: metricsBindAddress,
},
Scheme: scheme,
Cache: ctrlcache.Options{
Namespaces: []string{namespace},
DefaultNamespaces: namespaces,
},
LeaseDuration: leaseDuration,
RenewDeadline: renewDeadline,
Expand All @@ -131,7 +128,7 @@ func (a *Adapter) makeProvider(ctx context.Context) (provider.ExternalMetricsPro
close(stopCh)
}
}()
return kedaprovider.NewProvider(ctx, logger, mgr.GetClient(), *grpcClient, useMetricsServiceGrpc, namespace), stopCh, nil
return kedaprovider.NewProvider(ctx, logger, mgr.GetClient(), *grpcClient), stopCh, nil
}

// generateDefaultMetricsServiceAddr generates default Metrics Service gRPC Server address based on the current Namespace.
Expand All @@ -140,16 +137,6 @@ func generateDefaultMetricsServiceAddr() string {
return fmt.Sprintf("keda-operator.%s.svc.cluster.local:9666", kedautil.GetPodNamespace())
}

// getWatchNamespace returns the namespace the operator should be watching for changes
func getWatchNamespace() (string, error) {
const WatchNamespaceEnvVar = "WATCH_NAMESPACE"
ns, found := os.LookupEnv(WatchNamespaceEnvVar)
if !found {
return "", fmt.Errorf("%s must be set", WatchNamespaceEnvVar)
}
return ns, nil
}

// printWelcomeMsg prints welcome message during the start of the adater
func printWelcomeMsg(cmd *Adapter) error {
clientset, err := cmd.DiscoveryClient()
Expand Down
22 changes: 7 additions & 15 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package main

import (
"flag"
"fmt"
"os"
"time"

Expand All @@ -35,6 +34,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1"
Expand All @@ -59,16 +59,6 @@ func init() {
//+kubebuilder:scaffold:scheme
}

// getWatchNamespace returns the namespace the operator should be watching for changes
func getWatchNamespace() (string, error) {
const WatchNamespaceEnvVar = "WATCH_NAMESPACE"
ns, found := os.LookupEnv(WatchNamespaceEnvVar)
if !found {
return "", fmt.Errorf("%s must be set", WatchNamespaceEnvVar)
}
return ns, nil
}

func main() {
var metricsAddr string
var probeAddr string
Expand Down Expand Up @@ -107,7 +97,7 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
ctx := ctrl.SetupSignalHandler()
namespace, err := getWatchNamespace()
namespaces, err := kedautil.GetWatchNamespaces()
if err != nil {
setupLog.Error(err, "failed to get watch namespace")
os.Exit(1)
Expand Down Expand Up @@ -137,13 +127,15 @@ func main() {
cfg.DisableCompression = disableCompression

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Scheme: scheme,
Metrics: server.Options{
BindAddress: metricsAddr,
},
WebhookServer: webhook.NewServer(webhook.Options{
Port: 9443,
}),
Cache: ctrlcache.Options{
Namespaces: []string{namespace},
DefaultNamespaces: namespaces,
},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
Expand Down
9 changes: 6 additions & 3 deletions cmd/webhooks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1"
Expand Down Expand Up @@ -79,9 +80,11 @@ func main() {
cfg.Burst = webhooksClientRequestBurst

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
LeaderElection: false,
MetricsBindAddress: metricsAddr,
Scheme: scheme,
LeaderElection: false,
Metrics: server.Options{
BindAddress: metricsAddr,
},
WebhookServer: webhook.NewServer(webhook.Options{
Port: webhooksPort,
CertDir: certDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.0
controller-gen.kubebuilder.io/version: v0.13.0
name: clustertriggerauthentications.keda.sh
spec:
group: keda.sh
Expand Down
Loading