Merge pull request #5224 from appwrite/feat-db-pools-fix-scheduler
Fix scheduler bugs
This commit is contained in:
commit
b1c5457351
|
@ -85,6 +85,7 @@ App::post('/v1/functions')
|
||||||
'deployment' => '',
|
'deployment' => '',
|
||||||
'events' => $events,
|
'events' => $events,
|
||||||
'schedule' => $schedule,
|
'schedule' => $schedule,
|
||||||
|
'scheduleInternalId' => '',
|
||||||
'timeout' => $timeout,
|
'timeout' => $timeout,
|
||||||
'search' => implode(' ', [$functionId, $name, $runtime])
|
'search' => implode(' ', [$functionId, $name, $runtime])
|
||||||
]));
|
]));
|
||||||
|
@ -420,12 +421,10 @@ App::put('/v1/functions/:functionId')
|
||||||
])));
|
])));
|
||||||
|
|
||||||
$schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId'));
|
$schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId'));
|
||||||
|
|
||||||
$schedule
|
$schedule
|
||||||
->setAttribute('resourceUpdatedAt', DateTime::now())
|
->setAttribute('resourceUpdatedAt', DateTime::now())
|
||||||
->setAttribute('schedule', $function->getAttribute('schedule'))
|
->setAttribute('schedule', $function->getAttribute('schedule'))
|
||||||
->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment')));
|
->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment')));
|
||||||
|
|
||||||
Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule));
|
Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule));
|
||||||
|
|
||||||
$eventsInstance->setParam('functionId', $function->getId());
|
$eventsInstance->setParam('functionId', $function->getId());
|
||||||
|
@ -478,7 +477,7 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId')
|
||||||
|
|
||||||
$function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [
|
$function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [
|
||||||
'deploymentInternalId' => $deployment->getInternalId(),
|
'deploymentInternalId' => $deployment->getInternalId(),
|
||||||
'deployment' => $deployment->getId()
|
'deployment' => $deployment->getId(),
|
||||||
])));
|
])));
|
||||||
|
|
||||||
$schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId'));
|
$schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId'));
|
||||||
|
@ -528,12 +527,9 @@ App::delete('/v1/functions/:functionId')
|
||||||
}
|
}
|
||||||
|
|
||||||
$schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId'));
|
$schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId'));
|
||||||
|
|
||||||
$schedule
|
$schedule
|
||||||
->setAttribute('resourceUpdatedAt', DateTime::now())
|
->setAttribute('resourceUpdatedAt', DateTime::now())
|
||||||
->setAttribute('active', false)
|
->setAttribute('active', false);
|
||||||
;
|
|
||||||
|
|
||||||
Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule));
|
Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule));
|
||||||
|
|
||||||
$deletes
|
$deletes
|
||||||
|
@ -1355,6 +1351,13 @@ App::post('/v1/functions/:functionId/variables')
|
||||||
|
|
||||||
$dbForProject->deleteCachedDocument('functions', $function->getId());
|
$dbForProject->deleteCachedDocument('functions', $function->getId());
|
||||||
|
|
||||||
|
$schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId'));
|
||||||
|
$schedule
|
||||||
|
->setAttribute('resourceUpdatedAt', DateTime::now())
|
||||||
|
->setAttribute('schedule', $function->getAttribute('schedule'))
|
||||||
|
->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment')));
|
||||||
|
Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule));
|
||||||
|
|
||||||
$response
|
$response
|
||||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||||
->dynamic($variable, Response::MODEL_VARIABLE);
|
->dynamic($variable, Response::MODEL_VARIABLE);
|
||||||
|
@ -1479,6 +1482,13 @@ App::put('/v1/functions/:functionId/variables/:variableId')
|
||||||
|
|
||||||
$dbForProject->deleteCachedDocument('functions', $function->getId());
|
$dbForProject->deleteCachedDocument('functions', $function->getId());
|
||||||
|
|
||||||
|
$schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId'));
|
||||||
|
$schedule
|
||||||
|
->setAttribute('resourceUpdatedAt', DateTime::now())
|
||||||
|
->setAttribute('schedule', $function->getAttribute('schedule'))
|
||||||
|
->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment')));
|
||||||
|
Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule));
|
||||||
|
|
||||||
$response->dynamic($variable, Response::MODEL_VARIABLE);
|
$response->dynamic($variable, Response::MODEL_VARIABLE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1526,5 +1536,12 @@ App::delete('/v1/functions/:functionId/variables/:variableId')
|
||||||
|
|
||||||
$dbForProject->deleteCachedDocument('functions', $function->getId());
|
$dbForProject->deleteCachedDocument('functions', $function->getId());
|
||||||
|
|
||||||
|
$schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId'));
|
||||||
|
$schedule
|
||||||
|
->setAttribute('resourceUpdatedAt', DateTime::now())
|
||||||
|
->setAttribute('schedule', $function->getAttribute('schedule'))
|
||||||
|
->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment')));
|
||||||
|
Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule));
|
||||||
|
|
||||||
$response->noContent();
|
$response->noContent();
|
||||||
});
|
});
|
||||||
|
|
|
@ -93,7 +93,7 @@ Server::setResource('execute', function () {
|
||||||
'response' => '',
|
'response' => '',
|
||||||
'stderr' => '',
|
'stderr' => '',
|
||||||
'duration' => 0.0,
|
'duration' => 0.0,
|
||||||
'search' => implode(' ', [$functionId, $executionId]),
|
'search' => implode(' ', [$function->getId(), $executionId]),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
// TODO: @Meldiron Trigger executions.create event here
|
// TODO: @Meldiron Trigger executions.create event here
|
||||||
|
|
|
@ -156,6 +156,16 @@ class V17 extends Migration
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
Console::warning("'scheduleInternalId' from {$id}: {$th->getMessage()}");
|
Console::warning("'scheduleInternalId' from {$id}: {$th->getMessage()}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* Delete 'scheduleUpdatedAt' attribute
|
||||||
|
*/
|
||||||
|
$this->projectDB->deleteAttribute($id, 'scheduleUpdatedAt');
|
||||||
|
$this->projectDB->deleteCachedCollection($id);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Console::warning("'scheduleUpdatedAt' from {$id}: {$th->getMessage()}");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'deployments':
|
case 'deployments':
|
||||||
|
|
Loading…
Reference in a new issue