Skip to content

cloudrunv2: Fixed permadiff in template.scaling.min_instance_count#14971

Closed
wyardley wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
wyardley:wyardley/issues_20399
Closed

cloudrunv2: Fixed permadiff in template.scaling.min_instance_count#14971
wyardley wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
wyardley:wyardley/issues_20399

Conversation

@wyardley

@wyardley wyardley commented Aug 23, 2025

Copy link
Copy Markdown
Contributor

Release Note Template for Downstream PRs (will be copied)
Added default_from_api to template.scaling.max_instance_count, to resolve a permadiff if min_instance_count is set to the default (0) without a value set for max_instance_count

Part of hashicorp/terraform-provider-google#20399

See linked ticket: currently, this does not resolve the diff when one of CPU or memory is defined in limits but the other is unset.

cloudrunv2: fixed permadiff in `template.scaling.min_instance_count` when `max_instance_count` is unset.

Added `default_from_api` to `template.scaling.max_instance_count`, to
resolve a permadiff if `min_instance_count` is set to the default (0)
without a value set for `max_instance_count`

Part of hashicorp/terraform-provider-google#20399
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 23, 2025
@github-actions
github-actions Bot requested a review from rileykarson August 23, 2025 02:05
@github-actions

Copy link
Copy Markdown

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

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

@rileykarson, 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.

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 1 week. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 2 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 3 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 4 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 5 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Sep 26, 2025

@rileykarson rileykarson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, this is very stale due to my missing it.

What conditions will a value get returned by Cloud Run? I think to solve this we probably need to work through the rules for that relatively exhaustively.

The issue with default_from_api is that it makes values sticky and revert to zero / revert to null can become much more difficult. This is a problem with autoscalers/autoscaling in particular when you may want to switch between setting either end of the bounds, or scale on a different dimension.

@modular-magician

Copy link
Copy Markdown
Collaborator

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

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 1 file changed, 1 insertion(+))
google-beta provider: Diff ( 1 file changed, 1 insertion(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_cloud_run_v2_service (71 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_cloud_run_v2_service" "primary" {
  template {
    scaling {
      max_instance_count = # value needed
    }
  }
}

@modular-magician

Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 85
Passed tests: 76
Skipped tests: 9
Affected tests: 0

Click here to see the affected service packages
  • cloudrunv2

🟢 All tests passed!

View the build log

@wyardley

Copy link
Copy Markdown
Contributor Author

What conditions will a value get returned by Cloud Run? I think to solve this we probably need to work through the rules for that relatively exhaustively.

My brain is a little fuzzy on all this ~ 5 weeks later, but did you read this comment in the linked issue? This hopefully explains what I think is happening.
hashicorp/terraform-provider-google#20399 (comment)

For example, see comments inline here:

resource "google_cloud_run_v2_service" "default" {
  # [...]
  template {
    scaling {
      min_instance_count = 0   // This is the default, but max_instance_count isn't also set
    }

    containers {
      image = "us-docker.pkg.dev/cloudrun/container/hello"
      resources {
        limits = {
          memory = "1Gi"  // CPU not set; presumably you'd run into the same issue if CPU were set but memory wasn't
        }
      }
    }
  }
}

From my limited testing, if all defaults are taken (i.e., template.scaling is empty), things are fine, but once you set one of them explicitly, the values returned back from the API start causing some confusion.

I was going off the docs on permadiffs, and the settings of some existing parameters, and in my limited testing, the fix here seemed to work, but agree that it may be worth doing some additional testing to confirm. Baking in the default values would probably also work, so will defer to you in terms of what's the better behavior (or if there's another way to "fix" this).

I wasn't able to come up with something easy for the containers.resources.limits settings that seemed to work.

@github-actions

github-actions Bot commented Oct 1, 2025

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Oct 3, 2025

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 1 week. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 2 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 3 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 4 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 5 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

github-actions Bot commented Nov 7, 2025

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 6 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 7 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 8 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 9 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

github-actions Bot commented Dec 5, 2025

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 10 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions

Copy link
Copy Markdown

@GoogleCloudPlatform/terraform-team @rileykarson This PR has been waiting for review for 11 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

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.

4 participants