mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Correct the jobs stat artifact callback contract
Local testing against the live orchestrator revealed the real artifact-callback
payload: {artifactId, artifactType, content, status} — not the id/size I'd
guessed. Match on artifactId and read the byte size from content. Also depend
the source stat on 'job' (not 'source'): the orchestrator only emits artifact
callbacks for post-job artifacts, so a pre-job stat never reports.
Known upstream gap: because the stat is post-job, its size callback lands just
after the exit callback that marks the deployment ready — so a reader at 'ready'
sees sourceSize=0 (flaky). The orchestrator fix is to surface the size by the
exit event; the reconciliation here keeps sourceSize/totalSize consistent.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
545abe046b
commit
3772b3eb6f
2 files changed
+4
-6
No files matched your search
@@ -78,7 +78,7 @@ final class Job
|
||||
// so unlike the uploaded-tarball path it can't size it. Stat the
|
||||
// downloaded archive so the orchestrator reports its byte size in
|
||||
// an artifact callback, which the worker records as sourceSize.
|
||||
new StatArtifact(id: 'sourceSize', in: 'source.tar.gz', depends: 'source'),
|
||||
new StatArtifact(id: 'sourceSize', in: 'source.tar.gz', depends: 'job'),
|
||||
];
|
||||
} else {
|
||||
// Presigned source-download URL (GET, no request-body cap), fetched by
|
||||
|
||||
@@ -168,14 +168,12 @@ class Jobs extends Action
|
||||
*/
|
||||
private function onArtifact(Database $dbForProject, Document $deployment, array $data): Document
|
||||
{
|
||||
if (($data['id'] ?? '') !== 'sourceSize') {
|
||||
if (($data['artifactId'] ?? '') !== 'sourceSize' || ($data['status'] ?? '') !== 'success') {
|
||||
return $deployment;
|
||||
}
|
||||
|
||||
// The stat callback payload shape is still settling upstream; accept the
|
||||
// size flat or nested under 'stat'.
|
||||
$stat = \is_array($data['stat'] ?? null) ? $data['stat'] : $data;
|
||||
$size = (int) ($stat['size'] ?? $stat['bytes'] ?? 0);
|
||||
// A stat artifact reports the file's byte size as its 'content'.
|
||||
$size = (int) ($data['content'] ?? 0);
|
||||
if ($size <= 0) {
|
||||
return $deployment;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user