Skip to content

Commit

Permalink
feat: add cloud provider disruption reasons (#1574)
Browse files Browse the repository at this point in the history
  • Loading branch information
njtran committed Aug 15, 2024
1 parent c16a97b commit bb7468a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kwok/cloudprovider/cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ func (c CloudProvider) Create(ctx context.Context, nodeClaim *v1.NodeClaim) (*v1
return c.toNodeClaim(node)
}

func (c CloudProvider) DisruptionReasons() []v1.DisruptionReason {
return nil
}

func (c CloudProvider) Delete(ctx context.Context, nodeClaim *v1.NodeClaim) error {
if err := c.kubeClient.Delete(ctx, nodeClaim); err != nil {
if errors.IsNotFound(err) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/cloudprovider/fake/cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ func (c *CloudProvider) GetInstanceTypes(_ context.Context, np *v1.NodePool) ([]
}, nil
}

func (c *CloudProvider) DisruptionReasons() []v1.DisruptionReason {
return nil
}

func (c *CloudProvider) Delete(_ context.Context, nc *v1.NodeClaim) error {
c.mu.Lock()
defer c.mu.Unlock()
Expand Down
3 changes: 3 additions & 0 deletions pkg/cloudprovider/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ type CloudProvider interface {
// availability, the GetInstanceTypes method should always return all instance types,
// even those with no offerings available.
GetInstanceTypes(context.Context, *v1.NodePool) ([]*InstanceType, error)
// DisruptionReasons is for CloudProviders to hook into the Disruption Controller.
// Reasons will show up as StatusConditions on the NodeClaim.
DisruptionReasons() []v1.DisruptionReason
// IsDrifted returns whether a NodeClaim has drifted from the provisioning requirements
// it is tied to.
IsDrifted(context.Context, *v1.NodeClaim) (DriftReason, error)
Expand Down

0 comments on commit bb7468a

Please sign in to comment.