Skip to content

Commit fd723dc

Browse files
committed
Merge branch 'master' into develop
2 parents 9284c43 + 6d96a8f commit fd723dc

18 files changed

+238
-142
lines changed

src/BuildProcess/ValidateManifest.php

+2-13
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,12 @@ protected function warnAboutDeprecations()
3939
if (in_array(Manifest::runtime($this->environment), [
4040
'php-7.3',
4141
'php-7.4',
42-
'php-8.0',
43-
])) {
44-
Helpers::warn(
45-
'The runtimes "php-7.3", "php-7.4", and "php-8.0" are deprecated and support will be fully removed from Vapor on December 31st, 2023.'
46-
.' Those runtimes are based on Amazon Linux 1, for which AWS standard support has ended.'
47-
.' Amazon Linux 1 is only receiving critical and important security updates and it may not work with new Vapor/AWS features.'
48-
.' Please use Amazon Linux 2 with "php-7.4:al2" or "php-8.0:al2" instead.'
49-
);
50-
}
51-
52-
if (in_array(Manifest::runtime($this->environment), [
5342
'php-7.4:al2',
5443
'php-7.4:imagick',
44+
'php-8.0',
5545
])) {
5646
Helpers::warn(
57-
'The runtimes "php-7.4:al2", and "php-7.4:imagick" are deprecated and support will be fully removed from Vapor on December 31st, 2023.'
58-
.' PHP 7.4 is no longer being maintained or receiving security updates.'
47+
'The runtimes "php-7.3", "php-7.4", "php-7.4:al2", "php-7.4:imagick", and "php-8.0" are deprecated and will no longer be supported or receiving any updates.'
5948
.' For a full list of supported runtimes, please see: https://docs.vapor.build/1.0/projects/environments.html#runtime'
6049
);
6150
}

src/CacheInstanceClasses.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ class CacheInstanceClasses
1212
public static function general()
1313
{
1414
return [
15-
'cache.t3.micro' => 'cache.t3.micro - (2 VCPU, 0.5Gib RAM) - Free Tier Eligible ~$13 / month',
16-
'cache.t3.small' => 'cache.t3.small - (2 VCPU, 1.37Gib RAM) - ~$25 / month',
17-
'cache.t3.medium' => 'cache.t3.medium - (2 VCPU, 3.09Gib RAM) - ~$50 / month',
18-
'cache.m5.large' => 'cache.m5.large - (2 VCPU, 6.38Gib RAM) - ~$112 / month',
19-
'cache.m5.xlarge' => 'cache.m5.xlarge - (4 VCPU, 12.93Gib RAM) - ~$224 / month',
20-
'cache.m5.2xlarge' => 'cache.m5.2xlarge - (8 VCPU, 26.04Gib RAM) - ~$449 / month',
21-
'cache.m5.4xlarge' => 'cache.m5.4xlarge - (16 VCPU, 52.26Gib RAM) - ~$897 / month',
15+
'cache.t3.micro' => 'cache.t3.micro - (2 VCPU, 0.5Gib RAM) - Free Tier Eligible ~$13 / month',
16+
'cache.t3.small' => 'cache.t3.small - (2 VCPU, 1.37Gib RAM) - ~$25 / month',
17+
'cache.t3.medium' => 'cache.t3.medium - (2 VCPU, 3.09Gib RAM) - ~$50 / month',
18+
'cache.m5.large' => 'cache.m5.large - (2 VCPU, 6.38Gib RAM) - ~$112 / month',
19+
'cache.m5.xlarge' => 'cache.m5.xlarge - (4 VCPU, 12.93Gib RAM) - ~$224 / month',
20+
'cache.m5.2xlarge' => 'cache.m5.2xlarge - (8 VCPU, 26.04Gib RAM) - ~$449 / month',
21+
'cache.m5.4xlarge' => 'cache.m5.4xlarge - (16 VCPU, 52.26Gib RAM) - ~$897 / month',
2222
'cache.m5.12xlarge' => 'cache.m5.12xlarge - (48 VCPU, 157.12Gib RAM) - ~$2696 / month',
2323
'cache.m5.24xlarge' => 'cache.m5.24xlarge - (96 VCPU, 314.32Gib RAM) - ~$5392 / month',
2424
];
@@ -32,10 +32,10 @@ public static function general()
3232
public static function memory()
3333
{
3434
return [
35-
'cache.r5.large' => 'cache.r5.large - (2 VCPU, 13.07Gib RAM) - ~$156 / month',
36-
'cache.r5.xlarge' => 'cache.r5.xlarge - (4 VCPU, 26.32GiB RAM) - ~$310 / month',
37-
'cache.r5.2xlarge' => 'cache.r5.2xlarge - (8 VCPU, 52.82GiB RAM) - ~$621 / month',
38-
'cache.r5.4xlarge' => 'cache.r5.4xlarge - (16 VCPU, 105.81GiB RAM) - ~$1241 / month',
35+
'cache.r5.large' => 'cache.r5.large - (2 VCPU, 13.07Gib RAM) - ~$156 / month',
36+
'cache.r5.xlarge' => 'cache.r5.xlarge - (4 VCPU, 26.32GiB RAM) - ~$310 / month',
37+
'cache.r5.2xlarge' => 'cache.r5.2xlarge - (8 VCPU, 52.82GiB RAM) - ~$621 / month',
38+
'cache.r5.4xlarge' => 'cache.r5.4xlarge - (16 VCPU, 105.81GiB RAM) - ~$1241 / month',
3939
'cache.r5.12xlarge' => 'cache.r5.12xlarge - (48 VCPU, 317.77GiB RAM) - ~$3732 / month',
4040
'cache.r5.24xlarge' => 'cache.r5.24xlarge - (96 VCPU, 635.61GiB RAM) - ~$7465 / month',
4141
];

src/Commands/CacheCommand.php

+16-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ public function handle()
4444
}
4545

4646
$instanceClass = $this->determineInstanceClass();
47-
$type = $this->determineCacheType();
47+
48+
if ($instanceClass == 'serverless') {
49+
$instanceClass = null;
50+
$type = 'redis7.x-serverless';
51+
} else {
52+
$type = $this->determineCacheType();
53+
}
4854

4955
$response = $this->vapor->createCache(
5056
$networkId,
@@ -67,7 +73,7 @@ protected function determineCacheType()
6773
{
6874
return $this->menu('Which type of cache would you like to create?', [
6975
'redis6.x-cluster' => 'Redis 6.x Cluster',
70-
'redis-cluster' => 'Redis 5.x Cluster',
76+
'redis-cluster' => 'Redis 5.x Cluster',
7177
]);
7278
}
7379

@@ -79,15 +85,20 @@ protected function determineCacheType()
7985
protected function determineInstanceClass()
8086
{
8187
$type = $this->menu('Which type of cache instance would you like to create?', [
88+
'serverless' => 'Serverless',
8289
'general' => 'General Purpose',
83-
'memory' => 'Memory Optimized',
90+
'memory' => 'Memory Optimized',
8491
]);
8592

93+
if ($type == 'serverless') {
94+
return 'serverless';
95+
}
96+
8697
if ($type == 'general') {
8798
return $this->determineGeneralInstanceClass();
88-
} else {
89-
return $this->determineMemoryOptimizedInstanceClass();
9099
}
100+
101+
return $this->determineMemoryOptimizedInstanceClass();
91102
}
92103

93104
/**

src/Commands/CacheListCommand.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ public function handle()
5151
*/
5252
protected function cacheType($type)
5353
{
54-
return $type == 'redis6.x-cluster' ? 'Redis 6.x Cluster' : 'Redis 5.x Cluster';
54+
if ($type == 'redis7.x-serverless') {
55+
return 'Redis 7.x Serverless';
56+
}
57+
58+
if ($type == 'redis6.x-cluster') {
59+
return 'Redis 6.x Cluster';
60+
}
61+
62+
return 'Redis 5.x Cluster';
5563
}
5664
}

src/Commands/CacheMetricsCommand.php

+20-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function configure()
1717
$this
1818
->setName('cache:metrics')
1919
->addArgument('cache', InputArgument::REQUIRED, 'The cache name / ID')
20-
->addArgument('period', InputArgument::OPTIONAL, 'The metric period (1m, 5m, 1h, 8h, 1d, 3d, 7d, 1M)', '1d')
20+
->addArgument('period', InputArgument::OPTIONAL, 'The metric period (5m, 30m, 1h, 8h, 1d, 3d, 7d, 1M)', '1d')
2121
->setDescription('Get usage and performance metrics for a cache');
2222
}
2323

@@ -43,6 +43,10 @@ public function handle()
4343
$this->argument('period')
4444
);
4545

46+
if (isset($metrics['averageCacheProcessingUnits'])) {
47+
return $this->serverlessMetrics($metrics);
48+
}
49+
4650
$this->table([
4751
'Node', 'Average CPU Utilization', 'Cache Hits', 'Cache Misses',
4852
], collect(range(0, count($metrics['totalCacheHits']) - 1))->map(function ($node) use ($metrics) {
@@ -54,4 +58,19 @@ public function handle()
5458
];
5559
})->all());
5660
}
61+
62+
/**
63+
* Format the serverless metrics for display.
64+
*/
65+
protected function serverlessMetrics(array $metrics): void
66+
{
67+
$this->table([
68+
'Average CPU (ECPU Units)', 'Average Memory Utilization (Bytes)', 'Cache Hits', 'Cache Misses',
69+
], [[
70+
number_format($metrics['averageCacheProcessingUnits'][0]),
71+
number_format($metrics['averageCacheBytesUsed'][0]),
72+
$metrics['totalCacheHits'][0],
73+
$metrics['totalCacheMisses'][0],
74+
]]);
75+
}
5776
}

src/Commands/CacheScaleCommand.php

+38-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Laravel\VaporCli\Helpers;
66
use Symfony\Component\Console\Input\InputArgument;
7+
use Symfony\Component\Console\Input\InputOption;
78

89
class CacheScaleCommand extends Command
910
{
@@ -17,7 +18,9 @@ protected function configure()
1718
$this
1819
->setName('cache:scale')
1920
->addArgument('cache', InputArgument::REQUIRED, 'The cache name / ID')
20-
->addArgument('scale', InputArgument::REQUIRED, 'The number of nodes that should be in the cache cluster')
21+
->addArgument('scale', InputArgument::OPTIONAL, 'The number of nodes that should be in the cache cluster')
22+
->addOption('memory', null, InputOption::VALUE_OPTIONAL, 'The maximum amount of memory that can be used by the serverless cache')
23+
->addOption('cpu', null, InputOption::VALUE_OPTIONAL, 'The maximum amount of ECPUs that can be used by the serverless cache')
2124
->setDescription('Modify the number of nodes in a cache cluster');
2225
}
2326

@@ -40,13 +43,43 @@ public function handle()
4043

4144
$cache = $this->vapor->cache($cacheId);
4245

43-
$this->vapor->scaleCache(
44-
$cacheId,
45-
$this->argument('scale')
46-
);
46+
if ($cache['type'] === 'redis7.x-serverless') {
47+
$this->scaleServerlessCache($cacheId);
48+
} else {
49+
$this->scaleCacheCluster($cacheId);
50+
}
4751

4852
Helpers::info('Cache modification initiated successfully.');
4953
Helpers::line();
5054
Helpers::line('Caches may take several minutes to finish scaling.');
5155
}
56+
57+
/**
58+
* Scale a serverless cache.
59+
*/
60+
protected function scaleServerlessCache(int $cacheId): void
61+
{
62+
if (is_null($this->option('memory')) || is_null($this->option('cpu'))) {
63+
Helpers::abort('You must specify both the memory and CPU limits. To remove the either limit, set it to 0.');
64+
}
65+
66+
$this->vapor->scaleCache(
67+
$cacheId,
68+
null,
69+
$this->option('memory') === '0' ? null : $this->option('memory'),
70+
$this->option('cpu') === '0' ? null : $this->option('cpu')
71+
);
72+
}
73+
74+
/**
75+
* Scale a cache cluster.
76+
*/
77+
protected function scaleCacheCluster(int $cacheId): void
78+
{
79+
if (! $scale = $this->argument('scale')) {
80+
Helpers::abort('You must specify the number of nodes to scale the cache to.');
81+
}
82+
83+
$this->vapor->scaleCache($cacheId, $scale);
84+
}
5285
}

src/Commands/CacheShowCommand.php

+44-10
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,50 @@ public function handle()
4040

4141
$cache = $this->vapor->cache($cacheId);
4242

43+
if ($cache['type'] === 'redis7.x-serverless') {
44+
$this->showServerlessCache($cache);
45+
} else {
46+
$this->showCacheCluster($cache);
47+
}
48+
49+
if ($cache['endpoint']) {
50+
Helpers::line();
51+
52+
Helpers::line(' <info>Endpoint:</info> '.$cache['endpoint']);
53+
}
54+
55+
Helpers::line();
56+
57+
$this->call('cache:metrics', ['cache' => $this->argument('cache')]);
58+
}
59+
60+
/**
61+
* Render serverless cache details.
62+
*/
63+
protected function showServerlessCache(array $cache): void
64+
{
65+
$this->table([
66+
'ID', 'Provider', 'Name', 'Region', 'Class', 'Snapshot Retention (Days)', 'Memory Limit (Bytes)', 'ECPU Limit', 'Status',
67+
], collect([$cache])->map(function ($cache) {
68+
return [
69+
$cache['id'],
70+
$cache['cloud_provider']['name'],
71+
$cache['name'],
72+
$cache['region'],
73+
'Serverless',
74+
($snapshotLimit = $cache['snapshot_retention_limit'] ?? null) ? $snapshotLimit : 'N/A',
75+
($memoryLimit = $cache['memory_limit'] ?? null) ? $memoryLimit : 'Unlimited',
76+
($cpuLimit = $cache['cpu_limit'] ?? null) ? $cpuLimit : 'Unlimited',
77+
Str::title(str_replace('_', ' ', $cache['status'])),
78+
];
79+
})->all());
80+
}
81+
82+
/**
83+
* Render cluster cache details.
84+
*/
85+
protected function showCacheCluster(array $cache): void
86+
{
4387
$this->table([
4488
'ID', 'Provider', 'Name', 'Region', 'Class', 'Scale', 'Status',
4589
], collect([$cache])->map(function ($cache) {
@@ -53,15 +97,5 @@ public function handle()
5397
Str::title(str_replace('_', ' ', $cache['status'])),
5498
];
5599
})->all());
56-
57-
if ($cache['endpoint']) {
58-
Helpers::line();
59-
60-
Helpers::line(' <info>Endpoint:</info> '.$cache['endpoint']);
61-
}
62-
63-
Helpers::line();
64-
65-
$this->call('cache:metrics', ['cache' => $this->argument('cache')]);
66100
}
67101
}

src/Commands/DatabaseScaleCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function determineRdsInstanceClass()
6464
{
6565
$type = $this->menu('Which type of database instance would you like to scale to?', [
6666
'general' => 'General Purpose',
67-
'memory' => 'Memory Optimized',
67+
'memory' => 'Memory Optimized',
6868
]);
6969

7070
if ($type == 'general') {

src/Commands/DeployCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function handle()
6868

6969
if ($deployment['database'] && $deployment['database']['certificate_authority_status'] === 'expiring') {
7070
Helpers::line();
71-
Helpers::warn('You database is uses a certificate which expires in August 2024. To prevent connectivity issues after this date, please update the Certificate Authority of your database from the AWS console using the link below.');
71+
Helpers::warn('Your database is using a certificate which expires in August 2024. To prevent connectivity issues after this date, please update the Certificate Authority of your database from the AWS console using the link below.');
7272
Helpers::line();
7373
Helpers::line("https://{$deployment['database']['region']}.console.aws.amazon.com/rds/home?region={$deployment['database']['region']}#ca-cert-update:");
7474
}

src/Commands/EnvCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ public function handle()
4444
);
4545

4646
Manifest::addEnvironment($environment, [
47-
'memory' => 1024,
47+
'memory' => 1024,
4848
'cli-memory' => 512,
49-
'runtime' => $this->option('docker') ? 'docker' : 'php-8.2:al2',
50-
'build' => [
49+
'runtime' => $this->option('docker') ? 'docker' : 'php-8.2:al2',
50+
'build' => [
5151
'COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev',
5252
'php artisan event:cache',
5353
file_exists(Path::current().'/webpack.mix.js')

src/Commands/EnvDescribeCommand.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,20 @@ public function handle()
5151
$domain = count($domains) ? $domains[0] : null;
5252

5353
$description = [
54-
'project_id' => $environment['project_id'],
55-
'uuid' => $environment['uuid'],
56-
'id' => $environment['id'],
57-
'name' => $environment['name'],
58-
'vanity_domain' => $environment['vanity_domain'],
59-
'latest_deployment_id' => $environment['latest_deployment_id'],
54+
'project_id' => $environment['project_id'],
55+
'uuid' => $environment['uuid'],
56+
'id' => $environment['id'],
57+
'name' => $environment['name'],
58+
'vanity_domain' => $environment['vanity_domain'],
59+
'latest_deployment_id' => $environment['latest_deployment_id'],
6060
'latest_deployment_status' => $environment['latest_deployment'] ? $environment['latest_deployment']['status'] : null,
61-
'latest_deployment_url' => 'https://vapor.laravel.com/app/projects/'.$environment['project_id'].'/environments/'.$environment['name'].'/deployments/'.$environment['latest_deployment_id'],
62-
'deployment_status' => $environment['deployment_status'],
63-
'domains' => $domains,
64-
'domain' => $domain,
65-
'management_url' => 'https://vapor.laravel.com/app/projects/'.$environment['project_id'].'/environments/'.$environment['name'],
66-
'vanity_url' => 'https://'.$environment['vanity_domain'],
67-
'custom_url' => $domain ? 'https://'.$domain : null,
61+
'latest_deployment_url' => 'https://vapor.laravel.com/app/projects/'.$environment['project_id'].'/environments/'.$environment['name'].'/deployments/'.$environment['latest_deployment_id'],
62+
'deployment_status' => $environment['deployment_status'],
63+
'domains' => $domains,
64+
'domain' => $domain,
65+
'management_url' => 'https://vapor.laravel.com/app/projects/'.$environment['project_id'].'/environments/'.$environment['name'],
66+
'vanity_url' => 'https://'.$environment['vanity_domain'],
67+
'custom_url' => $domain ? 'https://'.$domain : null,
6868
];
6969

7070
if ($this->option('list')) {

0 commit comments

Comments
 (0)