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

UpdateLogpushJobParams: Make it possible to remove logpull_options on update #1711

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dloebl
Copy link

@dloebl dloebl commented Apr 9, 2024

Description

For reference: #1709
Make it possible to remove the logpull_options on update. I think this is still an issue with the Cloudflare API: I would expect a PUT to overwrite the existing resource, not only change the specified values.

Before:
PUT request (TF_LOG=trace output):

PUT /client/v4/zones/[redacted]/logpush/jobs/[redacted] HTTP/1.1
Host: api.cloudflare.com
User-Agent: terraform-provider-cloudflare/dev terraform-plugin-sdk/2.32.0 terraform/1.7.5
Content-Type: application/json
Body: {"dataset":"http_requests","enabled":false,"name":"example","output_options":{"field_names":[],"output_type":"ndjson","record_prefix":"{","record_suffix":"}","field_delimiter":",","timestamp_format":"unixnano","sample_rate":1,"CVE-2021-44228":false},"destination_conf":"[redacted]","frequency":"high"}

With this change:
PUT request (TF_LOG=trace output):

PUT /client/v4/zones/[redacted]/logpush/jobs/[redacted] HTTP/1.1
Host: api.cloudflare.com
User-Agent: terraform-provider-cloudflare/dev terraform-plugin-sdk/2.32.0 terraform/1.7.5
Body: {"dataset":"http_requests","enabled":false,"name":"example","logpull_options":"","output_options":{"field_names":[],"output_type":"ndjson","record_prefix":"{","record_suffix":"}","field_delimiter":",","timestamp_format":"unixnano","sample_rate":1,"CVE-2021-44228":false},"destination_conf":"[redacted]","frequency":"high"}

Output of the second terraform plan

No changes. Your infrastructure matches the configuration.

Types of changes

What sort of change does your code introduce/modify?

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • This change is using publicly documented in cloudflare/api-schemas
    and relies on stable APIs.

Copy link
Contributor

github-actions bot commented Apr 9, 2024

changelog detected ✅

@jacobbednarz
Copy link
Member

we shouldn't be sending empty strings to the API in order to remove values when using PUT given it should represent the final state of the resource. the omitempty here is the correct way of handling it so we i can't accept the PR as is.

let me check with the internal team as to which behaviour we are expecting here.

@dloebl
Copy link
Author

dloebl commented Apr 10, 2024

Thanks Jacob! Yeah, I think it would be better to solve this right at the API level. Just let me know in case further details are needed.

@sbfaulkner
Copy link
Contributor

@jacobbednarz any update on this getting resolved upstream in the API ?

@jacobbednarz
Copy link
Member

no further updates at this point. the team have it in their backlog to investigate and look at a fix to maintain compatibility.

the output_options takes precedence over logput_options though so you should be fine defining the newer version and it taking effect.

@josip-stanic
Copy link
Contributor

We've recently opened a support ticket regarding this, as a workaround we keep logpull_options = "" after migrating to output_options in our TF definitions until the API gets fixed.

@diarmuidie
Copy link

We've recently opened a support ticket regarding this, as a workaround we keep logpull_options = "" after migrating to output_options in our TF definitions until the API gets fixed.

You can also ignore that field, after setting it to "", so that it doesn't show up in plan and apply output, using the lifecycle field:

  lifecycle {
    ignore_changes = [
      logpull_options,
    ]
  }

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.

5 participants