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

Some BlockStorage composite operations throw a 404/NotAuthorizedOrNotFound for Cross Region operations #344

Closed
github-anurag opened this issue Apr 30, 2021 · 2 comments · Fixed by #374

Comments

@github-anurag
Copy link
Member

github-anurag commented Apr 30, 2021

The copy_boot_volume_backup_and_wait_for_state() and copy_volume_backup_and_wait_for_state() from the BlockStorage Client Composite operations throw a 404/NotAuthorizedOrNotFound when copying a backup from one region to another.

Example:-

region = "us-ashburn-1"
dr_region = "us-phoenix-1"
backup_item_id = "ocid1.volumebackup.oc1.iad.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
backup_item_display_name = "abc"
config = from_file() # gets ~./.oci/config and reads to the object
storage_client = BlockstorageClient(config) # storage instance primary region
storage_composite_client = BlockstorageClientCompositeOperations(storage_client)

replication_request_response = storage_composite_client.copy_volume_backup_and_wait_for_state(
    volume_backup_id = backup_item_id,
    copy_volume_backup_details = CopyVolumeBackupDetails(
        destination_region = dr_region,
        display_name = backup_item_display_name
    ),
    wait_for_states = ["AVAILABLE"]
).data

ServiceError: {'opc-request-id': '123456789', 'code': 'NotAuthorizedOrNotFound', 'message': 'Authorization failed or requested resource not found.', 'status': 404}

A workaround would be to use two different clients for this operation. A client in Source Region to send the request for the backup copy from Region A to Region B, and a client in Destination region which would then wait for the backup to become available.

An example using this approach can be found at:-
CopyVolumeBackup
CopyBootVolumeBackup

@github-anurag github-anurag added the SDK Issue pertains to the SDK itself and not specific to any service label Apr 30, 2021
@github-anurag
Copy link
Member Author

This issue has been resolved in v2.43.2 with the introduction of two new operations in BlockstorageClientCompositeOperations namely copy_boot_volume_backup_and_wait_for_work_request & copy_volume_backup_and_wait_for_work_request.

@github-anurag github-anurag linked a pull request Aug 3, 2021 that will close this issue
@github-anurag
Copy link
Member Author

An example usage:-

import oci
import argparse

# parse arguments
parser = argparse.ArgumentParser()
parser.add_argument('--boot-volume-backup-id',
                    help='the OCID of the boot volume backup to copy',
                    required=True
                    )
parser.add_argument('--destination-region',
                    help='the name of the destination region to copy the backup to',
                    required=True
                    )

parser.add_argument('--display-name',
                    help='the display name of the copied boot volume backup. If not specified, '
                         'defaults to the same as the original backup\'s display name',
                    required=False
                    )

parser.add_argument('--kms-key-id',
                    help='the OCID of the kms key in the destination region to encrypt the copied boot volume backup',
                    required=False
                    )
args = parser.parse_args()

source_backup_id = args.boot_volume_backup_id
destination_region = args.destination_region
kms_key_id = args.kms_key_id
display_name = args.display_name

# load config and create client and composite operation client
source_config = oci.config.from_file()
blockstorage_client = oci.core.BlockstorageClient(source_config)
blockstorage_composite_client = oci.core.BlockstorageClientCompositeOperations(blockstorage_client)
response = blockstorage_composite_client.copy_boot_volume_backup_and_wait_for_work_request(
    boot_volume_backup_id=source_backup_id,
    copy_boot_volume_backup_details=oci.core.models.CopyBootVolumeBackupDetails(
        destination_region=destination_region,
        display_name=display_name,
        kms_key_id=kms_key_id
    ))
print(response.data)

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 a pull request may close this issue.

1 participant