Skip to content

Commit

Permalink
CLI-1370: PHP warning in pull:db when backup fails
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed Aug 2, 2024
1 parent e7da699 commit 89ac802
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
6 changes: 5 additions & 1 deletion src/Command/Env/EnvCertCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Acquia\Cli\Attribute\RequireAuth;
use Acquia\Cli\Command\CommandBase;
use Acquia\Cli\Exception\AcquiaCliException;
use AcquiaCloudApi\Endpoints\SslCertificates;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -53,7 +54,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$legacy
);
$notificationUuid = CommandBase::getNotificationUuidFromResponse($response);
$this->waitForNotificationToComplete($acquiaCloudClient, $notificationUuid, 'Installing certificate');
$success = $this->waitForNotificationToComplete($acquiaCloudClient, $notificationUuid, 'Installing certificate');
if (!$success) {
throw new AcquiaCliException('Cloud API failed to install certificate');

Check warning on line 59 in src/Command/Env/EnvCertCreateCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/Env/EnvCertCreateCommand.php#L59

Added line #L59 was not covered by tests
}
return Command::SUCCESS;
}
}
5 changes: 4 additions & 1 deletion src/Command/Env/EnvCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
]);
}
};
$this->waitForNotificationToComplete($acquiaCloudClient, $notificationUuid, "Waiting for the environment to be ready. This usually takes 2 - 15 minutes.", $success);
$success = $this->waitForNotificationToComplete($acquiaCloudClient, $notificationUuid, "Waiting for the environment to be ready. This usually takes 2 - 15 minutes.", $success);
if (!$success) {
throw new AcquiaCliException('Cloud API failed to create environment');

Check warning on line 67 in src/Command/Env/EnvCreateCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/Env/EnvCreateCommand.php#L67

Added line #L67 was not covered by tests
}

return Command::SUCCESS;
}
Expand Down
17 changes: 9 additions & 8 deletions src/Command/Env/EnvMirrorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Acquia\Cli\Attribute\RequireAuth;
use Acquia\Cli\Command\CommandBase;
use Acquia\Cli\Exception\AcquiaCliException;
use Acquia\Cli\Output\Checklist;
use AcquiaCloudApi\Connector\Client;
use AcquiaCloudApi\Endpoints\Databases;
Expand Down Expand Up @@ -78,17 +79,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$configCopyResponse = $this->mirrorConfig($sourceEnvironment, $destinationEnvironment, $environmentsResource, $destinationEnvironmentUuid, $outputCallback);
}

if (isset($codeCopyResponse)) {
$this->waitForNotificationToComplete($acquiaCloudClient, CommandBase::getNotificationUuidFromResponse($codeCopyResponse), 'Waiting for code copy to complete');
if (isset($codeCopyResponse) && !$this->waitForNotificationToComplete($acquiaCloudClient, CommandBase::getNotificationUuidFromResponse($codeCopyResponse), 'Waiting for code copy to complete')) {
throw new AcquiaCliException('Cloud API failed to copy code');

Check warning on line 83 in src/Command/Env/EnvMirrorCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/Env/EnvMirrorCommand.php#L83

Added line #L83 was not covered by tests
}
if (isset($dbCopyResponse)) {
$this->waitForNotificationToComplete($acquiaCloudClient, CommandBase::getNotificationUuidFromResponse($dbCopyResponse), 'Waiting for database copy to complete');
if (isset($dbCopyResponse) && !$this->waitForNotificationToComplete($acquiaCloudClient, CommandBase::getNotificationUuidFromResponse($dbCopyResponse), 'Waiting for database copy to complete')) {
throw new AcquiaCliException('Cloud API failed to copy database');

Check warning on line 86 in src/Command/Env/EnvMirrorCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/Env/EnvMirrorCommand.php#L86

Added line #L86 was not covered by tests
}
if (isset($filesCopyResponse)) {
$this->waitForNotificationToComplete($acquiaCloudClient, CommandBase::getNotificationUuidFromResponse($filesCopyResponse), 'Waiting for files copy to complete');
if (isset($filesCopyResponse) && !$this->waitForNotificationToComplete($acquiaCloudClient, CommandBase::getNotificationUuidFromResponse($filesCopyResponse), 'Waiting for files copy to complete')) {
throw new AcquiaCliException('Cloud API failed to copy files');

Check warning on line 89 in src/Command/Env/EnvMirrorCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/Env/EnvMirrorCommand.php#L89

Added line #L89 was not covered by tests
}
if (isset($configCopyResponse)) {
$this->waitForNotificationToComplete($acquiaCloudClient, CommandBase::getNotificationUuidFromResponse($configCopyResponse), 'Waiting for config copy to complete');
if (isset($configCopyResponse) && !$this->waitForNotificationToComplete($acquiaCloudClient, CommandBase::getNotificationUuidFromResponse($configCopyResponse), 'Waiting for config copy to complete')) {
throw new AcquiaCliException('Cloud API failed to copy config');

Check warning on line 92 in src/Command/Env/EnvMirrorCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/Env/EnvMirrorCommand.php#L92

Added line #L92 was not covered by tests
}

$this->io->success([
Expand Down
5 changes: 4 additions & 1 deletion src/Command/Pull/PullCommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,11 @@ protected function waitForBackup(string $notificationUuid, Client $acquiaCloudCl
$this->output->writeln('');
$this->output->writeln('<info>Database backup is ready!</info>');
};
$this->waitForNotificationToComplete($acquiaCloudClient, $notificationUuid, $spinnerMessage, $successCallback);
$success = $this->waitForNotificationToComplete($acquiaCloudClient, $notificationUuid, $spinnerMessage, $successCallback);
Loop::run();
if (!$success) {
throw new AcquiaCliException('Cloud API failed to create a backup');

Check warning on line 353 in src/Command/Pull/PullCommandBase.php

View check run for this annotation

Codecov / codecov/patch

src/Command/Pull/PullCommandBase.php#L353

Added line #L353 was not covered by tests
}
}

private function connectToLocalDatabase(string $dbHost, string $dbUser, string $dbName, string $dbPassword, callable $outputCallback = null): void
Expand Down

0 comments on commit 89ac802

Please sign in to comment.