Skip to content

cloudscheduler: resume paused Job when paused is removed from config - #18954

Merged
roaks3 merged 1 commit into
GoogleCloudPlatform:mainfrom
philip-harvey:cloudscheduler-resume-on-unset
Sep 16, 2026
Merged

roaks3 merged 1 commit into
GoogleCloudPlatform:mainfrom
philip-harvey:cloudscheduler-resume-on-unset

Conversation

@philip-harvey

@philip-harvey philip-harvey commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Fixes hashicorp/terraform-provider-google#29280

Summary

Fixes a bug where a Cloud Scheduler Job that was paused via paused = true would remain paused after the attribute was removed from configuration, even though the field docs state jobs default to enabled when unset.

Root cause

paused uses default_from_api: true, making the schema field Optional + Computed. When the attribute is removed from config, Terraform carries the prior state value (true) forward instead of treating it as unset. No diff is produced, so d.HasChange("paused") in the post_update handler is false and the :resume RPC never fires.

Fix

New resumeJobWhenPausedUnset CustomizeDiff: when the raw config value for paused is null but the current (state) value is true, force the new value to false. This restores the documented default and produces the diff that drives the existing resume logic. Setting paused = false explicitly is unchanged.

Tests

  • Added TestAccCloudSchedulerJob_pausedRemovedResumes: sets paused = true (asserts PAUSED), then removes the attribute entirely (asserts paused = false / state = ENABLED). The pre-existing schedulerPausedExample test only flipped paused to an explicit false, so this regression was previously untested.

Verification

Generated the beta provider and ran locally:

  • go build / go vet cloudscheduler service — clean
  • Unit tests — pass
  • Confirmed resumeJobWhenPausedUnset is emitted and registered in CustomizeDiff.All(...)

Acceptance test requires GCP credentials and is left to CI.

Release Note

cloudscheduler: fixed `google_cloud_scheduler_job` staying paused when the `paused` field is removed from configuration

The `paused` field is Optional+Computed (default_from_api), so removing it
from configuration carried the prior state value (true) forward, producing
no diff. The post_update resume RPC only fires on d.HasChange("paused"), so
a previously-paused job stayed paused — contradicting the documented default
("Jobs default to being enabled when this property is not set").

Add a resumeJobWhenPausedUnset CustomizeDiff that forces the planned value to
false when the config attribute is null but state is true, generating the diff
that triggers the :resume RPC.

Add TestAccCloudSchedulerJob_pausedRemovedResumes covering the remove-attribute
path (the existing test only flipped paused to an explicit false).
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Sep 10, 2026
@google-cla

google-cla Bot commented Sep 10, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@philip-harvey philip-harvey changed the title cloudscheduler: resume paused Job when paused is removed from config cloudscheduler: resume paused Job when paused is removed from config Sep 10, 2026
@github-actions
github-actions Bot requested a review from c2thorn September 10, 2026 20:51
@github-actions

Copy link
Copy Markdown

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@c2thorn, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@philip-harvey

Copy link
Copy Markdown
Contributor Author

@c2thorn are you able to take a look at this PR. Thanks

@github-actions

Copy link
Copy Markdown

@c2thorn This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

@roaks3
roaks3 self-requested a review September 16, 2026 18:58
@modular-magician modular-magician added service/cloudscheduler and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Sep 16, 2026
@modular-magician

modular-magician commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 1c48aec:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 2 files changed, 78 insertions(+)
google-beta provider View Diff 2 files changed, 78 insertions(+)
terraform-google-conversion View Diff 1 file changed, 23 insertions(+)

Test report

Analytics

Total Tests Passed Skipped Affected
9 8 0 1
Affected Service Packages
  • cloudscheduler

Learn how VCR tests work


Step 1: Replaying Mode

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit.

Click here to see the affected tests
  • TestAccCloudSchedulerJob_pausedRemovedResumes

View the replaying VCR build log


Step 2: Recording Mode

Recording Mode Replaying Rerun Test Name
✅ Log TestAccCloudSchedulerJob_pausedRemovedResumes

🟢 All tests passed!

View the recording VCR build log or the debug logs folder for detailed results.

@philip-harvey, @roaks3, @c2thorn VCR tests complete for 1c48aec!

@roaks3 roaks3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was looking at the bug so just taking over the review here. Test basically confirms correct behavior (it's an additional test, but only takes ~15 sec to run), and implementation makes sense

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

google_cloud_scheduler_job paused field does not default to false as documented

3 participants