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: emit pod events on drain #703

Merged
merged 3 commits into from
Oct 21, 2022
Merged

feat: emit pod events on drain #703

merged 3 commits into from
Oct 21, 2022

Conversation

trutx
Copy link
Contributor

@trutx trutx commented Oct 13, 2022

Issue #635:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This is a followup of @dennisme 's PR #631 which in turn was a followup of @dthorsen 's work. All credits should go to them. The PR was closed for being stale with some pending questions and requests. In this PR I'll just try to satisfy these and try to get it finally merged.

I'll comment the code exactly where comments or requests were in the original PR, creating links to each original question and mentioning the author, and then I'll try to answer the question or satisfy the request.

I'm also adding some minor changes to the PR: deprecating io/ioutil in favor of os.

@trutx trutx requested a review from a team as a code owner October 13, 2022 14:46
pkg/node/node.go Outdated Show resolved Hide resolved
pkg/node/node.go Outdated Show resolved Hide resolved
pkg/node/node.go Outdated Show resolved Hide resolved
@@ -61,7 +63,10 @@ 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)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@brycahta asked https://github.com/aws/aws-node-termination-handler/pull/631/files#r868317617

  • Make this const please
  • Is it necessary for the buffer size to be this large?

A record.FakeRecorder object can't be constant. We could use a global var but we could incur in concurrency problems when testing, I think it's better to just instantiate a new var scoped to every unit test.

Regarding the buffer size, I lowered it to 10.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think what Bryan meant was that the buffer size should be a const, not the entire FakeRecorder object. Right now, 10 is a magic number used in three places, and it's hard to tell what it means without a descriptive name like RecorderBufferSize.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah gotcha. Makes sense, just pushed a commit to create and use the recorderBufferSize const.

pkg/node/node_test.go Outdated Show resolved Hide resolved
@trutx
Copy link
Contributor Author

trutx commented Oct 14, 2022

Tests passed locally. Is there any way to relaunch them?

Copy link
Contributor

@snay2 snay2 left a comment

Choose a reason for hiding this comment

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

This looks good to me, other than I'd like to see the buffer size use a constant in the unit tests to ease readability.

@trutx trutx requested a review from snay2 October 20, 2022 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants