From 209816055a226bce1474260e023e1b7121e611b0 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Thu, 28 Sep 2023 15:39:10 -0600 Subject: [PATCH 1/3] Back to dev 3.2.3. --- CHANGELOG.md | 2 ++ config/constants.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 316fd92c1..07e692d39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org) +## 3.2.3-dev + ## 3.2.2 - 2023-09-28 ### Fixed diff --git a/config/constants.yml b/config/constants.yml index ccc53e3fd..a6dac6201 100644 --- a/config/constants.yml +++ b/config/constants.yml @@ -7,7 +7,7 @@ --- # App -TERMINUS_VERSION: '3.2.2' +TERMINUS_VERSION: '3.2.3-dev' # Connectivity TERMINUS_HOST: 'terminus.pantheon.io' From b666f4e33c05482c7d42ba06e634243404b89e40 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Mon, 2 Oct 2023 12:13:57 -0600 Subject: [PATCH 2/3] Handle ICR exceptions from ygg. --- src/Commands/Branch/ListCommand.php | 9 ++++++++- src/Commands/Connection/SetCommand.php | 5 +++++ src/Exceptions/TerminusIcrSiteException.php | 11 +++++++++++ src/Request/Request.php | 10 ++++++++-- 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/Exceptions/TerminusIcrSiteException.php diff --git a/src/Commands/Branch/ListCommand.php b/src/Commands/Branch/ListCommand.php index 85e445f00..fe5e5301f 100644 --- a/src/Commands/Branch/ListCommand.php +++ b/src/Commands/Branch/ListCommand.php @@ -7,6 +7,7 @@ use Pantheon\Terminus\Commands\StructuredListTrait; use Pantheon\Terminus\Site\SiteAwareInterface; use Pantheon\Terminus\Site\SiteAwareTrait; +use Pantheon\Terminus\Exceptions\TerminusIcrSiteException; /** * Class ListCommand @@ -37,6 +38,12 @@ class ListCommand extends TerminusCommand implements SiteAwareInterface */ public function listBranches($site_id) { - return $this->getRowsOfFields($this->getSiteById($site_id)->getBranches()); + try { + return $this->getRowsOfFields($this->getSiteById($site_id)->getBranches()); + } catch (TerminusIcrSiteException $e) { + $this->log()->notice("This is an ICR site, branches are managed in the external VCS."); + $this->log()->debug($e->getMessage()); + return; + } } } diff --git a/src/Commands/Connection/SetCommand.php b/src/Commands/Connection/SetCommand.php index 8eed56254..a81c833d7 100644 --- a/src/Commands/Connection/SetCommand.php +++ b/src/Commands/Connection/SetCommand.php @@ -7,6 +7,7 @@ use Pantheon\Terminus\Site\SiteAwareInterface; use Pantheon\Terminus\Site\SiteAwareTrait; use Pantheon\Terminus\Exceptions\TerminusException; +use Pantheon\Terminus\Exceptions\TerminusIcrSiteException; /** * Class SetCommand. @@ -64,6 +65,10 @@ public function connectionSet($site_env, $mode) try { $mode = strtolower($mode ?? ''); $workflow = $env->changeConnectionMode($mode); + } catch (TerminusIcrSiteException $e) { + $this->log()->debug($e->getMessage()); + $this->log()->notice("This is an ICR site, connection mode switching is not currently supported."); + return; } catch (TerminusException $e) { $message = $e->getMessage(); if (strpos($message, $mode) !== false) { diff --git a/src/Exceptions/TerminusIcrSiteException.php b/src/Exceptions/TerminusIcrSiteException.php new file mode 100644 index 000000000..5b2a8dd09 --- /dev/null +++ b/src/Exceptions/TerminusIcrSiteException.php @@ -0,0 +1,11 @@ + $exception->getMessage()] ); } else { - if (preg_match('/[2,4]0\d/', $response->getStatusCode())) { - // Do not retry on 20x and 40x responses. + if (preg_match('/[2,4]0\d/', $response->getStatusCode()) || $response->getStatusCode() == 410) { + // Do not retry on 20x, 40x or 410 responses. return false; } @@ -427,6 +428,11 @@ public function request($path, array $options = []): RequestOperationResult $this->logger->debug($jsonException->getMessage()); } + if ($response->getStatusCode() == 410 && $body == "icr_site") { + // This request is expected to fail for an ICR site, throw exception that will be catched down the road. + throw new TerminusIcrSiteException("This is an ICR site."); + } + return new RequestOperationResult([ 'data' => $body, 'headers' => $response->getHeaders(), From 31f3efa17fa2b6accaebe6e16e1bc68dd2543863 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Mon, 2 Oct 2023 13:38:56 -0600 Subject: [PATCH 3/3] Use 409 instead of 410. --- src/Request/Request.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Request/Request.php b/src/Request/Request.php index 86b5c570b..4c6826d09 100755 --- a/src/Request/Request.php +++ b/src/Request/Request.php @@ -227,8 +227,8 @@ private function createRetryDecider(): callable ['error' => $exception->getMessage()] ); } else { - if (preg_match('/[2,4]0\d/', $response->getStatusCode()) || $response->getStatusCode() == 410) { - // Do not retry on 20x, 40x or 410 responses. + if (preg_match('/[2,4]0\d/', $response->getStatusCode())) { + // Do not retry on 20x or 40x responses. return false; } @@ -428,7 +428,7 @@ public function request($path, array $options = []): RequestOperationResult $this->logger->debug($jsonException->getMessage()); } - if ($response->getStatusCode() == 410 && $body == "icr_site") { + if ($response->getStatusCode() == 409 && $body == "icr_site") { // This request is expected to fail for an ICR site, throw exception that will be catched down the road. throw new TerminusIcrSiteException("This is an ICR site."); }