Skip to content

fix(cloudflare_list_item) fix bulk operation polling and update #5854

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

Closed

Conversation

broswen
Copy link

@broswen broswen commented Aug 4, 2025

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Creating, updating, or deleting list items results in an asynchronous bulk job that must be polled to know when it has completed and the new list item is visible.

It is not possible to update an existing list item by ID, so we must create a new list item and delete the old one.

If the "key" value is the same, they will be merged into the same list item. So we can optimize updates by only requiring replacement if the "key" value has changed.

Additional context & links

Bulk operation status
https://developers.cloudflare.com/api/resources/rules/subresources/lists/subresources/bulk_operations/methods/get/

@broswen broswen force-pushed the bswenson/list-item-poll-recreate branch from 722632a to 91c4fcc Compare August 4, 2025 22:50
@broswen broswen force-pushed the bswenson/list-item-poll-recreate branch from 91c4fcc to c3f1dec Compare August 5, 2025 14:03
@@ -97,6 +98,12 @@ func (r *ListItemResource) Create(ctx context.Context, req resource.CreateReques
return
}

err = pollBulkOperation(ctx, data.AccountID.ValueString(), createEnv.Result.OperationID.ValueString(), r.client)
Copy link
Contributor

@mgirouard mgirouard Aug 5, 2025

Choose a reason for hiding this comment

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

I don't know if we own the ctx instance, so I'm unclear what timeout exists already. Given that, should we have a new context WithTimeout?

(Ditto other calls to pollBulkOperation)

Copy link
Author

Choose a reason for hiding this comment

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

I don't see a context.WithTimeout used anywhere currently in the provider.

I'm adding a RequestOption onto the client calls. option.WithRequestTimeout(time.Second*3)

Copy link
Author

@broswen broswen Aug 5, 2025

Choose a reason for hiding this comment

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

It looks like in general Terraform has a 20min timeout set for each of the resource operations.
https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts#default-timeouts-and-deadline-exceeded-errors

@jeffa5
Copy link

jeffa5 commented Aug 6, 2025

@mgirouard @vaishakdinesh Could we get a review on this please, or merge it. If there are any changes I'll have to make a new PR (can't push to this branch).

@jeffa5
Copy link

jeffa5 commented Aug 7, 2025

@mgirouard @vaishakdinesh This is superseded by #5881 which has more acceptance tests and fixes the behaviour implemented here. The problem was that the search was not reliable at returning the expected item at the first index, and we don't really have a way of updating items so they should just be recreated.

@jeffa5
Copy link

jeffa5 commented Aug 12, 2025

This can be closed now that the other PR #5881 has been merged.

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.

4 participants