Skip to content

Commit

Permalink
Add support for the new infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
maximepoulin-hl committed Oct 4, 2024
1 parent ce0cdb5 commit 573666a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 46 deletions.
7 changes: 6 additions & 1 deletion src/Clients/OrchClusterClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ class OrchClusterClient extends HttpClient
{
public function __construct(OrchCluster $cluster)
{
parent::__construct("https://data.{$cluster->getClusterID()}.vanilladev.com");
$clusterId = $cluster->getClusterID();
$url = preg_match("/^cl[123456]00[0-9]{2}$/", $clusterId)
? "https://data.{$clusterId}.vanilladev.com"
: "http://data.{$clusterId}.service.consul";

parent::__construct($url);
$this->setDefaultHeaders([
"X-Access-Token" => $cluster->getSecret(),
"Content-Type" => "application/json",
Expand Down
31 changes: 0 additions & 31 deletions src/Exceptions/InvalidRegionException.php

This file was deleted.

2 changes: 2 additions & 0 deletions src/Orch/OrchSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public function getClusterRouterHostname(): ?string
return "haproxy-router.yul1-routing-prod1.vanilladev.com";
case Cluster::REGION_YUL1_DEV1:
return "haproxy-router.yul1-routing-dev1.vanilladev.com";
default:
return "http.haproxy.service.consul";
}

return null;

Check failure on line 123 in src/Orch/OrchSite.php

View workflow job for this annotation

GitHub Actions / static-analysis (7.4)

UnevaluatedCode

src/Orch/OrchSite.php:123:9: UnevaluatedCode: Expressions after return/throw/continue (see https://psalm.dev/084)

Check failure on line 123 in src/Orch/OrchSite.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.0)

UnevaluatedCode

src/Orch/OrchSite.php:123:9: UnevaluatedCode: Expressions after return/throw/continue (see https://psalm.dev/084)

Check failure on line 123 in src/Orch/OrchSite.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.1)

UnevaluatedCode

src/Orch/OrchSite.php:123:9: UnevaluatedCode: Expressions after return/throw/continue (see https://psalm.dev/084)

Check failure on line 123 in src/Orch/OrchSite.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.2)

UnevaluatedCode

src/Orch/OrchSite.php:123:9: UnevaluatedCode: Expressions after return/throw/continue (see https://psalm.dev/084)
Expand Down
16 changes: 5 additions & 11 deletions src/Orch/OrchSiteProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

namespace Garden\Sites\Orch;

use Garden\Http\CurlHandler;
use Garden\Sites\Clients\OrchHttpClient;
use Garden\Sites\Cluster;
use Garden\Sites\Exceptions\ConfigLoadingException;
use Garden\Sites\Exceptions\InvalidRegionException;
use Garden\Sites\SiteProvider;
use Garden\Sites\SiteRecord;
use Garden\Utils\ArrayUtils;
Expand Down Expand Up @@ -86,14 +84,9 @@ public function loadAllClusters(): array

$result = [];
foreach ($apiClusters as $apiCluster) {
try {
$regionID = self::getRegionIDFromOrch($apiCluster["CloudZone"], $apiCluster["Network"]);
$cluster = new OrchCluster($apiCluster["ClusterID"], $regionID, $apiCluster["ApiToken"]);
$result[$cluster->getClusterID()] = $cluster;
} catch (InvalidRegionException $e) {
// Ignore these ones.
continue;
}
$regionID = self::getRegionIDFromOrch($apiCluster["CloudZone"], $apiCluster["Network"]);
$cluster = new OrchCluster($apiCluster["ClusterID"], $regionID, $apiCluster["ApiToken"]);
$result[$cluster->getClusterID()] = $cluster;
}

return $result;
Expand Down Expand Up @@ -123,7 +116,8 @@ public static function getRegionIDFromOrch(string $orchCloudZone, string $orchNe
return Cluster::REGION_YUL1_DEV1;
}
default:
throw new InvalidRegionException("cloudZone: {$orchCloudZone}, network: $orchNetwork");
// new clusters have sane names
return $orchCloudZone;
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Garden\Sites\Clients\SiteHttpClient;
use Garden\Sites\Exceptions\BadApiCredentialsException;
use Garden\Sites\Exceptions\ClusterNotFoundException;
use Garden\Sites\Exceptions\InvalidRegionException;
use Garden\Utils\ArrayUtils;

/**
Expand Down Expand Up @@ -218,7 +217,7 @@ public function getQueueServiceBaseUrl(): string
case Cluster::REGION_SJC1_PROD1:
return "https://sjc1-vanillaqueue-prod1.v-fabric.net";
default:
throw new InvalidRegionException($this->getCluster()->getRegionID());
return "http://api.vanilla-queue.service.consul";
}
}

Expand All @@ -243,7 +242,7 @@ public function getSearchServiceBaseUrl(): string
case Cluster::REGION_AMS1_PROD1: // Temporarily using YUL prod instance into AMS is re-provisioned https://higherlogic.atlassian.net/browse/PV-323
return "https://yul1-vanillasearch-prod1-api.v-fabric.net";
default:
throw new InvalidRegionException($this->getCluster()->getRegionID());
return "http://api.vanilla-search.service.consul";
}
}
}

0 comments on commit 573666a

Please sign in to comment.