mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-20 19:18:45 +00:00
fix(volume-backups): preserve backup failure status
This commit is contained in:
@@ -28,6 +28,39 @@ describe("createRestartSafeBackupCommand", () => {
|
|||||||
expect(outputLines(result.stdout)).toEqual(["stop", "backup", "start"]);
|
expect(outputLines(result.stdout)).toEqual(["stop", "backup", "start"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("preserves the backup error status when the restart also fails", () => {
|
||||||
|
const result = runCommand(
|
||||||
|
createRestartSafeBackupCommand({
|
||||||
|
stopCommand: 'echo "stop"',
|
||||||
|
backupCommand: 'echo "backup"; exit 23',
|
||||||
|
startCommand: 'echo "start"; exit 17',
|
||||||
|
uploadCommand: 'echo "upload"',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.status).toBe(23);
|
||||||
|
expect(outputLines(result.stdout)).toEqual([
|
||||||
|
"stop",
|
||||||
|
"backup",
|
||||||
|
"start",
|
||||||
|
"Service restart also failed with exit code 17",
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns the restart error status when the backup succeeds", () => {
|
||||||
|
const result = runCommand(
|
||||||
|
createRestartSafeBackupCommand({
|
||||||
|
stopCommand: 'echo "stop"',
|
||||||
|
backupCommand: 'echo "backup"',
|
||||||
|
startCommand: 'echo "start"; exit 17',
|
||||||
|
uploadCommand: 'echo "upload"',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.status).toBe(17);
|
||||||
|
expect(outputLines(result.stdout)).toEqual(["stop", "backup", "start"]);
|
||||||
|
});
|
||||||
|
|
||||||
it("uploads only after a successful backup and service restart", () => {
|
it("uploads only after a successful backup and service restart", () => {
|
||||||
const result = runCommand(
|
const result = runCommand(
|
||||||
createRestartSafeBackupCommand({
|
createRestartSafeBackupCommand({
|
||||||
|
|||||||
@@ -28,11 +28,21 @@ export const createRestartSafeBackupCommand = ({
|
|||||||
${backupCommand}
|
${backupCommand}
|
||||||
)
|
)
|
||||||
DOKPLOY_VOLUME_BACKUP_STATUS=$?
|
DOKPLOY_VOLUME_BACKUP_STATUS=$?
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
${startCommand}
|
||||||
|
)
|
||||||
|
DOKPLOY_VOLUME_RESTART_STATUS=$?
|
||||||
set -e
|
set -e
|
||||||
${startCommand}
|
|
||||||
if [ "$DOKPLOY_VOLUME_BACKUP_STATUS" -ne 0 ]; then
|
if [ "$DOKPLOY_VOLUME_BACKUP_STATUS" -ne 0 ]; then
|
||||||
|
if [ "$DOKPLOY_VOLUME_RESTART_STATUS" -ne 0 ]; then
|
||||||
|
echo "Service restart also failed with exit code $DOKPLOY_VOLUME_RESTART_STATUS"
|
||||||
|
fi
|
||||||
exit "$DOKPLOY_VOLUME_BACKUP_STATUS"
|
exit "$DOKPLOY_VOLUME_BACKUP_STATUS"
|
||||||
fi
|
fi
|
||||||
|
if [ "$DOKPLOY_VOLUME_RESTART_STATUS" -ne 0 ]; then
|
||||||
|
exit "$DOKPLOY_VOLUME_RESTART_STATUS"
|
||||||
|
fi
|
||||||
${uploadCommand}
|
${uploadCommand}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user