Skip to content

Conversation

@vandonr-amz
Copy link
Contributor

Existing code had several problems imho, like

  • using 3 different sleep times, only one being configurable
  • sleeping before doing anything
  • relying on the last run being the one we care about, which is not necessarily true

I also refactored some duplicated code and added a wait_for_completion parameter to skip the wait entirely if needed.

@vandonr-amz vandonr-amz requested a review from eladkal as a code owner January 12, 2023 00:44
@boring-cyborg boring-cyborg bot added area:providers provider:amazon AWS/Amazon - related issues labels Jan 12, 2023
Comment on lines 101 to 104
# previous code had a wait between update and run without explaining why.
# since I don't have a way to actually test this behavior,
# I'm reproducing it out of fear of breaking workflows.
# It might be unnecessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

@igorborgest maybe you could and explanation?

Copy link
Contributor

Choose a reason for hiding this comment

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

If I recall correctly, the updates are not propagated atomically. So this sleep was to avoid runs using the previous configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

checked it with the team, and it's true for on-demand flows (see https://docs.aws.amazon.com/appflow/latest/userguide/flow-triggers.html for a desc of the different types of flows)
I updated the comment accordingly.
Unfortunately, we don't have infra setup to be able to run the appflow system test (because it depends on external sources), so it's a bit hard for me to test it.

@igorborgest
Copy link
Contributor

Great improvements @vandonr-amz, thank you!

Just one point, I recommend testing it against the real service.
AppFlow is one of the most annoying services I have worked with. Seems everything is eventually consistent.

@o-nikolas
Copy link
Contributor

@Taragolis @igorborgest are you happy with the state of this PR or would you like to see any other changes/testing?

@Taragolis
Copy link
Contributor

@o-nikolas Oh, I really do not use Appflow. I've just ping Igor, because remember (and git blame told me) that he initially implement. But let me have a look.


if last_exec_details["mostRecentExecutionStatus"] == "Error":
raise Exception(f"Flow error:\n{json.dumps(response_desc, default=str)}")
if wait_for_completion:
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having this custom logic, would not it be possible to use a custom waiter as in #29822?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, but do you think it should be done as part of this PR ? How about I push the conversion to waiter as a new PR ?

Copy link
Contributor

@vincbeck vincbeck Mar 2, 2023

Choose a reason for hiding this comment

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

To me it should be done in this PR. It is basically the same problem with 2 different implementations, let's aim directly the desire implementation

Copy link
Contributor

@ferruzzi ferruzzi Mar 2, 2023

Choose a reason for hiding this comment

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

I definitely agree that this should be a waiter and may as well be done now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, but after taking a look at it, waiter configurations don't allow implementing the logic needed here.

Because the API doesn't allow querying status by run ID, we have to employ other means. The old logic was somewhat flawed but still checked the timestamp to make sure we weren't picking up the previous run. The new logic relies on the run ID. Both of those behavior are not possible with regular waiters, so I wouldn't block this PR on this.

Copy link
Contributor

@ferruzzi ferruzzi Mar 3, 2023

Choose a reason for hiding this comment

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

We talked offline and it does look like the AppFlow waiters are a non-trivial change. They handle their waiters completely differently than other services. I still think a custom-waiters-first approach is
the best approach, but in this case I'm willing to approve this as is.

Copy link
Contributor

@ferruzzi ferruzzi left a comment

Choose a reason for hiding this comment

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

We talked offline and it does look like the AppFlow waiters are a non-trivial change. They handle their waiters completely differently than other services. I still think a custom-waiters-first approach is the best approach, but in this case I'm willing to approve this as is.

Edit to clarify: "custom-waiters-first approach" meaning we should prefer them when reasonably possible. In this case it's a LOT more work for marginal gain. "I don't feel like updating the json file" isn't IMHO a valid reason to skip using a custom waiter design.

Copy link
Contributor

@vincbeck vincbeck left a comment

Choose a reason for hiding this comment

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

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:amazon AWS/Amazon - related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants