Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit c2c403f

Browse files
committed
routing-daemon: F5: Delete client-ssl profile
F5IControlRestLoadBalancerModel#remove_ssl: Try to delete the client-ssl profile even if deleting it from the virtual server fails; try to delete the key even if deleting the client-ssl fails; and try to delete the certificate even if deleting the key fails. LBModelExceptionCollector: New helper class to rescue, collect, and combine LBModelException exceptions. F5 BIG-IP will not let us delete a resource that is in use (e.g., a client-ssl profile that is still associated with a virtual server), but this change will enable the routing-daemon to finish cleaning up a client-ssl profile or associated key or certificate that is already deleted from the virtual server.
1 parent 2fbcf34 commit c2c403f

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

routing-daemon/lib/openshift/routing/models/f5-icontrol-rest.rb

+20-8
Original file line numberDiff line numberDiff line change
@@ -358,17 +358,29 @@ def add_ssl pool_name, alias_str, ssl_cert, private_key
358358
end
359359

360360
def remove_ssl pool_name, alias_str
361-
@logger.debug("LTM removing #{URI.escape(alias_str)}-ssl-profile client-ssl from #{@https_vserver}")
362-
delete(resource: "/mgmt/tm/ltm/virtual/#{@https_vserver}/profiles/#{URI.escape(alias_str)}-ssl-profile")
361+
@exceptions = LBModelExceptionCollector.new
363362

364-
@logger.debug("LTM deleting removing #{URI.escape(alias_str)}-ssl-profile")
365-
delete(resource: "/mgmt/tm/ltm/profile/client-ssl/#{URI.escape(alias_str)}-ssl-profile")
363+
@exceptions.try do
364+
@logger.debug("LTM removing #{URI.escape(alias_str)}-ssl-profile client-ssl from #{@https_vserver}")
365+
delete(resource: "/mgmt/tm/ltm/virtual/#{@https_vserver}/profiles/#{URI.escape(alias_str)}-ssl-profile")
366+
end
367+
368+
@exceptions.try do
369+
@logger.debug("LTM deleting removing #{URI.escape(alias_str)}-ssl-profile")
370+
delete(resource: "/mgmt/tm/ltm/profile/client-ssl/#{URI.escape(alias_str)}-ssl-profile")
371+
end
366372

367-
@logger.debug("LTM removing #{alias_str}-https-key")
368-
delete(resource: "/mgmt/tm/sys/file/ssl-key/#{URI.escape(alias_str)}-https-key.key")
373+
@exceptions.try do
374+
@logger.debug("LTM removing #{alias_str}-https-key")
375+
delete(resource: "/mgmt/tm/sys/file/ssl-key/#{URI.escape(alias_str)}-https-key.key")
376+
end
377+
378+
@exceptions.try do
379+
@logger.debug("LTM removing #{alias_str}-https-cert")
380+
delete(resource: "/mgmt/tm/sys/file/ssl-cert/#{URI.escape(alias_str)}-https-cert.crt")
381+
end
369382

370-
@logger.debug("LTM removing #{alias_str}-https-cert")
371-
delete(resource: "/mgmt/tm/sys/file/ssl-cert/#{URI.escape(alias_str)}-https-cert.crt")
383+
@exceptions.done
372384
end
373385

374386
def get_pool_certificates pool_name

routing-daemon/lib/openshift/routing/models/load_balancer.rb

+21
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@ module OpenShift
22

33
class LBModelException < StandardError; end
44

5+
class LBModelExceptionCollector
6+
def initialize
7+
@exceptions = []
8+
end
9+
10+
def try
11+
yield
12+
rescue LBModelException => e
13+
@exceptions << e
14+
end
15+
16+
def to_s
17+
"got #{@exceptions.length} LBModelException exceptions: " +
18+
@exceptions.map {|e| e.message}.join('; ')
19+
end
20+
21+
def done
22+
raise LBModelException.new self.to_s unless @exceptions.empty?
23+
end
24+
end
25+
526
# == Abstract routing model class
627
#
728
# Presents direct access to a load balancer. This is an abstract class.

0 commit comments

Comments
 (0)