-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[POC] Feature/introduce amd to MOVE #31851
Conversation
Codecov Report
@@ Coverage Diff @@
## master #31851 +/- ##
============================================
- Coverage 64% 63.62% -0.38%
- Complexity 18578 18594 +16
============================================
Files 1171 1176 +5
Lines 69912 69772 -140
Branches 1267 1264 -3
============================================
- Hits 44746 44393 -353
- Misses 24796 25010 +214
+ Partials 370 369 -1
Continue to review full report at Codecov.
|
try with "Content-Location" then. we did that for other DAV APIs |
it's not strictly the entity's location, so maybe call it "Queue-Location" or "OC-Queue-Location" ? |
apps/dav/lib/DAV/LazyOpsPlugin.php
Outdated
} | ||
|
||
public function httpMove(RequestInterface $request, ResponseInterface $response) { | ||
if (!$request->getHeader('OC-LazyOps')) { |
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.
we could call this "Queue" or something referring to the queue, so we have the same terminology everywhere
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.
absolutly - I'm not yet fully convincent with the resource name 'queue' as well - since it is not a queue ....
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.
interesting concept
The queue could also be used to track stray/stuck uploads and clean up chunks afterwards. This would require using the queue earlier when dealing with chunks. Or needs a completely separate mechanism.
apps/dav/lib/DAV/LazyOpsPlugin.php
Outdated
|
||
$response->setStatus(202); | ||
$response->addHeader('Connection', 'close'); | ||
$response->addHeader('OC-Location', $location); |
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.
OC-Queue-Location ?
]); | ||
$this->server->emit('method:MOVE', [$request, $responseDummy]); | ||
|
||
$this->setJobStatus([ |
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.
if we can store the final file name in there we could solve a lot of problems, like the fact that encryption relies on the part file name and uses magic extraction to find the final file name... here it could just read from the upload queue
speaking of which... does this work with user-key encryption ? cron doesn't have the user's private key so cannot encrypt...
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.
the execution is not done in cron - but in the original client request.
The difference is that we defer the execution to PHP's shutdown handler which is called after the response is sent back to the client
Good. This more or less follow the design that was already done in the client and documented in #12097 so implementation in the client can re-use that. (although that code sort of bit-rotted and was not ported to new chunking) |
\sleep(1); | ||
} | ||
|
||
if (connection_aborted()) { |
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.
\
apps/dav/lib/DAV/LazyOpsPlugin.php
Outdated
private $jobId; | ||
|
||
public static function getQueueInfo(string $userId, string $jobId) { | ||
return \OC::$server->getConfig()->getUserValue($userId, 'dav', "lazy-ops-job.$jobId", null, false); |
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.
I assume you are going to replace this with a proper queue table ...
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.
or use a file property ... config is really not the place for this ....
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.
sure - this was for the sake of fast POC
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.
Could you use the existing oc_jobs? Insert as a 'already reserved' job, and add a status column?
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.
Could you use the existing oc_jobs? Insert as a 'already reserved' job, and add a status column?
hmmmm - let me think about this ....
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.
I don't think so - there is no way to select the job status by it's id where the is is a uuid ....
... and also the processing logic will not work.
In order to detect that the connection was closed by the client the server needs to send something over the wire. |
handled by the used library https://github.com/hhxsv5/php-sse/releases/tag/1.1.4 |
a6192ed
to
0266157
Compare
d3783cd
to
805a99b
Compare
805a99b
to
1e3d5bb
Compare
f3bb9fd
to
aab4804
Compare
aab4804
to
57ce13c
Compare
57ce13c
to
c1c2671
Compare
@PVince81 needs backport for 10, see https://github.com/owncloud/enterprise/issues/2480 |
We have to analyse the impact of SSE to the system. Following the semver definitions this is nothing to be added to 10.0.x but to 10.1 |
c1c2671
to
e2ad740
Compare
e2ad740
to
5042ce9
Compare
5042ce9
to
cef6bdc
Compare
@@ -86,6 +90,17 @@ public function __construct(IRequest $request, $baseUri) { | |||
$tree = new \OCA\DAV\Tree($root); | |||
$this->server = new \OCA\DAV\Connector\Sabre\Server($tree); | |||
|
|||
$config = \OC::$server->getConfig(); | |||
if ($config->getSystemValue('dav.enable.async', 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.
for this backport version I think we should disable this by default ?
the stable10 simplified version got merged. Here's its master port: #32576 |
Description
We want to avoid situations where the clients have to wait for the long MOVE operation on assembly to finish. The connection can be terminated by any reason before the server sends the response back to the client. And after that the client has no capability to query for the status of the assembly.
AMD - Asynchronous Method Dispatch
We return the http status code 202 right after we received the MOVE request. The client can then terminate the connection and knows that the server is working on it.
The implementation uses php's register_callback functionality to process the real MOVE after the response is sent to the client. register_callback can not be terminated by the system - we should be pretty save on this one ....
The 202 response will hold a header 'OC-JobStatus-Location' which will point the client to the job status endpoint
Job Status Endpoint
The job status endpoint is a DAV resource in the following format: /dav/job-status/{$userId}/{$this->jobId}. It will return a json object holding the job status information.
Server Side Event on the job status endpoint
The client can request the job status in simple request/response manner or request an event stream following the Server Side Event protocol. To initiate SSE handling the query parameter sse=1 is appended to the GET request. As a result the server will not terminate the connection but keep it open and stream job status changes to the client. The client is asked to close the connection once the status is success or error
Capabilities and LazyOps header
The server will announce to the clients via the capabilities API if this new mode of operations is available or not. A system config value is necessary to allow the admin to turn this feature explicitly on.
Furthermore in order not to break regular WebDAV client an additional http header is to be sent from the client to the server so that the server knows if this operation mode shall be used or not.
Todo
Motivation and Context
Introduce a more generic async mechanism
How Has This Been Tested?
move
Query for the status:
Types of changes
Checklist: