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

Implementing new cloud provider method for node deletion detection #1

Merged
merged 5 commits into from
Oct 17, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ func (ali *aliCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.N
return ali.manager.GetAsgForInstance(instanceId)
}

// NodeExists returns whether node exists in this cloud provider
func (ali *aliCloudProvider) NodeExists(*apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not available.
func (ali *aliCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
return nil, cloudprovider.ErrNotImplemented
Expand Down
5 changes: 5 additions & 0 deletions cluster-autoscaler/cloudprovider/aws/aws_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ func (aws *awsCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.N
}, nil
}

// NodeExists returns whether node exists in this cloud provider
func (aws *awsCloudProvider) NodeExists(*apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not available.
func (aws *awsCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
return nil, cloudprovider.ErrNotImplemented
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ func (azure *AzureCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovid
return azure.azureManager.GetNodeGroupForInstance(ref)
}

// NodeExists returns whether node exists in this cloud provider
func (azure *AzureCloudProvider) NodeExists(*apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not available.
func (azure *AzureCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
return nil, cloudprovider.ErrNotImplemented
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ func (baiducloud *baiducloudCloudProvider) NodeGroupForNode(node *apiv1.Node) (c
return asg, err
}

// NodeExists returns whether node exists in this cloud provider
func (baiducloud *baiducloudCloudProvider) NodeExists(*apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not available.
// Implementation optional.
func (baiducloud *baiducloudCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ func (d *bizflycloudCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprov
return nil, nil
}

// NodeExists returns whether node exists in this cloud provider
func (d *bizflycloudCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not
// available. Implementation optional.
func (d *bizflycloudCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ func (b *brightboxCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovid
return nil, nil
}

// NodeExists returns whether node exists in this cloud provider
func (b *brightboxCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Refresh is before every main loop and can be used to dynamically
// update cloud provider state.
// In particular the list of node groups returned by NodeGroups can
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ func (ccp *cherryCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovide
return nil, nil
}

// NodeExists returns whether node exists in this cloud provider
func (ccp *cherryCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not available.
func (ccp *cherryCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
return nil, cloudprovider.ErrNotImplemented
Expand Down
5 changes: 5 additions & 0 deletions cluster-autoscaler/cloudprovider/civo/civo_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ func (d *civoCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.No
return nil, nil
}

// NodeExists returns whether node exists in this cloud provider
func (d *civoCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not
// available. Implementation optional.
func (d *civoCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
Expand Down
4 changes: 4 additions & 0 deletions cluster-autoscaler/cloudprovider/cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ type CloudProvider interface {
// occurred. Must be implemented.
NodeGroupForNode(*apiv1.Node) (NodeGroup, error)

// NodeExists returns whether the node exists in cloud provider,
// true if the node is available, false if it has been deleted
NodeExists(*apiv1.Node) (bool, error)

// Pricing returns pricing model for this cloud provider or error if not available.
// Implementation optional.
Pricing() (PricingModel, errors.AutoscalerError)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ func (provider *cloudStackCloudProvider) NodeGroupForNode(node *v1.Node) (cloudp
return provider.manager.clusterForNode(node)
}

// NodeExists returns whether node exists in this cloud provider
func (provider *cloudStackCloudProvider) NodeExists(node *v1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Cleanup cleans up open resources before the cloud provider is destroyed, i.e. go routines etc.
func (provider *cloudStackCloudProvider) Cleanup() error {
return provider.manager.cleanup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ func (p *provider) NodeGroupForNode(node *corev1.Node) (cloudprovider.NodeGroup,
return ng, nil
}

// NodeExists returns whether node exists in this cloud provider
func (p *provider) NodeExists(node *corev1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

func (*provider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
return nil, cloudprovider.ErrNotImplemented
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ func (d *digitaloceanCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudpro
return nil, nil
}

// NodeExists returns whether node exists in this cloud provider
func (d *digitaloceanCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not
// available. Implementation optional.
func (d *digitaloceanCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ func (e *exoscaleCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovide
return nodeGroup, nil
}

// NodeExists returns whether node exists in this cloud provider
func (e *exoscaleCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not available.
// Implementation optional.
func (e *exoscaleCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ func (e *externalGrpcCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudpro
return ng, nil
}

// NodeExists returns whether node exists in this cloud provider
func (e *externalGrpcCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// pricingModel implements cloudprovider.PricingModel interface.
type pricingModel struct {
client protos.CloudProviderClient
Expand Down
5 changes: 5 additions & 0 deletions cluster-autoscaler/cloudprovider/gce/gce_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ func (gce *GceCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.N
return mig, err
}

// NodeExists returns whether node exists in this cloud provider
func (gce *GceCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not available.
func (gce *GceCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
return gce.pricingModel, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ func (d *HetznerCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider
return group, nil
}

// NodeExists returns whether node exists in this cloud provider
func (d *HetznerCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not
// available. Implementation optional.
func (d *HetznerCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ func (hcp *huaweicloudCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudpr
return hcp.cloudServiceManager.GetAsgForInstance(instanceID)
}

// NodeExists returns whether node exists in this cloud provider
func (hcp *huaweicloudCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not available. Not implemented.
func (hcp *huaweicloudCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
return nil, cloudprovider.ErrNotImplemented
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ func (ic *IonosCloudCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprov
return nil, nil
}

// NodeExists returns whether node exists in this cloud provider
func (ic *IonosCloudCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not
// available. Implementation optional.
func (ic *IonosCloudCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ func (k *kamateraCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovide
return nil, nil
}

// NodeExists returns whether node exists in this cloud provider
func (k *kamateraCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not available.
// Implementation optional.
func (k *kamateraCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
Expand Down
5 changes: 5 additions & 0 deletions cluster-autoscaler/cloudprovider/kubemark/kubemark_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ func (kubemark *KubemarkCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloud
return nil, nil
}

// NodeExists returns whether node exists in this cloud provider
func (kubemark *KubemarkCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return false, cloudprovider.ErrNotImplemented
}

// GetAvailableMachineTypes get all machine types that can be requested from the cloud provider.
// Implementation optional.
func (kubemark *KubemarkCloudProvider) GetAvailableMachineTypes() ([]string, error) {
Expand Down
5 changes: 5 additions & 0 deletions cluster-autoscaler/cloudprovider/kubemark/kubemark_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ func (kubemark *KubemarkCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloud
return nil, cloudprovider.ErrNotImplemented
}

// NodeExists returns whether node exists in this cloud provider
func (kubemark *KubemarkCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

// GetAvailableMachineTypes get all machine types that can be requested from the cloud provider.
// Implementation optional.
func (kubemark *KubemarkCloudProvider) GetAvailableMachineTypes() ([]string, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ func (l *linodeCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.
return nil, nil
}

// NodeExists returns whether node exists in this cloud provider
func (l *linodeCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not available.
// Implementation optional.
func (l *linodeCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ func (mcp *magnumCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovide
return nil, nil
}

// NodeExists returns whether node exists in this cloud provider
func (mcp *magnumCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

// Pricing is not implemented.
func (mcp *magnumCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
return nil, cloudprovider.ErrNotImplemented
Expand Down
23 changes: 23 additions & 0 deletions cluster-autoscaler/cloudprovider/mocks/CloudProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,29 @@ func (_m *CloudProvider) NodeGroupForNode(_a0 *v1.Node) (cloudprovider.NodeGroup
return r0, r1
}

// NodeExists provides a mock function with given fields:
func (_m *CloudProvider) NodeExists(_a0 *v1.Node) (bool, error) {
ret := _m.Called(_a0)

var r0 bool
if rf, ok := ret.Get(0).(func(*v1.Node) bool); ok {
r0 = rf(_a0)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(bool)
}
}

var r1 error
if rf, ok := ret.Get(1).(func(*v1.Node) error); ok {
r1 = rf(_a0)
} else {
r1 = ret.Error(1)
}

return r0, r1
}

// NodeGroups provides a mock function with given fields:
func (_m *CloudProvider) NodeGroups() []cloudprovider.NodeGroup {
ret := _m.Called()
Expand Down
5 changes: 5 additions & 0 deletions cluster-autoscaler/cloudprovider/oci/oci_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ func (ocp *OciCloudProvider) NodeGroupForNode(n *apiv1.Node) (cloudprovider.Node
return ng, err
}

// NodeExists returns whether node exists in this cloud provider
func (ocp *OciCloudProvider) NodeExists(n *apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not available.
// Implementation optional.
func (ocp *OciCloudProvider) Pricing() (cloudprovider.PricingModel, caerrors.AutoscalerError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ func (provider *OVHCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovi
return ng, err
}

// NodeExists returns whether node exists in this cloud provider
func (provider *OVHCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

// findNodeGroupFromCache tries to retrieve the associated node group from an already built mapping in cache
func (provider *OVHCloudProvider) findNodeGroupFromCache(providerID string) cloudprovider.NodeGroup {
if ng, ok := provider.manager.NodeGroupPerProviderID[providerID]; ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ func (pcp *packetCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovide
return nil, fmt.Errorf("Could not find group for node: %s", node.Spec.ProviderID)
}

// NodeExists returns whether node exists in this cloud provider
func (pcp *packetCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

// Pricing returns pricing model for this cloud provider or error if not available.
func (pcp *packetCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
return &PacketPriceModel{}, nil
Expand Down
5 changes: 5 additions & 0 deletions cluster-autoscaler/cloudprovider/rancher/rancher_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ func (provider *RancherCloudProvider) NodeGroupForNode(node *corev1.Node) (cloud
return nil, nil
}

// NodeExists returns whether node exists in this cloud provider
func (provider *RancherCloudProvider) NodeExists(node *corev1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

// GetAvailableMachineTypes get all machine types that can be requested from the cloud provider.
// Implementation optional.
func (provider *RancherCloudProvider) GetAvailableMachineTypes() ([]string, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ func (scw *scalewayCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovi
return scw.nodeGroupForNode(node)
}

// NodeExists returns whether node exists in this cloud provider
func (scw *scalewayCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

func (scw *scalewayCloudProvider) NodePrice(node *apiv1.Node, startTime time.Time, endTime time.Time) (float64, error) {
ng, err := scw.nodeGroupForNode(node)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ func (tencentcloud *tencentCloudProvider) NodeGroupForNode(node *apiv1.Node) (cl
return asg, nil
}

// NodeExists returns whether node exists in this cloud provider
func (tencentcloud *tencentCloudProvider) NodeExists(node *apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

// GPULabel returns the label added to nodes with GPU resource.
func (tencentcloud *tencentCloudProvider) GPULabel() string {
return GPULabel
Expand Down
Loading