-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move MaxNodeProvisionTime to NodeGroupAutoscalingOptions
- Loading branch information
Showing
16 changed files
with
242 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
cluster-autoscaler/clusterstate/max_node_provision_time_provider.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package clusterstate | ||
|
||
import ( | ||
"time" | ||
|
||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider" | ||
"k8s.io/autoscaler/cluster-autoscaler/context" | ||
"k8s.io/autoscaler/cluster-autoscaler/processors/nodegroupconfig" | ||
) | ||
|
||
type maxNodeProvisionTimeProvider interface { | ||
// GetMaxNodeProvisionTime returns MaxNodeProvisionTime value that should be used for the given NodeGroup. | ||
GetMaxNodeProvisionTime(nodeGroup cloudprovider.NodeGroup) (time.Duration, error) | ||
} | ||
|
||
// NewDefaultMaxNodeProvisionTimeProvider returns the default maxNodeProvisionTimeProvider which uses the NodeGroupConfigProcessor. | ||
func NewDefaultMaxNodeProvisionTimeProvider(context *context.AutoscalingContext, nodeGroupConfigProcessor nodegroupconfig.NodeGroupConfigProcessor) maxNodeProvisionTimeProvider { | ||
return &defultMaxNodeProvisionTimeProvider{context: context, nodeGroupConfigProcessor: nodeGroupConfigProcessor} | ||
} | ||
|
||
type defultMaxNodeProvisionTimeProvider struct { | ||
context *context.AutoscalingContext | ||
nodeGroupConfigProcessor nodegroupconfig.NodeGroupConfigProcessor | ||
} | ||
|
||
// GetMaxNodeProvisionTime returns MaxNodeProvisionTime value that should be used for the given NodeGroup. | ||
func (p *defultMaxNodeProvisionTimeProvider) GetMaxNodeProvisionTime(nodeGroup cloudprovider.NodeGroup) (time.Duration, error) { | ||
return p.nodeGroupConfigProcessor.GetMaxNodeProvisionTime(p.context, nodeGroup) | ||
} | ||
|
||
// NewStaticMaxNodeProvisionTimeProvider returns static maxNodeProvisionTimeProvider which returns constant MaxNodeProvisionTime for every NodeGroup. Can be used for convenient testing. | ||
func NewStaticMaxNodeProvisionTimeProvider(maxNodeProvisionTime time.Duration) maxNodeProvisionTimeProvider { | ||
return &staticMaxNodeProvisionTimeProvider{maxNodeProvisionTime} | ||
} | ||
|
||
type staticMaxNodeProvisionTimeProvider struct { | ||
staticMaxNodeProvisionTime time.Duration | ||
} | ||
|
||
// GetMaxNodeProvisionTime returns constant MaxNodeProvisionTime value that should be used for every NodeGroup. | ||
func (p *staticMaxNodeProvisionTimeProvider) GetMaxNodeProvisionTime(cloudprovider.NodeGroup) (time.Duration, error) { | ||
return p.staticMaxNodeProvisionTime, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.