Skip to content

Commit

Permalink
Review and fix or document TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
joe4dev committed Jan 25, 2017
1 parent 66386db commit 0fe8258
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 11 deletions.
5 changes: 3 additions & 2 deletions app/models/deployment_recommendation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions app/models/provider_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <nn.nn>%" to get a basic availability SLA.
def extract_sla(uri, pattern = %r{at least (\d+(?:\.\d+)?)%}im)
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion app/provider_updaters/atlantic_net_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion app/provider_updaters/google_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/provider_updaters/joyent_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 0 additions & 1 deletion bin/generate_mzn_data
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion lib/horizontal-scaling.mzn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/stove.mzn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0fe8258

Please sign in to comment.