Repository: cloud-custodian/cloud-custodian

Issue:
traceback when set-ssl-listener-policy action performed on ELB having multiple HTTPS listeners
```
2018-01-25 11:04:38,083: c7n.worker:ERROR Error invoking c7n.resources.elb.process_elb
Traceback (most recent call last):
  File "/Users/me/code/cloud/cloud-custodian/c7n/utils.py", line 410, in _f
    return f(*args, **kw)
  File "/Users/me/code/cloud/cloud-custodian/c7n/resources/elb.py", line 336, in process_elb
    policy_names.remove(ssl_policies[0])
ValueError: list.remove(x): x not in list
2018-01-25 11:04:38,088: custodian.output:ERROR Error while executing policy
Traceback (most recent call last):
  File "/Users/me/code/cloud/cloud-custodian/c7n/policy.py", line 337, in run
    results = a.process(resources)
  File "/Users/me/code/cloud/cloud-custodian/c7n/resources/elb.py", line 293, in process
    list(w.map(self.process_elb, load_balancers))
  File "/Users/me/code/cloud/cloud-custodian/lib/python2.7/site-packages/concurrent/futures/_base.py", line 641, in result_iterator
    yield fs.pop().result()
  File "/Users/me/code/cloud/cloud-custodian/lib/python2.7/site-packages/concurrent/futures/_base.py", line 462, in result
    return self.__get_result()
  File "/Users/me/code/cloud/cloud-custodian/lib/python2.7/site-packages/concurrent/futures/thread.py", line 63, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/me/code/cloud/cloud-custodian/c7n/utils.py", line 410, in _f
    return f(*args, **kw)
  File "/Users/me/code/cloud/cloud-custodian/c7n/resources/elb.py", line 336, in process_elb
    policy_names.remove(ssl_policies[0])
ValueError: list.remove(x): x not in list
2018-01-25 11:04:38,090: custodian.commands:ERROR Error while executing policy derp, continuing
Traceback (most recent call last):
  File "/Users/me/code/cloud/cloud-custodian/c7n/commands.py", line 217, in run
    policy()
  File "/Users/me/code/cloud/cloud-custodian/c7n/policy.py", line 750, in __call__
    resources = mode.run()
  File "/Users/me/code/cloud/cloud-custodian/c7n/policy.py", line 337, in run
    results = a.process(resources)
  File "/Users/me/code/cloud/cloud-custodian/c7n/resources/elb.py", line 293, in process
    list(w.map(self.process_elb, load_balancers))
  File "/Users/me/code/cloud/cloud-custodian/lib/python2.7/site-packages/concurrent/futures/_base.py", line 641, in result_iterator
    yield fs.pop().result()
  File "/Users/me/code/cloud/cloud-custodian/lib/python2.7/site-packages/concurrent/futures/_base.py", line 462, in result
    return self.__get_result()
  File "/Users/me/code/cloud/cloud-custodian/lib/python2.7/site-packages/concurrent/futures/thread.py", line 63, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/me/code/cloud/cloud-custodian/c7n/utils.py", line 410, in _f
    return f(*args, **kw)
  File "/Users/me/code/cloud/cloud-custodian/c7n/resources/elb.py", line 336, in process_elb
    policy_names.remove(ssl_policies[0])
ValueError: list.remove(x): x not in list
```


Discussion:

Resolving patch:
diff --git a/c7n/resources/elb.py b/c7n/resources/elb.py
--- a/c7n/resources/elb.py
+++ b/c7n/resources/elb.py
@@ -333,7 +333,7 @@ def process_elb(self, elb):
                 policy_names.extend(ld.get('PolicyNames', ()))
                 # Remove extant ssl listener policy
                 if ssl_policies:
-                    policy_names.remove(ssl_policies[0])
+                    policy_names = list(set(policy_names).difference(ssl_policies))
                 client.set_load_balancer_policies_of_listener(
                     LoadBalancerName=lb_name,
                     LoadBalancerPort=ld['Listener']['LoadBalancerPort'],


Test patch: