Open cyli opened 9 years ago
Using the following script:
"""
Script to see what responses CLB returns when it's immutable (BUILD,
PENDING_UPDATE, PENDING_DELETE, DELETED)
"""
from twisted.internet.task import deferLater, react
from twisted.internet.defer import gatherResults, inlineCallbacks
import json
import treq
@inlineCallbacks
def what_happens_when(clock, tenant_id, auth_token):
"""
Hammer CLB while it's immutable and see what responses are.
"""
lb_config = {
"loadBalancer": {
"name": "cyli-test",
"protocol": "HTTP",
"virtualIps": [
{"type": "PUBLIC"}
]
}
}
nodes = {
"nodes": [
{
"address": "124.1.2.3",
"port": 80,
"condition": "ENABLED",
"type": "PRIMARY"
},
{
"address": "125.1.2.4",
"port": 81,
"condition": "ENABLED",
"type": "SECONDARY"
}
]
}
url = "/".join((
"https://iad.loadbalancers.api.rackspacecloud.com/v1.0",
tenant_id, "loadbalancers"))
headers = {'x-auth-token': auth_token,
'content-type': 'application/json',
'accept': 'application/json'}
@inlineCallbacks
def see_how_responds(node_id='12345'):
resps = yield gatherResults([
treq.get('/'.join((url, lbid)), headers=headers),
treq.post('/'.join((url, lbid, 'nodes')), headers=headers,
data=json.dumps(nodes)),
treq.put('/'.join((url, lbid, 'nodes', node_id)),
headers=headers,
data=json.dumps({'condition': "DRAINING"})),
treq.delete('/'.join((url, lbid, 'nodes')), headers=headers,
params={'id': node_id}),
treq.delete('/'.join((url, lbid)), headers=headers),
treq.get('/'.join((url, lbid, "nodes")), headers=headers)
])
bodies = yield gatherResults(
[treq.json_content(resp) for resp in resps])
print "------"
print bodies[0]['loadBalancer']['status']
for i, thing in enumerate(["ADD N: ", "CHANGE N: ",
"DEL N: ", "DEL LB: ",
"LIST N: "]):
print thing, resps[i + 1].code
print json.dumps(bodies[i + 1])
print "------"
resp = yield treq.post(url, headers=headers, data=json.dumps(lb_config))
assert resp.code == 202
lbid = str((yield treq.json_content(resp))['loadBalancer']['id'])
yield see_how_responds()
# should be in active state after 60 seconds - add a node
resp = yield deferLater(
clock, 60, treq.post,
'/'.join((url, lbid, 'nodes')), headers=headers,
data=json.dumps({"nodes": [{"address": "123.1.2.1",
"port": 8080,
"condition": "ENABLED",
"type": "PRIMARY"}]}))
assert resp.code == 202
node_id = str((yield treq.json_content(resp))['nodes'][0]['id'])
yield see_how_responds(node_id)
# shoudl be in active state again after 60 seconds - deleted CLB
resp = yield deferLater(clock, 60, treq.delete, '/'.join((url, lbid)),
headers=headers)
yield see_how_responds(node_id)
# should be in deleted state now
resp = yield deferLater(clock, 60, lambda: None)
yield see_how_responds(node_id)
if __name__ == "__main__":
tenant_id = raw_input("Tenant ID: ")
auth_token = raw_input("Auth token for " + tenant_id + ": ")
react(what_happens_when, [tenant_id, auth_token])
I got the following results:
{"message": "Load Balancer '116301' has a status of 'BUILD' and is considered immutable.", "code": 422}
{"message": "Node not found", "code": 404}
{"message": "LoadBalancer is not ACTIVE", "code": 422}
{"message": "Must provide valid load balancers: 116301 are immutable and could not be processed.", "code": 400}
{"message": "Load Balancer '116303' has a status of 'PENDING_UPDATE' and is considered immutable.", "code": 422}
{"message": "Load Balancer '116303' has a status of 'PENDING_UPDATE' and is considered immutable.", "code": 422}
{"message": "LoadBalancer is not ACTIVE", "code": 422}
{"message": "Must provide valid load balancers: 116303 are immutable and could not be processed.", "code": 400}
{"message": "Load Balancer '116303' has a status of 'PENDING_DELETE' and is considered immutable.", "code": 422}
{"message": "Load Balancer '116303' has a status of 'PENDING_DELETE' and is considered immutable.", "code": 422}
{"message": "LoadBalancer is not ACTIVE", "code": 422}
{"message": "Must provide valid load balancers: 116303 are immutable and could not be processed.", "code": 400}
{"message": "The load balancer is deleted and considered immutable.", "code": 422}
{"message": "The loadbalancer is marked as deleted.", "code": 410}
{"message": "The load balancer is deleted and considered immutable.", "code": 422}
{"message": "Must provide valid load balancers: 116303 could not be found.", "code": 400}
{"message": "The loadbalancer is marked as deleted.", "code": 410}
No idea what the error messages are if CLB is in ERROR, since that is not something trigger-able on demand.
See #269 - this is the same but with CLBs.
This is a poor record, but here's some so far that Autoscale has seen:
{"message":"Load Balancer '375263' has a status of 'ERROR' and is considered immutable.","code":422}
{"message":"Load Balancer '375263' has a status of 'PENDING_UPDATE' and is considered immutable.","code":422}
{"message":"Load Balancer '375263' has a status of 'PENDING_DELETE' and is considered immutable.","code":422}
{"message":"The load balancer is deleted and considered immutable.","code":422}
{"message":"Node with id #5315312 not found for loadbalancer #375263","code":404}
{"message":"Load balancer not found.","code":404}
{"message":"Duplicate nodes detected. One or more nodes already configured on load balancer.","code":422}
{"message": "Nodes must not exceed 25 per load balancer.", "code": 413}