From bb7468a3a758aca957d3778881072447bc1fcb98 Mon Sep 17 00:00:00 2001 From: Nick Tran <10810510+njtran@users.noreply.github.com> Date: Thu, 15 Aug 2024 10:03:20 -0700 Subject: [PATCH] feat: add cloud provider disruption reasons (#1574) --- kwok/cloudprovider/cloudprovider.go | 4 ++++ pkg/cloudprovider/fake/cloudprovider.go | 4 ++++ pkg/cloudprovider/types.go | 3 +++ 3 files changed, 11 insertions(+) diff --git a/kwok/cloudprovider/cloudprovider.go b/kwok/cloudprovider/cloudprovider.go index 75692a6569..85537ecdb6 100644 --- a/kwok/cloudprovider/cloudprovider.go +++ b/kwok/cloudprovider/cloudprovider.go @@ -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) { diff --git a/pkg/cloudprovider/fake/cloudprovider.go b/pkg/cloudprovider/fake/cloudprovider.go index a9ff7cd66b..bf5e80fcf4 100644 --- a/pkg/cloudprovider/fake/cloudprovider.go +++ b/pkg/cloudprovider/fake/cloudprovider.go @@ -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() diff --git a/pkg/cloudprovider/types.go b/pkg/cloudprovider/types.go index 2115c5971f..b4ec654859 100644 --- a/pkg/cloudprovider/types.go +++ b/pkg/cloudprovider/types.go @@ -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)