Skip to content

Commit

Permalink
drop unused columns
Browse files Browse the repository at this point in the history
access_key is more practical to configure outside the DB, and recovery_cost is going unused for the foreseeable future.  both are simple to re-add.

* migration to drop cols from DB
* remove related configuration
* remove related app and test code
  • Loading branch information
jmartin-sul committed May 22, 2018
1 parent 3074343 commit 44f5c67
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 37 deletions.
7 changes: 1 addition & 6 deletions app/models/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Endpoint < ApplicationRecord
validates :endpoint_type, presence: true
validates :endpoint_node, presence: true
validates :storage_location, presence: true
validates :recovery_cost, presence: true

scope :archive, lambda {
# TODO: maybe endpoint_class should be an enum or a constant?
Expand Down Expand Up @@ -55,7 +54,6 @@ def self.seed_storage_root_endpoints_from_config(endpoint_type, preservation_pol
endpoint.endpoint_type = endpoint_type
endpoint.endpoint_node = Settings.endpoints.storage_root_defaults.endpoint_node
endpoint.storage_location = File.join(storage_root_location, Settings.moab.storage_trunk)
endpoint.recovery_cost = Settings.endpoints.storage_root_defaults.recovery_cost
endpoint.preservation_policies = preservation_policies
end
end
Expand All @@ -67,8 +65,6 @@ def self.seed_archive_endpoints_from_config(preservation_policies)
endpoint.endpoint_type = EndpointType.find_by!(type_name: endpoint_config.endpoint_type_name)
endpoint.endpoint_node = endpoint_config.endpoint_node
endpoint.storage_location = endpoint_config.storage_location
endpoint.access_key = endpoint_config.access_key
endpoint.recovery_cost = endpoint_config.recovery_cost
endpoint.preservation_policies = preservation_policies
end
end
Expand All @@ -85,8 +81,7 @@ def to_h
endpoint_type_name: endpoint_type.type_name,
endpoint_type_class: endpoint_type.endpoint_class,
endpoint_node: endpoint_node,
storage_location: storage_location,
recovery_cost: recovery_cost
storage_location: storage_location
}
end

Expand Down
1 change: 0 additions & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ endpoints:
# value for endpoint_type_name must correspond to an endpoint_types entry (defined above)
endpoint_type_name: 'online_nfs'
endpoint_node: 'localhost'
recovery_cost: 1

moab:
# storage_trunk is the name of the directory under a storage_root which contains
Expand Down
2 changes: 0 additions & 2 deletions config/settings/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ archive_endpoints:
endpoint_type_name: 'aws_s3'
endpoint_node: 'localhost'
storage_location: 'bucket_name'
access_key: 'totallysecret'
recovery_cost: 10
workflow_services_url: 'https://sul-lyberservices-test.stanford.edu/workflow/'
2 changes: 0 additions & 2 deletions config/settings/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@ archive_endpoints:
endpoint_type_name: 'aws_s3'
endpoint_node: 'localhost'
storage_location: 'bucket_name'
access_key: 'totallysecret'
recovery_cost: 10
1 change: 0 additions & 1 deletion db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
* `endpoint_type_id`: the `EndpointType` implemented by this `Endpoint`.
* `endpoint_node`: the network location of the endpoint relative to the preservation catalog instance (e.g. localhost for a locally mounted NFS volume, s3.us-east-2.amazonaws.com for an S3 bucket, etc).
* `storage_location`: the path or bucket name or similar from which to read (e.g. "/services-disk03/sdr2objects", "sdr-bucket-01", etc).
* `access_key`: authorization info, if any, for connecting to the endpoint.
* `preservation_policies`: the preservation policies for which governed objects are preserved (declared to ActiveRecord via `has_and_belongs_to_many :preservation_policies`).
* An `EndpointType`, as the name implies, describes general shared characteristics common to many `Endpoint` instances. At present these include a general type name describing what sort of storage the endpoint is to be implemented on (e.g. our own NFS mounts, an AWS bucket, a Ceph instance, etc), as well as the type of objects the endpoint stores (at present, only "online" exploded moabs, or "archive" moabs packed into a single file).
* A `PreservationPolicy` defines
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20180518175719_remove_access_key_from_endpoints.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveAccessKeyFromEndpoints < ActiveRecord::Migration[5.1]
def change
remove_column :endpoints, :access_key, :string
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveRecoveryCostFromEndpoints < ActiveRecord::Migration[5.1]
def change
remove_column :endpoints, :recovery_cost, :integer
end
end
4 changes: 1 addition & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180517220356) do
ActiveRecord::Schema.define(version: 20180518180326) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -28,8 +28,6 @@
t.datetime "updated_at", null: false
t.string "endpoint_node", null: false
t.string "storage_location", null: false
t.integer "recovery_cost", null: false
t.string "access_key"
t.bigint "endpoint_type_id", null: false
t.integer "delivery_class"
t.index ["endpoint_name"], name: "index_endpoints_on_endpoint_name", unique: true
Expand Down
2 changes: 0 additions & 2 deletions spec/factories/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
factory :endpoint, aliases: [:online_endpoint] do
sequence(:endpoint_name) { |n| "endpoint#{format('%02d', n)}" }
endpoint_node 'localhost'
recovery_cost 1
storage_location { "spec/fixtures/#{endpoint_name}/moab_storage_trunk" }
endpoint_type # default online
end

factory :archive_endpoint, parent: :endpoint do
delivery_class 1
recovery_cost 10
association :endpoint_type, endpoint_class: 'archive'
end
end
18 changes: 4 additions & 14 deletions spec/models/endpoint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
endpoint_name: 'aws-us-east-2',
endpoint_type_id: endpoint_type.id,
endpoint_node: 's3.us-east-2.amazonaws.com',
storage_location: 'sdr-bucket-01',
recovery_cost: '5'
storage_location: 'sdr-bucket-01'
)
end

Expand All @@ -31,8 +30,7 @@
endpoint_name: 'aws-us-east-2',
endpoint_type_id: endpoint_type.id,
endpoint_node: 's3.us-east-2.amazonaws.com',
storage_location: 'sdr-bucket-01',
recovery_cost: '5'
storage_location: 'sdr-bucket-01'
)
end.to raise_error(ActiveRecord::RecordInvalid)
end
Expand All @@ -43,7 +41,6 @@
dup_endpoint.endpoint_name = 'aws-us-east-2'
dup_endpoint.endpoint_node = 's3.us-east-2.amazonaws.com'
dup_endpoint.storage_location = 'sdr-bucket-01'
dup_endpoint.recovery_cost = '5'
dup_endpoint.endpoint_type_id = endpoint_type.id
expect { dup_endpoint.save(validate: false) }.to raise_error(ActiveRecord::RecordNotUnique)
end
Expand All @@ -59,7 +56,6 @@
it { is_expected.to validate_presence_of(:endpoint_type) }
it { is_expected.to validate_presence_of(:endpoint_node) }
it { is_expected.to validate_presence_of(:storage_location) }
it { is_expected.to validate_presence_of(:recovery_cost) }

describe '.seed_storage_root_endpoints_from_config' do
let(:endpoint_type) { Endpoint.default_storage_root_endpoint_type }
Expand All @@ -71,7 +67,6 @@
endpoint_type: endpoint_type,
endpoint_node: Settings.endpoints.storage_root_defaults.endpoint_node,
storage_location: File.join(storage_root_location, Settings.moab.storage_trunk),
recovery_cost: Settings.endpoints.storage_root_defaults.recovery_cost,
preservation_policies: default_pres_policies
}
expect(Endpoint.find_by(endpoint_name: storage_root_name)).to have_attributes(storage_root_attrs)
Expand Down Expand Up @@ -124,8 +119,6 @@
endpoint_type: endpoint_type,
endpoint_node: endpoint_config.endpoint_node,
storage_location: endpoint_config.storage_location,
access_key: endpoint_config.access_key,
recovery_cost: endpoint_config.recovery_cost,
preservation_policies: default_pres_policies
}
expect(Endpoint.find_by(endpoint_name: endpoint_name)).to have_attributes(archive_endpoint_attrs)
Expand All @@ -146,9 +139,7 @@
Config::Options.new(
endpoint_type_name: 'aws_s3',
endpoint_node: 'endpoint_node',
storage_location: 'storage_location',
access_key: 'access_key',
recovery_cost: 20
storage_location: 'storage_location'
)
)
allow(Settings).to receive(:archive_endpoints).and_return(archive_endpoints_setting)
Expand Down Expand Up @@ -206,8 +197,7 @@
endpoint_type_name: 'aws',
endpoint_type_class: 'archive',
endpoint_node: 's3.us-east-2.amazonaws.com',
storage_location: 'sdr-bucket-01',
recovery_cost: 5
storage_location: 'sdr-bucket-01'
)
end
end
Expand Down
2 changes: 0 additions & 2 deletions spec/services/preserved_object_handler_check_exist_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@
endpoint.endpoint_type = Endpoint.default_storage_root_endpoint_type
endpoint.endpoint_node = Settings.endpoints.storage_root_defaults.endpoint_node
endpoint.storage_location = invalid_storage_dir
endpoint.recovery_cost = Settings.endpoints.storage_root_defaults.recovery_cost
end
# these need to be in before loop so it happens before each context below
invalid_po = PreservedObject.create!(
Expand Down Expand Up @@ -546,7 +545,6 @@
endpoint.endpoint_type = Endpoint.default_storage_root_endpoint_type
endpoint.endpoint_node = Settings.endpoints.storage_root_defaults.endpoint_node
endpoint.storage_location = storage_dir
endpoint.recovery_cost = Settings.endpoints.storage_root_defaults.recovery_cost
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
endpoint_name: 'diff_endpoint',
endpoint_type: Endpoint.default_storage_root_endpoint_type,
endpoint_node: 'localhost',
storage_location: 'blah',
recovery_cost: 1
storage_location: 'blah'
)
PreservedObject.create!(druid: druid, current_version: 2, preservation_policy: default_prez_policy)
po_handler = described_class.new(druid, 3, incoming_size, diff_ep)
Expand Down
1 change: 0 additions & 1 deletion spec/services/preserved_object_handler_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
endpoint.endpoint_type = Endpoint.default_storage_root_endpoint_type
endpoint.endpoint_node = Settings.endpoints.storage_root_defaults.endpoint_node
endpoint.storage_location = storage_dir
endpoint.recovery_cost = Settings.endpoints.storage_root_defaults.recovery_cost
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@
endpoint.endpoint_type = Endpoint.default_storage_root_endpoint_type
endpoint.endpoint_node = Settings.endpoints.storage_root_defaults.endpoint_node
endpoint.storage_location = storage_dir
endpoint.recovery_cost = Settings.endpoints.storage_root_defaults.recovery_cost
end
po = PreservedObject.create!(druid: druid, current_version: 2, preservation_policy: default_prez_policy)
t = Time.current
Expand Down

0 comments on commit 44f5c67

Please sign in to comment.