-
Notifications
You must be signed in to change notification settings - Fork 265
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
Dennisme/rebase pod events #631
Conversation
feat: emit pod events on drain
…ndler into dennisme/rebase-pod-events
Tests failing locally
|
@dennisme thanks for the PR. Could you include the issue # or requested feature in the description? If no issue exists, please open one with some context as to why these changes are needed/beneficial. |
Yes of course! Also next commit will fix the test 😬 |
2f6d527
to
22a31cb
Compare
ok we should be good, test fixed :) |
@@ -61,7 +63,8 @@ func TestDryRun(t *testing.T) { | |||
tNode, err := node.New(config.Config{DryRun: true}) | |||
h.Ok(t, err) | |||
|
|||
err = tNode.CordonAndDrain(nodeName, "cordonReason") | |||
fakeRecorder := record.NewFakeRecorder(100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Make this const please
- Is it necessary for the buffer size to be this large?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not, but if it set to small the tests will hang indefinitely.
@@ -98,6 +101,7 @@ func TestNewFailure(t *testing.T) { | |||
} | |||
|
|||
func TestDrainSuccess(t *testing.T) { | |||
controllerBool := true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update to be more descriptive, ex: isOwnerController
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call
h.Ok(t, err) | ||
close(fakeRecorder.Events) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to explicitly close
this channel? If so, please update and use defer
in case h.Ok
fails.
// PodEvictReason is the event reason emitted for Pod evictions during node drain | ||
PodEvictReason = "PodEviction" | ||
// PodEvictMsg is the event message emitted for Pod evictions during node drain | ||
PodEvictMsg = "Pod evicted due to node drain" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this sufficient detail for the event? Do you need it to specify that node-termination-handler initiated the drain in response to a particular AWS event (Spot ITN, ASG event, etc.)?
for k, v := range pod.GetLabels() { | ||
annotations[k] = v | ||
} | ||
recorder.AnnotatedEventf(podRef, annotations, "Normal", PodEvictReason, PodEvictMsg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should "Normal"
also be in a constant, like PodEvictReason
and PodEvictMsg
? What are the other possible values for that argument?
@@ -113,7 +113,7 @@ func InitK8sEventRecorder(enabled bool, nodeName string, sqsMode bool, nodeMetad | |||
} | |||
|
|||
broadcaster := record.NewBroadcaster() | |||
broadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: clientSet.CoreV1().Events("default")}) | |||
broadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: clientSet.CoreV1().Events("")}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide some context on this change? What is the difference in behavior between "default"
and ""
?
@@ -800,3 +827,7 @@ func filterPodForDeletion(podName string) func(pod corev1.Pod) drain.PodDeleteSt | |||
return drain.MakePodDeleteStatusOkay() | |||
} | |||
} | |||
|
|||
type recorderInterface interface { | |||
AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: eventtype
-> eventType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good catch. I agree.
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want this PR to never become stale, please ask a maintainer to apply the "stalebot-ignore" label. |
This PR was closed because it has become stale with no activity. |
Issue #635, if available:
Description of changes:
This PR rebases an earlier PR on our fork by @dthorsen that adds pod eventing to draining. We have been running this for a few months and it does help a ton with visibility.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.