Skip to content

Commit

Permalink
Remove unused code (#4072)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethboyles authored Dec 16, 2024
1 parent 42f955a commit b5adbf3
Show file tree
Hide file tree
Showing 14 changed files with 5 additions and 123 deletions.
1 change: 0 additions & 1 deletion lib/cloud_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ module VCAP::CloudController; end
require 'cloud_controller/transport_rule_validator'
require 'cloud_controller/icmp_rule_validator'
require 'cloud_controller/controller_factory'
require 'cloud_controller/egress_network_rules_presenter'
require 'cloud_controller/organization_instance_usage_calculator'
require 'cloud_controller/organization_quota_usage'
require 'cloud_controller/url_secret_obfuscator'
Expand Down
4 changes: 0 additions & 4 deletions lib/cloud_controller/backends/runners.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,5 @@ def diego_runner(process)
def dependency_locator
CloudController::DependencyLocator.instance
end

def staging_timeout
@config.get(:staging, :timeout_in_seconds)
end
end
end
2 changes: 0 additions & 2 deletions lib/cloud_controller/background_job_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def initialize(config)
@logger = Steno.logger('cc.background')
end

READINESS_SOCKET_QUEUE_DEPTH = 100

def setup_environment(readiness_port=nil)
VCAP::CloudController::DB.load_models(@config.get(:db), @logger)
@config.configure_components
Expand Down
6 changes: 0 additions & 6 deletions lib/cloud_controller/blobstore/fingerprints_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ def each(&block)
end
end

def storage_size
@fingerprints.inject(0) do |sum, fingerprint|
sum + fingerprint['size']
end
end

private

def parse_mode(raw_mode, filename)
Expand Down
2 changes: 2 additions & 0 deletions lib/cloud_controller/drain.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This class is used in capi-release (e.g. https://github.com/cloudfoundry/capi-release/blob/b817791b0f4d8780304cef148f1aeb3f2a944af8/jobs/cloud_controller_ng/templates/shutdown_drain.rb.erb#L8)

require 'logger'
require 'fileutils'

Expand Down
11 changes: 0 additions & 11 deletions lib/cloud_controller/egress_network_rules_presenter.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/cloud_controller/resource_match.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module VCAP::CloudController
class ResourceMatch
attr_reader :descriptors, :minimum_size, :maximum_size, :resource_batch_id
attr_reader :descriptors

FILE_SIZE_GROUPS = {
'1KB or less': 0...1.kilobyte,
Expand Down
6 changes: 1 addition & 5 deletions lib/cloud_controller/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

module VCAP::CloudController
class Runner
attr_reader :config, :config_file, :insert_seed_data, :secrets_file
attr_reader :config, :config_file, :secrets_file

def initialize(argv)
@argv = argv
Expand Down Expand Up @@ -66,10 +66,6 @@ def options_parser
end
end

def deprecation_warning(message)
Rails.logger.warn message
end

def parse_options!
options_parser.parse!(@argv)
raise 'Missing config' if @config_file.blank?
Expand Down
8 changes: 0 additions & 8 deletions lib/cloud_controller/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,6 @@ def seed_encryption_key_sentinels(config)
def routing_api_client
CloudController::DependencyLocator.instance.routing_api_client
end

def domain_overlap(parsed_domain, system_config)
overlap = false
parsed_domain.each do |d|
overlap = true if d['name'].include?(system_config)
end
overlap
end
end
end
end
9 changes: 0 additions & 9 deletions lib/diego/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ def initialize(url:, ca_cert_file:, client_cert_file:, client_key_file:,
)
end

def ping
response = with_request_error_handling do
client.post(Routes::PING)
end

validate_status_200!(response)
protobuf_decode!(response.body, Bbs::Models::PingResponse)
end

def upsert_domain(domain:, ttl:)
request = protobuf_encode!({ domain: domain, ttl: ttl.to_i }, Bbs::Models::UpsertDomainRequest)

Expand Down
45 changes: 1 addition & 44 deletions spec/diego/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,49 +34,6 @@ module Diego
end
end

describe '#ping' do
let(:response_body) { Bbs::Models::PingResponse.encode(Bbs::Models::PingResponse.new(available: true)).to_s }
let(:response_status) { 200 }

before do
stub_request(:post, "#{bbs_url}/v1/ping").to_return(status: response_status, body: response_body)
end

it 'returns a ping response' do
expect(client.ping.available).to be_truthy
expect(a_request(:post, "#{bbs_url}/v1/ping")).to have_been_made.once
end

context 'when it does not return successfully' do
let(:response_status) { 500 }
let(:response_body) { 'Internal Server Error' }

it 'raises' do
expect { client.ping }.to raise_error(ResponseError, /status: 500, body: Internal Server Error/)
end
end

context 'when it fails to make the request' do
before do
stub_request(:post, "#{bbs_url}/v1/ping").to_raise(StandardError.new('error message'))
allow(subject).to receive(:sleep) { |n| Timecop.travel(n) }
end

it 'raises' do
expect { client.ping }.to raise_error(RequestError, /error message/)
expect(a_request(:post, "#{bbs_url}/v1/ping")).to have_been_made.times(17)
end
end

context 'when decoding the response fails' do
let(:response_body) { 'potato' }

it 'raises' do
expect { client.ping }.to raise_error(DecodeError)
end
end
end

describe '#upsert_domain' do
let(:response_body) { Bbs::Models::UpsertDomainResponse.encode(Bbs::Models::UpsertDomainResponse.new(error: nil)).to_s }
let(:response_status) { 200 }
Expand Down Expand Up @@ -887,7 +844,7 @@ module Diego
end

it 'sets TCPSocket:connect_timeout to HTTPClient:connect_timeout / 2' do
expect { client.ping }.to raise_error('done!')
expect { client.task_by_guid('b62be6c2-0f2c-4199-94d3-41a69e00f67d') }.to raise_error('done!')
expect(TCPSocket).to have_received(:new).with(bbs_host, bbs_port, { connect_timeout: timeout / 2 }).exactly(17).times
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ module Blobstore
end
end

describe '#storage_size' do
it 'sums the sizes' do
expect(collection.storage_size).to eq 123 + 321 + 112
end
end

describe '#fingerprints' do
let(:unpresented_fingerprints) do
[
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions spec/unit/lib/cloud_controller/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ module VCAP::CloudController
end

describe '#initialize' do
before do
allow_any_instance_of(Runner).to receive(:deprecation_warning)
end

describe 'web server selection' do
context 'when thin is specifed' do
it 'chooses ThinRunner as the web server' do
Expand Down

0 comments on commit b5adbf3

Please sign in to comment.