Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hetzner: Add shared vCPU instance types; EUR -> USD #835

Merged
merged 15 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions console/db/migrations/20241205103951_2.1.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,59 @@ WHERE extension_name IN (
'timescaledb'
);

-- Adds shared_cpu BOOLEAN field to cloud_instances
-- ref: https://github.com/vitabaks/autobase/issues/784
ALTER TABLE ONLY public.cloud_instances
ADD COLUMN shared_cpu BOOLEAN DEFAULT FALSE;

-- Update AWS shared vCPU instances
UPDATE public.cloud_instances
SET shared_cpu = true
WHERE cloud_provider = 'aws' AND instance_name IN ('t3.small', 't3.medium');

-- Update GCP shared vCPU instances
UPDATE public.cloud_instances
SET shared_cpu = true
WHERE cloud_provider = 'gcp' AND instance_name IN ('e2-small', 'e2-medium');

-- Update Azure shared vCPU instances
UPDATE public.cloud_instances
SET shared_cpu = true
WHERE cloud_provider = 'azure' AND instance_name IN ('Standard_B1ms', 'Standard_B2s');

-- Update DigitalOcean shared vCPU instances
UPDATE public.cloud_instances
SET shared_cpu = true
WHERE cloud_provider = 'digitalocean' AND instance_name IN ('s-2vcpu-2gb', 's-2vcpu-4gb');

vitabaks marked this conversation as resolved.
Show resolved Hide resolved
-- Extends 20240520144338_2.0.0_initial_scheme_setup.sql#L217 with more cloud instance types
-- Heztner price is for the region 'Geremany / Finland', other regions may vary in price.
INSERT INTO public.cloud_instances (cloud_provider, instance_group, instance_name, cpu, ram, price_hourly, price_monthly, currency, updated_at, shared_cpu) VALUES
('hetzner', 'Small Size', 'CX22', 2, 4, 0.0074 , 4.59, '$', '2024-12-10', true),
('hetzner', 'Small Size', 'CX32', 4, 8, 0.0127 , 7.59, '$', '2024-12-10', true),
('hetzner', 'Medium Size', 'CX42', 8, 16, 0.0304 , 18.59, '$', '2024-12-10', true),
('hetzner', 'Medium Size', 'CX52', 16, 32, 0.0611 , 36.09, '$', '2024-12-10', true),
('hetzner', 'Small Size', 'CPX31', 4, 8, 0.025 , 15.59, '$', '2024-12-10', true),
('hetzner', 'Medium Size', 'CPX41', 8, 16, 0.0464 , 28.09, '$', '2024-12-10', true),
('hetzner', 'Medium Size', 'CPX51', 16, 32, 0.0979 , 61.09, '$', '2024-12-10', true);


-- Update all existing Hetzner instances to use USD instead of EUR for easy comparison to other IaaS Providers.
-- cloud_instances
-- Update prices and other relevant fields for Hetzner cloud instances indludes an IPv4 address
UPDATE public.cloud_instances SET price_hourly = 0.0082, price_monthly = 5.09, currency = '$', updated_at = '2024-12-10', shared_cpu = true WHERE cloud_provider = 'hetzner' AND instance_name = 'CPX11';
UPDATE public.cloud_instances SET price_hourly = 0.0138, price_monthly = 8.59, currency = '$', updated_at = '2024-12-10', shared_cpu = true WHERE cloud_provider = 'hetzner' AND instance_name = 'CPX21';
UPDATE public.cloud_instances SET price_hourly = 0.0226, price_monthly = 14.09, currency = '$', updated_at = '2024-12-10', shared_cpu = false WHERE cloud_provider = 'hetzner' AND instance_name = 'CCX13';
UPDATE public.cloud_instances SET price_hourly = 0.0435, price_monthly = 27.09, currency = '$', updated_at = '2024-12-10', shared_cpu = false WHERE cloud_provider = 'hetzner' AND instance_name = 'CCX23';
UPDATE public.cloud_instances SET price_hourly = 0.0867, price_monthly = 54.09, currency = '$', updated_at = '2024-12-10', shared_cpu = false WHERE cloud_provider = 'hetzner' AND instance_name = 'CCX33';
UPDATE public.cloud_instances SET price_hourly = 0.1725, price_monthly = 107.59, currency = '$', updated_at = '2024-12-10', shared_cpu = false WHERE cloud_provider = 'hetzner' AND instance_name = 'CCX43';
UPDATE public.cloud_instances SET price_hourly = 0.3431, price_monthly = 214.09, currency = '$', updated_at = '2024-12-10', shared_cpu = false WHERE cloud_provider = 'hetzner' AND instance_name = 'CCX53';
UPDATE public.cloud_instances SET price_hourly = 0.5138, price_monthly = 320.59, currency = '$', updated_at = '2024-12-10', shared_cpu = false WHERE cloud_provider = 'hetzner' AND instance_name = 'CCX63';

-- cloud_volumes
-- Update prices and other relevant fields for Hetzner cloud volume
UPDATE public.cloud_volumes SET price_monthly = 0.05, currency = '$', updated_at = '2024-12-10' WHERE cloud_provider = 'hetzner';

-- +goose Down
DELETE FROM public.postgres_versions
WHERE major_version = 17;
3 changes: 3 additions & 0 deletions console/service/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,9 @@ definitions:
cpu:
type: integer
example: 8
shared_cpu:
type: boolean
example: false
ram:
type: integer
example: 256
Expand Down
3 changes: 3 additions & 0 deletions console/service/internal/convert/external_deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func ProviderInfoToSwagger(providerInfo *storage.CloudProviderInfo, description,
resp.InstanceTypes.Small = append(resp.InstanceTypes.Small, &models.DeploymentInstanceType{
Code: instance.InstanceName,
CPU: instance.Cpu,
SharedCPU: instance.SharedCpu,
PriceHourly: instance.PriceHourly,
PriceMonthly: instance.PriceMonthly,
Currency: instance.Currency,
Expand All @@ -70,6 +71,7 @@ func ProviderInfoToSwagger(providerInfo *storage.CloudProviderInfo, description,
resp.InstanceTypes.Medium = append(resp.InstanceTypes.Medium, &models.DeploymentInstanceType{
Code: instance.InstanceName,
CPU: instance.Cpu,
SharedCPU: instance.SharedCpu,
PriceHourly: instance.PriceHourly,
PriceMonthly: instance.PriceMonthly,
Currency: instance.Currency,
Expand All @@ -79,6 +81,7 @@ func ProviderInfoToSwagger(providerInfo *storage.CloudProviderInfo, description,
resp.InstanceTypes.Large = append(resp.InstanceTypes.Large, &models.DeploymentInstanceType{
Code: instance.InstanceName,
CPU: instance.Cpu,
SharedCPU: instance.SharedCpu,
PriceHourly: instance.PriceHourly,
PriceMonthly: instance.PriceMonthly,
Currency: instance.Currency,
Expand Down
1 change: 1 addition & 0 deletions console/service/internal/storage/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type CloudInstance struct {
PriceMonthly float64
Currency string
UpdatedAt time.Time
SharedCpu bool
}

type CloudImage struct {
Expand Down
Loading