Skip to content

Commit

Permalink
fix: Ignore K8s NotFound error on interruption delete (aws#3233)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis authored Jan 18, 2023
1 parent fb274cd commit 45a512d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 1 addition & 5 deletions pkg/controllers/interruption/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
interruptionevents "github.com/aws/karpenter/pkg/controllers/interruption/events"
"github.com/aws/karpenter/pkg/controllers/interruption/messages"
"github.com/aws/karpenter/pkg/controllers/interruption/messages/statechange"
"github.com/aws/karpenter/pkg/errors"
"github.com/aws/karpenter/pkg/utils"

"github.com/aws/karpenter-core/pkg/apis/v1alpha5"
Expand Down Expand Up @@ -203,10 +202,7 @@ func (c *Controller) handleNode(ctx context.Context, msg messages.Message, node
// deleteNode removes the node from the api-server
func (c *Controller) deleteNode(ctx context.Context, node *v1.Node) error {
if err := c.kubeClient.Delete(ctx, node); err != nil {
if errors.IsNotFound(err) {
return nil
}
return fmt.Errorf("deleting the node on interruption message, %w", err)
return client.IgnoreNotFound(fmt.Errorf("deleting the node on interruption message, %w", err))
}
logging.FromContext(ctx).Infof("deleted node from interruption message")
c.recorder.Publish(interruptionevents.NodeTerminatingOnInterruption(node))
Expand Down
4 changes: 4 additions & 0 deletions pkg/controllers/interruption/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ var _ = Describe("AWSInterruption", func() {
sqsapi.ReceiveMessageBehavior.Error.Set(awsErrWithCode("AccessDenied"), fake.MaxCalls(0))
ExpectReconcileFailed(ctx, controller, types.NamespacedName{})
})
It("should not return an error when deleting a node that is already deleted", func() {
ExpectMessagesCreated(spotInterruptionMessage(defaultInstanceID))
ExpectReconcileSucceeded(ctx, controller, types.NamespacedName{})
})
})
Context("Configuration", func() {
It("should not poll SQS if interruption queue is disabled", func() {
Expand Down

0 comments on commit 45a512d

Please sign in to comment.