Skip to content

Commit

Permalink
Parameterize GcePriceInfo into GcePriceModel for capability to expand…
Browse files Browse the repository at this point in the history
… to different PriceInfo
  • Loading branch information
jayantjain93 committed May 9, 2022
1 parent a816268 commit b3b1c9f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cluster-autoscaler/cloudprovider/gce/gce_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (gce *GceCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.N

// Pricing returns pricing model for this cloud provider or error if not available.
func (gce *GceCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
return NewGcePriceModel(), nil
return NewGcePriceModel(NewGcePriceInfo()), nil
}

// GetAvailableMachineTypes get all machine types that can be requested from the cloud provider.
Expand Down
4 changes: 2 additions & 2 deletions cluster-autoscaler/cloudprovider/gce/gce_price_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ type GcePriceModel struct {
}

// NewGcePriceModel gets a new instance of GcePriceModel
func NewGcePriceModel() *GcePriceModel {
func NewGcePriceModel(info PriceInfo) *GcePriceModel {
return &GcePriceModel{
PriceInfo: NewGcePriceInfo(),
PriceInfo: info,
}
}

Expand Down
4 changes: 2 additions & 2 deletions cluster-autoscaler/cloudprovider/gce/gce_price_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func TestGetNodePrice(t *testing.T) {

for tn, tc := range cases {
t.Run(tn, func(t *testing.T) {
model := NewGcePriceModel()
model := NewGcePriceModel(NewGcePriceInfo())
now := time.Now()

price1, err := model.NodePrice(tc.cheaperNode, now, now.Add(time.Hour))
Expand All @@ -193,7 +193,7 @@ func TestGetPodPrice(t *testing.T) {
pod1 := BuildTestPod("a1", 100, 500*units.MiB)
pod2 := BuildTestPod("a2", 2*100, 2*500*units.MiB)

model := NewGcePriceModel()
model := NewGcePriceModel(NewGcePriceInfo())
now := time.Now()

price1, err := model.PodPrice(pod1, now, now.Add(time.Hour))
Expand Down

0 comments on commit b3b1c9f

Please sign in to comment.