Skip to content

Commit

Permalink
create schedule even if we cannot see it (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov-aws authored Feb 6, 2024
1 parent 1d6c489 commit a46ca81
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions cid/helpers/quicksight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,12 +1125,27 @@ def ensure_dataset_refresh_schedule(self, dataset_id, schedules: list):
try:
existing_schedules = self.get_dataset_refresh_schedules(dataset_id)
except CidError as exc:
logger.debug(f'List refresh schedule throws: {exc}')
logger.warning(
f'Cannot read dataset schedules for dataset = {dataset_id}. {str(exc)}. Skipping schedule management.'
' Please make sure scheduled refresh is configured manually.'
)
return
# We cannot access schedules, but let's check if there are scheduled ingestions.
ingestions_exist = False
try:
ingestions_exist = list(
self.client.get_paginator('list_ingestions').paginate(
DataSetId=dataset_id,
AwsAccountId=self.account_id
).search("Ingestions[?RequestSource=='SCHEDULED']")
)
except Exception:
logger.debug(f'List refresh schedule throws: {exc}')
logger.warning(
f'Cannot read dataset schedules for dataset = {dataset_id}. {str(exc)}. Skipping schedule management.'
' Please make sure scheduled refresh is configured manually.'
)
return
if ingestions_exist:
logger.debug(f'We cannot read schedules but there are ingestions. Skipping creation of schedule.')
return
logger.debug(f'We cannot read schedules but there no ingestions. Continue to creation of schedule.')
existing_schedules = []

if schedules:
if exec_env()['terminal'] in ('lambda'):
Expand Down Expand Up @@ -1198,6 +1213,8 @@ def ensure_dataset_refresh_schedule(self, dataset_id, schedules: list):
logger.error(f'Unable to create refresh schedule with id {schedule["ScheduleId"]}. Dataset {dataset_id} does not exist.')
except self.client.exceptions.AccessDeniedException:
logger.error(f'Unable to create refresh schedule with id {schedule["ScheduleId"]}. Please add quicksight:CreateDataSet permission.')
except self.client.exceptions.ResourceExistsException:
logger.info(f'Schedule with id {schedule["ScheduleId"]} exists. But can have other settings. You better check.')
except Exception as exc:
logger.error(f'Unable to create refresh schedule with id {schedule["ScheduleId"]} for dataset "{dataset_id}": {str(exc)}')
else:
Expand Down

0 comments on commit a46ca81

Please sign in to comment.