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

fix(jinad): ensure log is ready on creating flow #2279

Merged

Conversation

mohamed--abdel-maksoud
Copy link
Contributor

A minimal fix for #1812: right after creating a flow, the function keeps checking for the flow's log file (up to 1 minute).

If it is possible to have a tighter integration with fluentd, a better fix could be implemented.

@codecov
Copy link

codecov bot commented Apr 3, 2021

Codecov Report

Merging #2279 (92143ff) into master (c8fb6b6) will decrease coverage by 16.32%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #2279       +/-   ##
===========================================
- Coverage   90.42%   74.09%   -16.33%     
===========================================
  Files         211      192       -19     
  Lines       11444    10889      -555     
===========================================
- Hits        10348     8068     -2280     
- Misses       1096     2821     +1725     
Flag Coverage Δ
daemon 49.71% <ø> (-1.40%) ⬇️
jina 73.92% <ø> (-16.95%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
jina/types/request/common.py 0.00% <0.00%> (-100.00%) ⬇️
jina/jaml/parsers/default/v1.py 0.00% <0.00%> (-100.00%) ⬇️
jina/types/ndarray/sparse/numpy.py 0.00% <0.00%> (-100.00%) ⬇️
jina/types/ndarray/sparse/pytorch.py 0.00% <0.00%> (-100.00%) ⬇️
jina/types/ndarray/sparse/tensorflow.py 0.00% <0.00%> (-100.00%) ⬇️
jina/optimizers/flow_runner.py 0.00% <0.00%> (-97.78%) ⬇️
jina/optimizers/parameters.py 0.00% <0.00%> (-97.50%) ⬇️
jina/optimizers/__init__.py 0.00% <0.00%> (-97.15%) ⬇️
jina/optimizers/discovery.py 0.00% <0.00%> (-80.27%) ⬇️
jina/drivers/debug.py 23.33% <0.00%> (-73.34%) ⬇️
... and 98 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 387939b...92143ff. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Apr 3, 2021

Latency summary

Current PR yields:

  • 😶 index QPS at 904, delta to last 3 avg.: +0%
  • 😶 query QPS at 13, delta to last 3 avg.: -2%

Breakdown

Version Index QPS Query QPS
current 904 13
1.1.1 903 13

Backed by latency-tracking. Further commits will update this comment.

@jina-bot jina-bot added size/M area/testing This issue/PR affects testing and removed size/S labels Apr 4, 2021
@bwanglzu bwanglzu requested review from deepankarm and removed request for davidbp and Roshanjossey April 6, 2021 06:05
Copy link
Member

@deepankarm deepankarm left a comment

Choose a reason for hiding this comment

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

Thanks for the awesome PR @mohamed--abdel-maksoud.

Few points:

  • The adapter of jinad + fluentd to stream logs (jina dashboard) already takes care of Right after starting a flow, GET logs sends 404 #1812 on the frontend code.
  • jinad supports flow creation even when fluentd is not installed, hence we cannot rely on a local folder creation to send back flow_id.
  • Current integration of fluentd with jinad is very simple as it is local file-based and we plan to move it to a more optimal solution soon.

About the changes to the logstream endpoint, can you briefly explain how it would help us if we move away from WebSocketEndpoint?

@mohamed--abdel-maksoud
Copy link
Contributor Author

Thanks for the feedback @deepankarm

The adapter of jinad + fluentd to stream logs (jina dashboard) already takes care of #1812 on the frontend code.

Sorry, I didn't notice that part, so it is solved in dashboard?

jinad supports flow creation even when fluentd is not installed, hence we cannot rely on a local folder creation to send back flow_id.

True, there should've been a condition on jinargs.no_fluentd

how it would help us if we move away from WebSocketEndpoint?

beside being a more idiomatic way to do websockets in FastAPI, it allows us to pass query parameters (e.g. timeout). Which in turn allows unit-testing that endpoint.
A question I had while working on this is why this part was implemented as websocket? The connection is unidirectional and can be done by server-sent events. This would solve the missing documentation issue for this endpoint.

@deepankarm
Copy link
Member

A question I had while working on this is why this part was implemented as websocket? The connection is unidirectional and can be done by server-sent events. This would solve the missing documentation issue for this endpoint.

Good question. The initial implementation had bi-directional communication, hence the implementation was using websockets (and WebSocketEndpoint because of some additional logic). Ideally, we can move away to SSE, but that would need an extension library with starlette.

Since we are looking at an optimal place to store & stream fluentd logs anyway in near future, websocket based stream might be optimized/removed. I would definitely accept the PR if we only keep the websocket endpoint refactoring and remove the section with wait until _log_is_ready.

@deepankarm
Copy link
Member

Also, please rebase your branch with master to make sure CI runs.

@mohamed--abdel-maksoud
Copy link
Contributor Author

I would definitely accept the PR if we only keep the websocket endpoint refactoring and remove the section with wait until _log_is_ready
Also, please rebase your branch with master to make sure CI runs.

OK, I will update the PR this evening. Thanks for the review!

await self.disconnect(connection)


@router.websocket("/logstream/{workspace_id}/{log_id}")
Copy link
Member

Choose a reason for hiding this comment

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

Hey @mohamed--abdel-maksoud , could you please use single quote?

daemon/api/endpoints/logs.py Show resolved Hide resolved
@mohamed--abdel-maksoud
Copy link
Contributor Author

@deepankarm I did the requested changes, I also pulled latest master and rebased my branch, it says it is up to date, so I'm not sure what's missing in branch to pass CI.
Also, since the score of the PR changed, I'm also not sure the branch name should stay the same.

@mohamed--abdel-maksoud
Copy link
Contributor Author

@deepankarm I did the requested changes, I also pulled latest master and rebased my branch, it says it is up to date, so I'm not sure what's missing in branch to pass CI.

I think it's related to this issue: jitterbit/get-changed-files#4

@deepankarm
Copy link
Member

I think it's related to this issue: jitterbit/get-changed-files#4

@cristianmtr can you help here?

@@ -1,3 +1,4 @@
import asyncio
Copy link
Member

Choose a reason for hiding this comment

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

What is the motivation of adding this import?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, there used to be asyncio.sleep but I removed it.
Strange the linter didn't catch it!

@cristianmtr
Copy link
Contributor

@deepankarm I did the requested changes, I also pulled latest master and rebased my branch, it says it is up to date, so I'm not sure what's missing in branch to pass CI.

Make sure you pull the master from jina-ai/jina, not your own fork. Did you do that?

@mohamed--abdel-maksoud
Copy link
Contributor Author

@deepankarm I did the requested changes, I also pulled latest master and rebased my branch, it says it is up to date, so I'm not sure what's missing in branch to pass CI.

Make sure you pull the master from jina-ai/jina, not your own fork. Did you do that?

Thanks, that was it. I totally forgot to sync with upstream.

@deepankarm
Copy link
Member

Nice work @mohamed--abdel-maksoud

@deepankarm deepankarm requested a review from nan-wang April 9, 2021 06:42
Copy link
Member

@nan-wang nan-wang left a comment

Choose a reason for hiding this comment

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

LGTM👍

@nan-wang nan-wang merged commit 2df2af5 into jina-ai:master Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing This issue/PR affects testing size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants