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

feat: ability to emit Kubernetes events #411

Merged
merged 17 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 1 addition & 4 deletions pkg/monitor/sqsevent/ec2-state-change-event.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (m SQSMonitor) ec2StateChangeToInterruptionEvent(event EventBridgeEvent, me
if err != nil {
return monitor.InterruptionEvent{}, err
}
asgName, err := m.retrieveAutoScalingGroupName(ec2StateChangeDetail.InstanceID)
asgName, _ := m.retrieveAutoScalingGroupName(ec2StateChangeDetail.InstanceID)
interruptionEvent := monitor.InterruptionEvent{
EventID: fmt.Sprintf("ec2-state-change-event-%x", event.ID),
Kind: SQSTerminateKind,
Expand All @@ -75,9 +75,6 @@ func (m SQSMonitor) ec2StateChangeToInterruptionEvent(event EventBridgeEvent, me
InstanceID: ec2StateChangeDetail.InstanceID,
Description: fmt.Sprintf("EC2 State Change event received. Instance went into %s at %s \n", ec2StateChangeDetail.State, event.getTime()),
}
if err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this error handling here made the ec2-state-change-sqs-test test fail. Not sure if swallowing this error is the way to go but this is out of the scope of this PR. I'm just replacing err with _ for the sake of the linter but IMO this should be revisited.

Valid also for pkg/monitor/sqsevent/rebalance-recommendation-event.go and pkg/monitor/sqsevent/spot-itn-event.go

return monitor.InterruptionEvent{}, err
}

interruptionEvent.PostDrainTask = func(interruptionEvent monitor.InterruptionEvent, n node.Node) error {
errs := m.deleteMessages([]*sqs.Message{message})
Expand Down
6 changes: 1 addition & 5 deletions pkg/monitor/sqsevent/rebalance-recommendation-event.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ func (m SQSMonitor) rebalanceRecommendationToInterruptionEvent(event EventBridge
if err != nil {
return monitor.InterruptionEvent{}, err
}
asgName, err := m.retrieveAutoScalingGroupName(rebalanceRecDetail.InstanceID)
if err != nil {
return monitor.InterruptionEvent{}, err
}

asgName, _ := m.retrieveAutoScalingGroupName(rebalanceRecDetail.InstanceID)
interruptionEvent := monitor.InterruptionEvent{
EventID: fmt.Sprintf("rebalance-recommendation-event-%x", event.ID),
Kind: SQSTerminateKind,
Expand Down
6 changes: 1 addition & 5 deletions pkg/monitor/sqsevent/spot-itn-event.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ func (m SQSMonitor) spotITNTerminationToInterruptionEvent(event EventBridgeEvent
if err != nil {
return monitor.InterruptionEvent{}, err
}
asgName, err := m.retrieveAutoScalingGroupName(spotInterruptionDetail.InstanceID)
if err != nil {
return monitor.InterruptionEvent{}, err
}

asgName, _ := m.retrieveAutoScalingGroupName(spotInterruptionDetail.InstanceID)
interruptionEvent := monitor.InterruptionEvent{
EventID: fmt.Sprintf("spot-itn-event-%x", event.ID),
Kind: SQSTerminateKind,
Expand Down