Skip to content

Conversation

@ipl31
Copy link
Contributor

@ipl31 ipl31 commented Aug 28, 2018

Overview

The example usage of wait_until() w/parameter succeed_on_found=True are incorrect to the best of my understanding.

When using the examples in this file I came across an issue deleting subnets. Specifically my wait_until() calls would throw exceptions because of a 404 even though I had the succeed_on_not_found parameter set to True. After some help from @arthall (thanks Art!) I determined that the examples in this file are incorrect and will reliably error out when trying to use them.

I believe the issue is the wait_until() call is unable to get a response object from the client.get() call when a non-tombstoning resource is deleted and disappears (resulting in 404) before it can get a response object to use for it's property check.

Proposed Fix

The proposed fix does a GET on the resource before calling wait_until() and then passes the resulting response to the wait_until() method. I have tested this fix locally a few times.

Reproduction steps

  1. Set your compartment ID and ADs in wait_for_resource_in_state.py.
  2. Run wait_for_resource_in_state.py. It should fail on the subnet deletion steps in at least one out of few runs but it will probably fail on all of them.

I get the following type of errors reliably:

Traceback (most recent call last):
  File "wait_for_resource_in_state_ken.py", line 105, in <module>
    oci.wait_until(virtual_network_client, virtual_network_client.get_subnet(subnet_ocid), 'lifecycle_state', 'TERMINATED', succeed_on_not_found=True)
  File "/Users/kcaruso/.virtualenvs/oci/lib/python2.7/site-packages/oci/core/virtual_network_client.py", line 5064, in get_subnet
    response_type="Subnet")
  File "/Users/kcaruso/.virtualenvs/oci/lib/python2.7/site-packages/oci/base_client.py", line 209, in call_api
    return self.request(request)
  File "/Users/kcaruso/.virtualenvs/oci/lib/python2.7/site-packages/oci/base_client.py", line 323, in request
    self.raise_service_error(request, response)
  File "/Users/kcaruso/.virtualenvs/oci/lib/python2.7/site-packages/oci/base_client.py", line 491, in raise_service_error
    original_request=request)
oci.exceptions.ServiceError: {'status': 404, 'message': u'Either Subnet with ID ocid1.subnet.oc1.phx.aaaaaaaanuauphx4dv7ltvdhion36oksvpbjlve54r7fojiuisopl6kflkkq does not exist or you are not authorized to access it.', 'code': u'NotAuthorizedOrNotFound', 'opc-request-id': 'A83957A1AA1645BBAEDB253A48D43A6A/2F91FFDE243B23F7668B8BF2CF3821FF/C9D75A6AC4D5412095DF8AF1D5B430A3'}

… of calling clients

Signed-off-by: Ken Caruso <ken.caruso@oracle.com>
Copy link
Contributor

@arthall arthall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the example, @ipl31.

@arthall arthall merged commit 67b0838 into oracle:master Aug 28, 2018
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

Successfully merging this pull request may close these issues.

2 participants