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

Skip collecting logs and events on failure via env var #239

Merged
merged 7 commits into from
Jan 18, 2018

Conversation

dturn
Copy link
Contributor

@dturn dturn commented Jan 12, 2018

When a bunch (~10) of deployments fail, there can be a 5+ minute delay between the polling loop completing and the statsd metric for completion being emitted. #238 sped this up by collecting logs and events in parallel. This PR goes one more step and provides a way to skip this altogether.

Open question: Should this be an env var?

@dturn dturn requested a review from KnVerey January 12, 2018 22:10
@dturn dturn changed the title Fast exit from debug_message Skip collecting logs and events on failure via env var Jan 12, 2018
Copy link
Contributor

@KnVerey KnVerey left a comment

Choose a reason for hiding this comment

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

I think this is worth trying, but we should leave it undocumented for now. Making it an env var seems okay... it's kinda a similar setting to log levels, which use env vars too. Naming is tricky though, since the most obvious choices sound like they could be talking about the gem's logging. DISABLE_FETCHING_DEBUG_INFO=1, DISABLE_KUBE_DEBUG_INFO=1, FETCH_EVENTS_AND_LOGS_ON_FAILURE=0?

I'm also wondering if we should make the logs and events switches separate. For huge deployments like the ones that are running into problems, events are significantly more useful than logs... but at a guess they're more likely the culprits of the fetch slowness.

def test_debug_message_with_no_debug_info
ENV['NO_DEBUG_INFO'] = 'true'
dummy = DummyResource.new
dummy.expects(:deploy_failed?).returns(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using a stub, let's make this settable the same way we have done for deploy_succeeded? (add an attribute and a write for that attribute)

dummy = DummyResource.new
dummy.expects(:deploy_failed?).returns(true)

assert_match dummy.debug_message,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also refute that it matches - Logs or - Events

@@ -12,6 +12,7 @@ class KubernetesResource
TIMEOUT = 5.minutes
LOG_LINE_COUNT = 250

NO_DEBUG_INFO_MESSAGE = "Event and log collection is disabled by the NO_DEBUG_INFO env var."
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: let's make the env var string itself a constant too, since it's used in three places.

@dturn
Copy link
Contributor Author

dturn commented Jan 17, 2018

This is ready for a second look.

Copy link
Contributor

@KnVerey KnVerey left a comment

Choose a reason for hiding this comment

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

Please fix the indentation issue and then 🎩 with test_deploy_result_logging_for_mixed_result_deploy to confirm that it looks right. Other than that, looks good to me!

@@ -169,12 +173,16 @@ def debug_message
@events.each do |identifier, event_hashes|
event_hashes.each { |event| helpful_info << " [#{identifier}]\t#{event}" }
end
elsif ENV[DISABLE_FETCHING_EVENT_INFO]
helpful_info << DISABLED_EVENT_INFO_MESSAGE
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably indent this (and the log message) with " - " like we do with the actual info. Looks a bit out of place:

image

image

(I'm using test_deploy_result_logging_for_mixed_result_deploy to see that)

@dturn dturn merged commit 1df2474 into master Jan 18, 2018
@dturn dturn deleted the faster-debug-message-gathering branch January 18, 2018 16:12
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