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

Add flags for QPS and Burst to *-poollet and *-broker #1157

Merged
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
21 changes: 17 additions & 4 deletions broker/bucketbroker/cmd/bucketbroker/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import (
"fmt"
"net"

"github.com/ironcore-dev/controller-utils/configutils"
"github.com/ironcore-dev/ironcore/broker/bucketbroker/server"
"github.com/ironcore-dev/ironcore/broker/common"
iri "github.com/ironcore-dev/ironcore/iri/apis/bucket/v1alpha1"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"google.golang.org/grpc"

"github.com/ironcore-dev/ironcore/broker/bucketbroker/server"
"github.com/ironcore-dev/ironcore/broker/common"
iri "github.com/ironcore-dev/ironcore/iri/apis/bucket/v1alpha1"
"github.com/ironcore-dev/ironcore/utils/client/config"

"github.com/ironcore-dev/controller-utils/configutils"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
)
Expand All @@ -24,6 +27,9 @@ type Options struct {
Kubeconfig string
Address string

QPS float32
Burst int

Namespace string
BucketPoolName string
BucketPoolSelector map[string]string
Expand All @@ -33,6 +39,9 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.Kubeconfig, "kubeconfig", o.Kubeconfig, "Path pointing to a kubeconfig file to use.")
fs.StringVar(&o.Address, "address", "/var/run/iri-bucketbroker.sock", "Address to listen on.")

fs.Float32Var(&o.QPS, "qps", config.QPS, "Kubernetes client qps.")
fs.IntVar(&o.Burst, "burst", config.Burst, "Kubernetes client burst.")

fs.StringVar(&o.Namespace, "namespace", o.Namespace, "Target Kubernetes namespace to use.")
fs.StringVar(&o.BucketPoolName, "bucket-pool-name", o.BucketPoolName, "Name of the target bucket pool to pin buckets to, if any.")
fs.StringToStringVar(&o.BucketPoolSelector, "bucket-pool-selector", o.BucketPoolSelector, "Selector of the target bucket pools to pin buckets to, if any.")
Expand Down Expand Up @@ -74,6 +83,10 @@ func Run(ctx context.Context, opts Options) error {
return err
}

cfg.QPS = opts.QPS
cfg.Burst = opts.Burst
setupLog.Info("Kubernetes Client configuration", "QPS", cfg.QPS, "Burst", cfg.Burst)

srv, err := server.New(cfg, server.Options{
Namespace: opts.Namespace,
BucketPoolName: opts.BucketPoolName,
Expand Down
25 changes: 19 additions & 6 deletions broker/machinebroker/cmd/machinebroker/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ import (
"net/url"

"github.com/go-logr/logr"
"github.com/ironcore-dev/controller-utils/configutils"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"

"github.com/ironcore-dev/ironcore/broker/common"
commongrpc "github.com/ironcore-dev/ironcore/broker/common/grpc"
machinebrokerhttp "github.com/ironcore-dev/ironcore/broker/machinebroker/http"
"github.com/ironcore-dev/ironcore/broker/machinebroker/server"
iri "github.com/ironcore-dev/ironcore/iri/apis/machine/v1alpha1"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
"github.com/ironcore-dev/ironcore/utils/client/config"

"github.com/ironcore-dev/controller-utils/configutils"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
)
Expand All @@ -34,6 +37,9 @@ type Options struct {
BaseURL string
BrokerDownwardAPILabels map[string]string

QPS float32
Burst int

Namespace string
MachinePoolName string
MachinePoolSelector map[string]string
Expand All @@ -48,6 +54,9 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
fs.StringToStringVar(&o.BrokerDownwardAPILabels, "broker-downward-api-label", nil, "The labels to broker via downward API. "+
"Example is for instance to broker \"root-machine-uid\" initially obtained via \"machinepoollet.ironcore.dev/machine-uid\".")

fs.Float32Var(&o.QPS, "qps", config.QPS, "Kubernetes client qps.")
fs.IntVar(&o.Burst, "burst", config.Burst, "Kubernetes client burst.")

fs.StringVar(&o.Namespace, "namespace", o.Namespace, "Target Kubernetes namespace to use.")
fs.StringVar(&o.MachinePoolName, "machine-pool-name", o.MachinePoolName, "Name of the target machine pool to pin machines to, if any.")
fs.StringToStringVar(&o.MachinePoolSelector, "machine-pool-selector", o.MachinePoolSelector, "Selector of the target machine pools to pin machines to, if any.")
Expand Down Expand Up @@ -102,6 +111,10 @@ func Run(ctx context.Context, opts Options) error {
baseURL = u.String()
}

cfg.QPS = opts.QPS
cfg.Burst = opts.Burst
setupLog.Info("Kubernetes Client configuration", "QPS", cfg.QPS, "Burst", cfg.Burst)

log.V(1).Info("Creating server",
"Namespace", opts.Namespace,
"MachinePoolName", opts.MachinePoolName,
Expand Down Expand Up @@ -142,7 +155,7 @@ func runServer(ctx context.Context, setupLog, log logr.Logger, srv *server.Serve
return nil
}

func runGRPCServer(ctx context.Context, setupLog logr.Logger, log logr.Logger, srv *server.Server, opts Options) error {
func runGRPCServer(ctx context.Context, setupLog, log logr.Logger, srv *server.Server, opts Options) error {
log.V(1).Info("Cleaning up any previous socket")
if err := common.CleanupSocketIfExists(opts.Address); err != nil {
return fmt.Errorf("error cleaning up socket: %w", err)
Expand Down
21 changes: 17 additions & 4 deletions broker/volumebroker/cmd/volumebroker/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import (
"fmt"
"net"

"github.com/ironcore-dev/controller-utils/configutils"
"github.com/ironcore-dev/ironcore/broker/common"
"github.com/ironcore-dev/ironcore/broker/volumebroker/server"
iri "github.com/ironcore-dev/ironcore/iri/apis/volume/v1alpha1"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"google.golang.org/grpc"

"github.com/ironcore-dev/ironcore/broker/common"
"github.com/ironcore-dev/ironcore/broker/volumebroker/server"
iri "github.com/ironcore-dev/ironcore/iri/apis/volume/v1alpha1"
"github.com/ironcore-dev/ironcore/utils/client/config"

"github.com/ironcore-dev/controller-utils/configutils"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
)
Expand All @@ -24,6 +27,9 @@ type Options struct {
Kubeconfig string
Address string

QPS float32
Burst int

Namespace string
VolumePoolName string
VolumePoolSelector map[string]string
Expand All @@ -33,6 +39,9 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.Kubeconfig, "kubeconfig", o.Kubeconfig, "Path pointing to a kubeconfig file to use.")
fs.StringVar(&o.Address, "address", "/var/run/iri-volumebroker.sock", "Address to listen on.")

fs.Float32Var(&o.QPS, "qps", config.QPS, "Kubernetes client qps.")
fs.IntVar(&o.Burst, "burst", config.Burst, "Kubernetes client burst.")

fs.StringVar(&o.Namespace, "namespace", o.Namespace, "Target Kubernetes namespace to use.")
fs.StringVar(&o.VolumePoolName, "volume-pool-name", o.VolumePoolName, "Name of the target volume pool to pin volumes to, if any.")
fs.StringToStringVar(&o.VolumePoolSelector, "volume-pool-selector", o.VolumePoolSelector, "Selector of the target volume pools to pin volumes to, if any.")
Expand Down Expand Up @@ -74,6 +83,10 @@ func Run(ctx context.Context, opts Options) error {
return err
}

cfg.QPS = opts.QPS
cfg.Burst = opts.Burst
setupLog.Info("Kubernetes Client configuration", "QPS", cfg.QPS, "Burst", cfg.Burst)

srv, err := server.New(cfg, server.Options{
Namespace: opts.Namespace,
VolumePoolName: opts.VolumePoolName,
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module github.com/ironcore-dev/ironcore
go 1.23.0

require (
github.com/bits-and-blooms/bitset v1.15.0
github.com/bits-and-blooms/bitset v1.17.0
github.com/blang/semver/v4 v4.0.0
github.com/go-chi/chi/v5 v5.1.0
github.com/go-logr/logr v1.4.2
github.com/gogo/protobuf v1.3.2
github.com/google/go-cmp v0.6.0
github.com/ironcore-dev/controller-utils v0.9.5
github.com/onsi/ginkgo/v2 v2.22.0
github.com/onsi/gomega v1.35.1
github.com/onsi/gomega v1.36.0
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
go4.org/netipx v0.0.0-20220812043211-3cc044ffd68d
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bits-and-blooms/bitset v1.15.0 h1:DiCRMscZsGyYePE9AR3sVhKqUXCt5IZvkX5AfAc5xLQ=
github.com/bits-and-blooms/bitset v1.15.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/bits-and-blooms/bitset v1.17.0 h1:1X2TS7aHz1ELcC0yU1y2stUs/0ig5oMU6STFZGrhvHI=
github.com/bits-and-blooms/bitset v1.17.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
Expand Down Expand Up @@ -151,8 +151,8 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=
github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/onsi/gomega v1.36.0 h1:Pb12RlruUtj4XUuPUqeEWc6j5DkVVVA49Uf6YLfC95Y=
github.com/onsi/gomega v1.36.0/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
22 changes: 14 additions & 8 deletions poollet/bucketpoollet/cmd/bucketpoollet/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ type Options struct {
RelistThreshold time.Duration

WatchFilterValue string

MaxConcurrentReconciles int
}

func (o *Options) AddFlags(fs *pflag.FlagSet) {
Expand All @@ -89,6 +91,8 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
fs.DurationVar(&o.RelistThreshold, "relist-threshold", 3*time.Minute, "event channel relisting threshold.")

fs.StringVar(&o.WatchFilterValue, "watch-filter", "", "Value to filter for while watching.")

fs.IntVar(&o.MaxConcurrentReconciles, "max-concurrent-reconciles", 1, "Maximum number of concurrent reconciles.")
}

func (o *Options) MarkFlagsRequired(cmd *cobra.Command) {
Expand Down Expand Up @@ -150,7 +154,8 @@ func Run(ctx context.Context, opts Options) error {
return fmt.Errorf("error getting config: %w", err)
}

setupLog.Info("IRI client config", "ChannelCapacity", opts.ChannelCapacity, "RelistPeriod", opts.RelistPeriod, "RelistThreshold", opts.RelistThreshold)
setupLog.Info("IRI Client configuration", "ChannelCapacity", opts.ChannelCapacity, "RelistPeriod", opts.RelistPeriod, "RelistThreshold", opts.RelistThreshold)
setupLog.Info("Kubernetes Client configuration", "QPS", cfg.QPS, "Burst", cfg.Burst)

leaderElectionCfg, err := configutils.GetConfig(
configutils.Kubeconfig(opts.LeaderElectionKubeconfig),
Expand Down Expand Up @@ -213,13 +218,14 @@ func Run(ctx context.Context, opts Options) error {
}

if err := (&controllers.BucketReconciler{
EventRecorder: mgr.GetEventRecorderFor("buckets"),
Client: mgr.GetClient(),
Scheme: scheme,
BucketRuntime: bucketRuntime,
BucketClassMapper: bucketClassMapper,
BucketPoolName: opts.BucketPoolName,
WatchFilterValue: opts.WatchFilterValue,
EventRecorder: mgr.GetEventRecorderFor("buckets"),
Client: mgr.GetClient(),
Scheme: scheme,
BucketRuntime: bucketRuntime,
BucketClassMapper: bucketClassMapper,
BucketPoolName: opts.BucketPoolName,
WatchFilterValue: opts.WatchFilterValue,
MaxConcurrentReconciles: opts.MaxConcurrentReconciles,
}).SetupWithManager(mgr); err != nil {
return fmt.Errorf("error setting up bucket reconciler with manager: %w", err)
}
Expand Down
17 changes: 12 additions & 5 deletions poollet/bucketpoollet/controllers/bucket_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ import (
"fmt"

"github.com/go-logr/logr"
"github.com/ironcore-dev/controller-utils/clientutils"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

storagev1alpha1 "github.com/ironcore-dev/ironcore/api/storage/v1alpha1"
iriBucket "github.com/ironcore-dev/ironcore/iri/apis/bucket"
iri "github.com/ironcore-dev/ironcore/iri/apis/bucket/v1alpha1"

irimeta "github.com/ironcore-dev/ironcore/iri/apis/meta/v1alpha1"
bucketpoolletv1alpha1 "github.com/ironcore-dev/ironcore/poollet/bucketpoollet/api/v1alpha1"
"github.com/ironcore-dev/ironcore/poollet/bucketpoollet/bcm"
"github.com/ironcore-dev/ironcore/poollet/bucketpoollet/controllers/events"
ironcoreclient "github.com/ironcore-dev/ironcore/utils/client"
"github.com/ironcore-dev/ironcore/utils/predicates"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/ironcore-dev/controller-utils/clientutils"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -32,6 +33,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/predicate"
)
Expand All @@ -47,6 +49,8 @@ type BucketReconciler struct {

BucketPoolName string
WatchFilterValue string

MaxConcurrentReconciles int
}

func (r *BucketReconciler) iriBucketLabels(bucket *storagev1alpha1.Bucket) map[string]string {
Expand Down Expand Up @@ -432,7 +436,6 @@ func (r *BucketReconciler) updateStatus(ctx context.Context, log logr.Logger, bu
Endpoint: iriAccess.Endpoint,
}
}

}

base := bucket.DeepCopy()
Expand Down Expand Up @@ -466,6 +469,10 @@ func (r *BucketReconciler) SetupWithManager(mgr ctrl.Manager) error {
predicates.ResourceIsNotExternallyManaged(log),
),
).
WithOptions(
controller.Options{
MaxConcurrentReconciles: r.MaxConcurrentReconciles,
}).
Complete(r)
}

Expand Down
12 changes: 7 additions & 5 deletions poollet/bucketpoollet/controllers/controllers_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"testing"
"time"

"github.com/ironcore-dev/controller-utils/buildutils"
"github.com/ironcore-dev/controller-utils/modutils"
corev1alpha1 "github.com/ironcore-dev/ironcore/api/core/v1alpha1"
storagev1alpha1 "github.com/ironcore-dev/ironcore/api/storage/v1alpha1"
storageclient "github.com/ironcore-dev/ironcore/internal/client/storage"
Expand All @@ -22,8 +20,9 @@ import (
"github.com/ironcore-dev/ironcore/utils/envtest/apiserver"
"github.com/ironcore-dev/ironcore/utils/envtest/controllermanager"
"github.com/ironcore-dev/ironcore/utils/envtest/process"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/ironcore-dev/controller-utils/buildutils"
"github.com/ironcore-dev/controller-utils/modutils"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
Expand All @@ -34,10 +33,13 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
. "sigs.k8s.io/controller-runtime/pkg/envtest/komega"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "sigs.k8s.io/controller-runtime/pkg/envtest/komega"
)

var (
Expand Down
Loading
Loading