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

Cloudrun beta implementation on alpha KNative #1820

Merged
merged 11 commits into from
Jul 26, 2019

Conversation

chrisst
Copy link
Contributor

@chrisst chrisst commented May 23, 2019

Publishing this as a WIP PR for early feedback (see the TODO checklist for the remaining work to be done) and get code generation working. This is an implementation of the beta version of CloudRun, however they are currently running against an alpha version of the KNative apis which means that the underlying object model could change when CloudRun moves to KNative beta. See KNative release details for more information on the beta implementation.

TODO

  • # make sure location is showing up in docs
  • # add the guides / references to api.yaml
  • # Address Domain Mapping correctly
  • # get Update working
  • # Support v1beta1 object model

Requested in hashicorp/terraform-provider-google#3421

Release Note for Downstream PRs (will be copied)

`google_cloud_run_service` - Set up a cloud run service
`google_cloud_run_domain_mapping` - Allows custom domains to map to a cloud run service

@chrisst chrisst mentioned this pull request May 23, 2019
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
This PR seems not to have generated downstream PRs before, as of 62b8fba960165d2c7e854753ca943ef9967ed341.

Pull request statuses

No diff detected in terraform-google-conversion.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I built this PR into one or more new PRs on other repositories, and when those are closed, this PR will also be merged and closed.
depends: hashicorp/terraform-provider-google-beta#757
depends: hashicorp/terraform-provider-google#3703

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, c105721.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
No diff detected in terraform-provider-google.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 5483d2f.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
No diff detected in terraform-provider-google.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 1dd06b4.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I built this PR into one or more new PRs on other repositories, and when those are closed, this PR will also be merged and closed.
depends: hashicorp/terraform-provider-google#3714

@chrisst chrisst changed the title [WIP] Cloudrun beta implementation on alpha KNative [blocked] Cloudrun beta implementation on alpha KNative May 24, 2019
@chrisst chrisst force-pushed the cloudrun-canary branch from 1dd06b4 to 3fb27d3 Compare May 24, 2019 20:27
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 9281d88.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, ff245bd.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@chrisst chrisst force-pushed the cloudrun-canary branch from ff245bd to e6a9373 Compare July 2, 2019 22:54
@rambleraptor
Copy link
Contributor

Hi drive-by reviewer. Did you mean to commit "products/test"?

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, ec67b52.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 7572b07.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 8f8e728.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 673e7fd.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 8320c04.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@chrisst chrisst changed the title [blocked] Cloudrun beta implementation on alpha KNative Cloudrun beta implementation on alpha KNative Jul 22, 2019
@chrisst chrisst requested a review from danawillow July 22, 2019 21:23
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 5f618a8.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@chrisst
Copy link
Contributor Author

chrisst commented Jul 22, 2019

@danawillow These resources are working, but they don't currently have a great experience in the error scenario. For example if you create a DomainMapping with bad values it doesn't do much validation on the POST and instead returns the object where the conditions include a Ready status of "status": "Unknown". That status will then transition to either True or False with an error message.

However we can't use "status": "Unknown" as an transition state to poll against because it can be a terminal state that requires more out of band input, such as:

{
        "type": "Ready",
        "status": "Unknown",
        "reason": "CertificatePending",
        "message": "Waiting for certificate provisioning. You must configure your DNS records for certificate issuance to begin and to accept HTTP traffic.",
        "lastTransitionTime": "2019-07-22T20:05:37.029Z"
      }

I think adding custom polling behavior using the status and reason of the Ready block is a slight improvement but I think it can be added in a follow on PR.

Copy link
Contributor

@danawillow danawillow left a comment

Choose a reason for hiding this comment

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

I'm excited to see this moving forward!

products/cloudrun/api.yaml Outdated Show resolved Hide resolved
products/cloudrun/api.yaml Outdated Show resolved Hide resolved
products/cloudrun/api.yaml Outdated Show resolved Hide resolved
products/cloudrun/api.yaml Outdated Show resolved Hide resolved
description: The location of the cloud run instance. eg us-central1
url_param_only: true
required: true
properties:
Copy link
Contributor

Choose a reason for hiding this comment

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

I put a few comments in, but generally I think most of these descriptions are hard to parse, and many contain information not relevant to our users. It would be nice if they could be given a once-over to try to make them a bit more user-friendly.

Also I'm generally a fan of putting things alphabetically, just to make it easier to find stuff later. Up to you though, don't worry about it if it messes with your tooling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I get for directly generating from REST docs, which directly generate from protos, which directly generate from....
I'll take a quick pass.

third_party/terraform/utils/config.go.erb Outdated Show resolved Hide resolved
kind: !ruby/object:Overrides::Terraform::PropertyOverride
exclude: true
apiVersion: !ruby/object:Overrides::Terraform::PropertyOverride
output: true
Copy link
Contributor

Choose a reason for hiding this comment

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

why output instead of exclude?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tbh - I'm worried that this value might be different even when querying the same endpoint. I am pretty sure that you will be able to retrieve Services created at v1alpha1 via the v1beta1 endpoint when it ships. So I thought it would be valuable down the road.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since it's easier to add than to remove, would it make sense to wait until it becomes valuable to add it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sound good.

"github.com/hashicorp/terraform/helper/resource"
)

func TestAccCloudrunService_cloudrunServiceUpdate(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This failed when I tried to run it:

------- Stdout: -------
=== RUN   TestAccCloudrunService_cloudrunServiceUpdate
=== PAUSE TestAccCloudrunService_cloudrunServiceUpdate
=== CONT  TestAccCloudrunService_cloudrunServiceUpdate
--- FAIL: TestAccCloudrunService_cloudrunServiceUpdate (4.99s)
    testing.go:568: Step 2 error: errors during apply:
        
        Error: Error updating Service "tftest-cloudrun-lmgbra": googleapi: Error 409: Conflict for resource 'tftest-cloudrun-lmgbra' for version '1563901425614000'.
        
          on /opt/teamcity-agent/temp/buildTmp/tf-test772321307/main.tf line 2:
          (source code not available)
        
        
FAIL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have been able to reproduce this once, but not consistently. I suspect this is a race condition due to not handling polling until ready:true.

}
}

# The Service is ready to be used when the "Ready" condition is True
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't wait in the resource itself because of the comment that you made about Unknown sometimes being a terminal state, right? Is there any way we can give feedback on that? I feel like doing it this way just pushes the problem down to our users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Summary from in person conversation: It sounds like DomainMapping should be the exception and my understanding so far is that UNKNOWN should be a truly transitional state in most cases. We decided that Service needs this before it's really usable so I filed hashicorp/terraform-provider-google#4091 and I am opening a bug against the DomainMapping endpoint to see if we can figure out a better state resolution.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 5e0c058.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, a6f7a15.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 44751db.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

Copy link
Contributor

@danawillow danawillow left a comment

Choose a reason for hiding this comment

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

A few test/docs comments, but LGTM once those are resolved 🙌

resource "google_cloudrun_domain_mapping" "<%= ctx[:primary_resource_id] %>" {
location = "us-central1"
provider = "google-beta"
name = "<%= ctx[:vars]['cloudrun_domain_name'] %>"
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -0,0 +1,13 @@
resource "google_cloudrun_domain_mapping" "<%= ctx[:primary_resource_id] %>" {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be google_cloud_run_domain_mapping now

@@ -0,0 +1,28 @@
resource "google_cloudrun_service" "<%= ctx[:primary_resource_id] %>" {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@@ -0,0 +1,28 @@
resource "google_cloudrun_service" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['cloudrun_service_name'] %>"
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

# Due to Terraform and API limitations this is best accessed through a local variable
locals {
cloudrun_status = {
for cond in google_cloudrun_service.default.status[0].conditions :
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Resource to hold the state and status of a user's domain mapping.

**Note:** Cloud Run as a product is in beta, however the REST API is currently still an alpha.
Please use this with caution as it may change when the resource moves to beta.
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: s/resource/API (since we're in the beta provider right now, which could make things confusing)

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 34842b1.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

chrisst and others added 11 commits July 26, 2019 21:53
add cloudrun to providers block

remove all output: false to simplify the yaml

Add location property for building URLs

Setting required fields and hacking name

Removing fields that aren't core

more updates to cloudrun service

Create and Read are now working
Flattened the spec block to get down to relevant properties
hoisted name to a top level resoruce and hard coded apiVersion with encoders

WIP adding cloudrun tests

Cloud Run Service Updates

Get generated tests up and running.

Fix documentation for flattened objects

Add docs and remove fields that can't be set

Adding Service udpate test

Add baseurl plubming

Change cloudrun to beta format

Add example version

Removing test products

changing for beta version

change to beta endpoints
Also making cloudrun encoders generic
Enrich Service examples
Tracked submodules are build/terraform-beta build/terraform-mapper build/terraform build/ansible build/inspec.
@modular-magician modular-magician merged commit 83b9fd5 into GoogleCloudPlatform:master Jul 26, 2019
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 3388baa.

Pull request statuses

No diff detected in terraform-google-conversion.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I built this PR into one or more new PRs on other repositories, and when those are closed, this PR will also be merged and closed.
depends: hashicorp/terraform-provider-google-beta#984
depends: hashicorp/terraform-provider-google#4119

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.

5 participants