From 0fe8258e38bff139544e244c62863a1eccfec17e Mon Sep 17 00:00:00 2001 From: Joel Scheuner Date: Wed, 25 Jan 2017 16:06:55 +0100 Subject: [PATCH] Review and fix or document TODOs --- app/models/deployment_recommendation.rb | 5 +++-- app/models/provider_updater.rb | 5 ++--- app/provider_updaters/atlantic_net_updater.rb | 4 +++- app/provider_updaters/google_updater.rb | 2 +- app/provider_updaters/joyent_updater.rb | 2 +- bin/generate_mzn_data | 1 - lib/horizontal-scaling.mzn | 1 - lib/stove.mzn | 1 - 8 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/models/deployment_recommendation.rb b/app/models/deployment_recommendation.rb index 190e41e..2cff3b0 100644 --- a/app/models/deployment_recommendation.rb +++ b/app/models/deployment_recommendation.rb @@ -11,7 +11,7 @@ class DeploymentRecommendation < Base DEFAULT_REGION_AREAS = %w(EU) DEFAULT_MAX_NUM_INSTANCES = 0 - # Transfer costs + # Transfer costs (assumed) INTRA_REGION_TRANSFER = 0 INTER_REGION_SAME_PROVIDER_TRANSFER = 10 INTER_REGION_DIFFERENT_PROVIDER_TRANSFER = 30 @@ -175,9 +175,10 @@ def filtered_resources(provider_id) end end + # NOTICE: Currently, these transfer costs are only a heuristic and + # do not reflect actual tranfer cost from real cloud providers def transfer_costs(resources) Matrix.build(resources.count, resources.count) do |row, col| - # FIXME: use actual transfer costs! if resources[row].region_code == resources[col].region_code INTRA_REGION_TRANSFER elsif resources[row].region_area == resources[col].region_area diff --git a/app/models/provider_updater.rb b/app/models/provider_updater.rb index ab94f74..8d3da24 100644 --- a/app/models/provider_updater.rb +++ b/app/models/provider_updater.rb @@ -15,6 +15,7 @@ def self.update_providers end private + def self.load_providers Dir[Rails.root + 'app/provider_updaters/*.rb'].each do |updater| require updater @@ -27,7 +28,7 @@ def logger # Parse SLA information from an SLA document # - # This method will try to get SLA information from the document at the + # This method tries to get SLA information from the document at the # specified URI. Currently, it is _very_ simple and will only search for a # phrase like "at least %" to get a basic availability SLA. def extract_sla(uri, pattern = %r{at least (\d+(?:\.\d+)?)%}im) @@ -36,8 +37,6 @@ def extract_sla(uri, pattern = %r{at least (\d+(?:\.\d+)?)%}im) doc = Nokogiri::HTML(open(uri)) pattern.match(doc.to_s) do |match| result['availability'] = (match[1].to_d / 100).to_s - # TODO: Extract more info from SLA. - # maybe we can even get some decent conditions from the SLA text. end result end diff --git a/app/provider_updaters/atlantic_net_updater.rb b/app/provider_updaters/atlantic_net_updater.rb index 4cc011b..363e144 100644 --- a/app/provider_updaters/atlantic_net_updater.rb +++ b/app/provider_updaters/atlantic_net_updater.rb @@ -23,6 +23,7 @@ def update_compute_batch end end + # Atlantic.Net API docs: https://www.atlantic.net/docs/api/?shell#describe-plans def update_compute uri = URI('https://cloudapi.atlantic.net/?Action=describe-plan') access_key_id = ENV['ANC_ACCESS_KEY_ID'] @@ -67,7 +68,8 @@ def update_compute next unless instance_type['platform'] == platform resource_id = instance_type['plan_name'] - #TODO: use real regions instead of default EUWEST region + # NOTICE: Currently hardcoded data center list. Looks like pricing is identical for all regions: + # https://www.atlantic.net/cloud-hosting/pricing/ regions = ['EUWEST1', 'USEAST1', 'USEAST2', 'USCENTRAL1', 'USWEST1', 'CAEAST1'] regions.each do |region| diff --git a/app/provider_updaters/google_updater.rb b/app/provider_updaters/google_updater.rb index c2b5808..f92127d 100644 --- a/app/provider_updaters/google_updater.rb +++ b/app/provider_updaters/google_updater.rb @@ -61,7 +61,7 @@ def update_compute(pricelist) regions.each do |region| resource = provider.resources.find_or_create_by(name: resource_id, region:region) resource.more_attributes['price_per_hour'] = value[region].to_s - # FIXME: 744 hours/month assumes a 31 day month. Same as above. + # NOTICE: 744 hours/month assumes a 31 day month. Same as above. price_per_month = BigDecimal.new(value[region].to_s) * 744 * full_month_discount resource.more_attributes['price_per_month'] = price_per_month # vCPU Quotas from https://cloud.google.com/compute/pricing#sharedcore diff --git a/app/provider_updaters/joyent_updater.rb b/app/provider_updaters/joyent_updater.rb index 75a1943..fa57ddf 100644 --- a/app/provider_updaters/joyent_updater.rb +++ b/app/provider_updaters/joyent_updater.rb @@ -18,7 +18,7 @@ def perform private def update_provider - #TODO: Add SLA for provider. CAUTION! Joyent has no 'actual' availability SLA, they claim 100%, but in reality it's around 0.9993, if you follow their example. + # NOTICE: Joyent has no 'actual' availability SLA, they claim 100%, but in reality it's around 0.9993, if you follow their example. # See here: https://www.joyent.com/about/policies/cloud-hosting-service-level-agreement provider = Provider.find_or_create_by(name: 'Joyent') diff --git a/bin/generate_mzn_data b/bin/generate_mzn_data index fad79e3..359b84f 100755 --- a/bin/generate_mzn_data +++ b/bin/generate_mzn_data @@ -17,7 +17,6 @@ puts "cpu = #{cores};" require 'matrix' transfer_costs = Matrix.build(resources.count, resources.count) do |row, col| - # FIXME: use actual transfer costs! (resources[row].provider_id - resources[col].provider_id).abs * 100 end.to_a.flatten diff --git a/lib/horizontal-scaling.mzn b/lib/horizontal-scaling.mzn index d5b744b..169a1f6 100644 --- a/lib/horizontal-scaling.mzn +++ b/lib/horizontal-scaling.mzn @@ -25,7 +25,6 @@ array[Resources] of int: costs; array[Resources] of int: ram; % CPU cores/usage per resource -% FIXME: ideally should be something we can fairly compare across providers array[Resources] of int: cpu; % Network transfer costs between resources diff --git a/lib/stove.mzn b/lib/stove.mzn index 1849ce7..a81e861 100644 --- a/lib/stove.mzn +++ b/lib/stove.mzn @@ -23,7 +23,6 @@ array[Resources] of int: costs; array[Resources] of int: ram; % CPU cores/usage per resource -% FIXME: ideally should be something we can fairly compare across providers array[Resources] of int: cpu; % Network transfer costs between resources