Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While using BIG-IQ.task_start, timeout is caught #3

Closed
ictabc opened this issue Mar 14, 2024 · 2 comments
Closed

While using BIG-IQ.task_start, timeout is caught #3

ictabc opened this issue Mar 14, 2024 · 2 comments

Comments

@ictabc
Copy link

ictabc commented Mar 14, 2024

Jason, just found out you took over the BIGREST sdk, hope you can help me.

We need to migrate to a new BIG-IQ/BIG-IP environment, while the old system will keep up and running until actual migration. Wished we didn't need to, but F5 support said the only way to fix the issues we have is to rebuild a complete new BIG-IQ/BIG-IP setup. If you want to know the reason I can forward you the case number.

It's all done with AS3, some VIPS still manual created but will be recreated with AS3 if possible. As AS3 APPSVCS is still missing alot of needed functionality, even official RESTapi/ansible/terraform is missing nethsm support, only available via CLI/GUI.

I found an ansible script to replace a BIG-IP in a BIG-IQ setup, and trying to create with the ansible as an example a script so I can use it to populate an new BIG-IQ/IP enviroment Ansible script is only for replacing an BIG-IP using the same BIG-IQ.

It's all using BGP, and the new systems is prepended so it will not become active, and we should be able to force offline the old BIG-IP's and everything should run through the new enviroment. Should work but needs testing :P

But I have a small issue, the below code works, but when I start an task (BIG-IQ.task_start), I get a request.exceptions.ReadTimeout. Can understand that because it takes a while for BIG-IQ to process an AS3 script. But I would have thought this would be caught so I could use the BIG-IQ.task_wait and BIG-IQ.task_completed to check progress. Could be that I am using the wrong URL, and should use something else. I know BIG-IQ has some options, but couldn't find anything yet so task_start works. Examples are a bit simple most of the times.

At this time it works for a single AS3, but script stops when getting the timeout (10 seconds) not changeable.

Woud be nice if this could be solved in BIGREST, I will try to catch this exception and continue the program, so I can continue. But maybe in the future more people will hit this, as AS3 is getting some momentum. And if you have a good option for catching this, I would be gratefull.

This is my test script, need to extend stuff, so we can migrate a single vip to a complete partition to all partitions (Excluding Common)

Code:

# get data from old BIG-IQ
data = get_realtime_bigiq_data_partition(device, url)

# Itterate through data and replace the IP for target value "address" to the new BIG-IP IP address.
for data_element in data:
    data_element.properties["body"]["target"]["address"] = big_ip_new

    # Print debug output for visual inspection
    print(json.dumps(data_element.properties["body"], indent=4))

    # Open connection to new BIG-IQ
    device_az2, token_bigiq_az2, token_creation_az2 = connect_to_big_iq(bigiq_device_az2,username,password,login_provider, timeout) <<== Added timeout value

    # Start a task, with the AS3 data 
    task = device_az2.task_start("/mgmt/shared/appsvcs/declare",json.dumps(data_element.properties["body"]))

    # Check if task is finished
    device_az2.task_wait(task)
    
    # If task completed print task info
    if device_az2.task_completed(task):
            print("Task "+ bigiq_partition + " completed.")

Error:

Traceback (most recent call last):
File "/

//py39/lib64/python3.9/site-packages/urllib3/connectionpool.py", line 537, in _make_request
response = conn.getresponse()
File "///py39/lib64/python3.9/site-packages/urllib3/connection.py", line 466, in getresponse
httplib_response = super().getresponse()
File "/usr/lib64/python3.9/http/client.py", line 1377, in getresponse
response.begin()
File "/usr/lib64/python3.9/http/client.py", line 320, in begin
version, status, reason = self._read_status()
File "/usr/lib64/python3.9/http/client.py", line 281, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib64/python3.9/socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "/usr/lib64/python3.9/ssl.py", line 1275, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib64/python3.9/ssl.py", line 1133, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/

//py39/lib64/python3.9/site-packages/requests/adapters.py", line 486, in send
resp = conn.urlopen(
File "///py39/lib64/python3.9/site-packages/urllib3/connectionpool.py", line 847, in urlopen
retries = retries.increment(
File "///py39/lib64/python3.9/site-packages/urllib3/util/retry.py", line 470, in increment
raise reraise(type(error), error, _stacktrace)
File "///py39/lib64/python3.9/site-packages/urllib3/util/util.py", line 39, in reraise
raise value
File "///py39/lib64/python3.9/site-packages/urllib3/connectionpool.py", line 793, in urlopen
response = self._make_request(
File "///py39/lib64/python3.9/site-packages/urllib3/connectionpool.py", line 539, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "///py39/lib64/python3.9/site-packages/urllib3/connectionpool.py", line 370, in _raise_timeout
raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='', port=443): Read timed out. (read timeout=10)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/

//big-iq-migrate.py", line 278, in
main()
File "///big-iq-migrate.py", line 270, in main
process_bigiq_config(args.test, args.savedata,args.big_iq_partition,args.bigiq_address,args.bigiq_user,args.bigiq_password,args.action)
File "///big-iq-migrate.py", line 150, in process_bigiq_config
task = device_az2.task_start("/mgmt/shared/appsvcs/declare",json.dumps(data_element.properties["body"]))
File "///py39/lib64/python3.9/site-packages/bigrest/bigiq.py", line 56, in task_start
response = self.session.post(url, json=data, timeout=self.timeout)
File "///py39/lib64/python3.9/site-packages/requests/sessions.py", line 637, in post
return self.request("POST", url, data=data, json=json, **kwargs)
File "///py39/lib64/python3.9/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "///py39/lib64/python3.9/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "///py39/lib64/python3.9/site-packages/requests/adapters.py", line 532, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='', port=443): Read timed out. (read timeout=10)

@ictabc
Copy link
Author

ictabc commented Mar 18, 2024

Ok, figured out what my problem was, needed to set a time while connecting to the device. But did get another issue, the reply will also produce an exemption. But will create a separate issue for that.

@ictabc
Copy link
Author

ictabc commented Mar 18, 2024

Closed issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant