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

[BEAM-8626] Implement status fn api handler in python sdk #10598

Merged
merged 4 commits into from Jan 28, 2020

Conversation

y1chi
Copy link
Contributor

@y1chi y1chi commented Jan 15, 2020

Please add a meaningful description for your change here


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

Post-Commit Tests Status (on master branch)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- Build Status --- --- Build Status
Java Build Status Build Status Build Status Build Status
Build Status
Build Status
Build Status Build Status Build Status
Build Status
Build Status
Python Build Status
Build Status
Build Status
Build Status
--- Build Status
Build Status
Build Status
Build Status
--- --- Build Status
XLang --- --- --- Build Status --- --- ---

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website
Non-portable Build Status Build Status
Build Status
Build Status Build Status
Portable --- Build Status --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

@y1chi y1chi requested a review from angoenka January 15, 2020 18:04
@y1chi y1chi force-pushed the BEAM-8626 branch 2 times, most recently from 93665a9 to 7cc2797 Compare January 15, 2020 21:11
@y1chi
Copy link
Contributor Author

y1chi commented Jan 16, 2020

R: @angoenka

Copy link
Contributor

@angoenka angoenka left a comment

Choose a reason for hiding this comment

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

Thanks @y1chi !

sdks/python/apache_beam/runners/test/utils.py Outdated Show resolved Hide resolved
sdks/python/apache_beam/runners/worker/sdk_worker.py Outdated Show resolved Hide resolved
@@ -110,6 +112,15 @@ def __init__(self,
data_channel_factory=self._data_channel_factory,
fns=self._fns)

if status_address:
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 move it in sdk_worker_main where we keep other reporting related code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to do the actual initialization inside sdk_worker since I want to pass the active bundle cache in sdk worker in order to report the dangling operation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good

from apache_beam.runners.worker.worker_id_interceptor import WorkerIdInterceptor


def thread_dump():
Copy link
Contributor

Choose a reason for hiding this comment

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

We have thread dump code in sdk_worker_main.py under get_thread_dump.
Shall we reuse it or move it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made few changes to the thread dump format. I'll reuse the function, I think eventually we probably won't need the status http server.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, we can get rid of status http server.

Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned above, Lets add a jira to clean StatusServer in sdk_worker_main

beam_fn_api_pb2.WorkerStatusResponse(id=request.id,
status_info=response))

def generate_status_response(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

We can also expose it over a http server on dynamic port.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's possible but since eventually we'll be able to query the runner like localhost:port/sdk_status?id=<sdk_id>, it has same effect as exposing it individually.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds reasonable.

sdks/python/apache_beam/runners/worker/worker_status.py Outdated Show resolved Hide resolved
sdks/python/apache_beam/runners/worker/worker_status.py Outdated Show resolved Hide resolved
@y1chi
Copy link
Contributor Author

y1chi commented Jan 21, 2020

retest this please

Copy link
Contributor

@angoenka angoenka left a comment

Choose a reason for hiding this comment

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

LGTM.
Few minor comments.

@@ -110,6 +112,15 @@ def __init__(self,
data_channel_factory=self._data_channel_factory,
fns=self._fns)

if status_address:
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good

status_address, self._bundle_processor_cache)
except Exception:
traceback_string = traceback.format_exc()
_LOGGER.info('Error creating worker status request handler, skipping '
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
_LOGGER.info('Error creating worker status request handler, skipping '
_LOGGER.warn('Error creating worker status request handler, skipping '

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@@ -78,8 +67,7 @@ def do_GET(self): # pylint: disable=invalid-name
self.send_header('Content-Type', 'text/plain')
self.end_headers()

for line in StatusServer.get_thread_dump():
self.wfile.write(line.encode('utf-8'))
self.wfile.write(thread_dump())
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets add a jira to clean StatusServer from here completely once we have rolled out Debug capture.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from apache_beam.runners.worker.worker_id_interceptor import WorkerIdInterceptor


def thread_dump():
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned above, Lets add a jira to clean StatusServer in sdk_worker_main

stack_traces[stack_trace].append(thread_ident_name)

all_traces = ['=' * 10 + 'THREAD DUMP' + '=' * 10]
for stack, identity in stack_traces.items():
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 add a jira to group threads which have same thread stack for easier analysis and reducing text size.
This can be a starter task for new beam contributors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isn't it already included in this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right. It's already in this PR.
We can print names of all the threads along with count so that we don't miss any information.

return '\n'.join(x.encode('utf-8') for x in all_traces)


def active_processing_bundles_state(bundle_process_cache):
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be private method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

stack_traces[stack_trace].append(thread_ident_name)

all_traces = ['=' * 10 + 'THREAD DUMP' + '=' * 10]
for stack, identity in stack_traces.items():
Copy link
Contributor

Choose a reason for hiding this comment

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

You are right. It's already in this PR.
We can print names of all the threads along with count so that we don't miss any information.

all_traces = ['=' * 10 + 'THREAD DUMP' + '=' * 10]
for stack, identity in stack_traces.items():
ident, name = identity[0]
trace = '--- Thread #%s name: %s %s---\n' % (
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
trace = '--- Thread #%s name: %s %s---\n' % (
trace = '--- Threads (%d) %s --- \n' % (len(identity), [ident+':'+name for (ident, name) in identity])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is already printed in a separated line below.

Copy link
Contributor

@angoenka angoenka left a comment

Choose a reason for hiding this comment

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

Thanks!
LGTM

@angoenka
Copy link
Contributor

Retest this please

1 similar comment
@angoenka
Copy link
Contributor

Retest this please

@angoenka
Copy link
Contributor

Run Python PreCommit

@y1chi
Copy link
Contributor Author

y1chi commented Jan 23, 2020

Retest this please

1 similar comment
@angoenka
Copy link
Contributor

Retest this please

@y1chi
Copy link
Contributor Author

y1chi commented Jan 23, 2020

retest this please

@angoenka
Copy link
Contributor

Retest this please

@angoenka
Copy link
Contributor

Run Dataflow ValidatesRunner

@angoenka
Copy link
Contributor

I am not sure why the tests are not running on this PR.

@y1chi
Copy link
Contributor Author

y1chi commented Jan 23, 2020

retest this please

1 similar comment
@angoenka
Copy link
Contributor

retest this please

@angoenka
Copy link
Contributor

@y1chi
Copy link
Contributor Author

y1chi commented Jan 24, 2020

retest this please

@angoenka
Copy link
Contributor

retest this please

1 similar comment
@angoenka
Copy link
Contributor

retest this please

@y1chi
Copy link
Contributor Author

y1chi commented Jan 28, 2020

Run PythonLint PreCommit

2 similar comments
@angoenka
Copy link
Contributor

Run PythonLint PreCommit

@angoenka
Copy link
Contributor

Run PythonLint PreCommit

@angoenka angoenka merged commit d1b70d6 into apache:master Jan 28, 2020
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.

None yet

2 participants