mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Add support for setting a custom rate limiter in gce cloud provider
This commit is contained in:
parent
201e15af35
commit
455fcac51c
@ -152,6 +152,9 @@ type GCECloud struct {
|
|||||||
|
|
||||||
// New code generated interface to the GCE compute library.
|
// New code generated interface to the GCE compute library.
|
||||||
c cloud.Cloud
|
c cloud.Cloud
|
||||||
|
|
||||||
|
// Keep a reference of this around so we can inject a new cloud.RateLimiter implementation.
|
||||||
|
s *cloud.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: replace gcfg with json
|
// TODO: replace gcfg with json
|
||||||
@ -508,17 +511,27 @@ func CreateGCECloud(config *CloudConfig) (*GCECloud, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gce.manager = &gceServiceManager{gce}
|
gce.manager = &gceServiceManager{gce}
|
||||||
gce.c = cloud.NewGCE(&cloud.Service{
|
gce.s = &cloud.Service{
|
||||||
GA: service,
|
GA: service,
|
||||||
Alpha: serviceAlpha,
|
Alpha: serviceAlpha,
|
||||||
Beta: serviceBeta,
|
Beta: serviceBeta,
|
||||||
ProjectRouter: &gceProjectRouter{gce},
|
ProjectRouter: &gceProjectRouter{gce},
|
||||||
RateLimiter: &gceRateLimiter{gce},
|
RateLimiter: &gceRateLimiter{gce},
|
||||||
})
|
}
|
||||||
|
gce.c = cloud.NewGCE(gce.s)
|
||||||
|
|
||||||
return gce, nil
|
return gce, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetRateLimiter adds a custom cloud.RateLimiter implementation.
|
||||||
|
// WARNING: Calling this could have unexpected behavior if you have in-flight
|
||||||
|
// requests. It is best to use this immediately after creating a GCECloud.
|
||||||
|
func (g *GCECloud) SetRateLimiter(rl cloud.RateLimiter) {
|
||||||
|
if rl != nil {
|
||||||
|
g.s.RateLimiter = rl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// determineSubnetURL queries for all subnetworks in a region for a given network and returns
|
// determineSubnetURL queries for all subnetworks in a region for a given network and returns
|
||||||
// the URL of the subnetwork which exists in the auto-subnet range.
|
// the URL of the subnetwork which exists in the auto-subnet range.
|
||||||
func determineSubnetURL(service *compute.Service, networkProjectID, networkName, region string) (string, error) {
|
func determineSubnetURL(service *compute.Service, networkProjectID, networkName, region string) (string, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user