-
Notifications
You must be signed in to change notification settings - Fork 237
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
feat: Direct controller for ComputeForwardingRule #2364
feat: Direct controller for ComputeForwardingRule #2364
Conversation
64c01cf
to
8be07af
Compare
}, | ||
"loadBalancingScheme": "EXTERNAL", | ||
"name": "computeregionalforwardingrule-${uniqueId}", | ||
"region": "projects/${projectId}/global/regions/us-central1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This region looks problematic. I will investigate where the value comes from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not be an issue because it's in the URL
...ngrule/globalcomputeforwardingrule/_generated_object_globalcomputeforwardingrule.golden.yaml
Show resolved
Hide resolved
...le/regionalcomputeforwardingrule/_generated_object_regionalcomputeforwardingrule.golden.yaml
Show resolved
Hide resolved
...le/regionalcomputeforwardingrule/_generated_object_regionalcomputeforwardingrule.golden.yaml
Show resolved
Hide resolved
...e/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrule/_http.log
Show resolved
Hide resolved
...e/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrule/_http.log
Outdated
Show resolved
Hide resolved
...e/testdata/basic/compute/v1beta1/computeforwardingrule/globalcomputeforwardingrule/_http.log
Outdated
Show resolved
Hide resolved
...le/regionalcomputeforwardingrule/_generated_object_regionalcomputeforwardingrule.golden.yaml
Show resolved
Hide resolved
...le/regionalcomputeforwardingrule/_generated_object_regionalcomputeforwardingrule.golden.yaml
Show resolved
Hide resolved
8be07af
to
9fdbedc
Compare
9fdbedc
to
eea1f1c
Compare
9925f9e
to
6ee76cb
Compare
} | ||
log.V(2).Info("successfully created ComputeForwardingRule", "name", a.fullyQualifiedName()) | ||
// Get the created resource | ||
created := &computepb.ForwardingRule{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Insert
returns a computepb.Operation
, which op.Status
could be either OpDone or OpPending Code. I think we shall probably only proceed the following GCP Get
when we get a OpDone.
For OpPending, we probably want to return quietly and update the KCC .status
in the next Reconcile, maybe Find/Update
? @justinsb I'll vote for Update, do you have a preference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't worry about this because we call op.Wait()
(source code) a few lines above, and it makes sure that the operation is Done.
c51505c
to
8c304c6
Compare
8c304c6
to
6c82d9c
Compare
924dd21
to
4588327
Compare
4588327
to
20b8fe4
Compare
func (m *optionsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { | ||
if m.config.UserAgent != "" { | ||
req.Header.Set("User-Agent", m.config.UserAgent) | ||
req.Header.Del("x-goog-request-params") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know what this header is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm I'm actually unsure why this added... and seems it's not deleted by Del
. I also noticed that other direct resources(monitoringdashboard, cloudbuildworkerpool) have this header as well, I would guess it comes from the underlying GCP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
return nil, err | ||
|
||
} | ||
obj.Spec.NetworkRef.External = networkRef.External |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you may want to clear the other fields in the NetworkRef. But not a big deal, and we may be able to move all reference-resolution into a shared function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean cleaning up other fields like Name
in obj.Spec.NetworkRef
? I won't worry about other fields because we get value from External only, see the mapping function: code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it might be clearer/safer if you did clear all those other fields, it's a nit because I agree it shouldn't change functionality.
return nil, err | ||
} | ||
|
||
if id.project != projectID { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this equivalent to BuildID(...) != asID(externalRef)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but this way, we have a better idea (via separate error messages) of which specific field has been changed.
} | ||
log.V(2).Info("successfully updated ComputeForwardingRule labels", "name", a.fullyQualifiedName()) | ||
// Get the updated resource | ||
if a.id.location == "global" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to get it here, we also get it a few lines down....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call Get
twice, once after updating labels and once after updating targets, to match the realGCP http log.
@@ -37,7 +22,6 @@ spec: | |||
networkRef: | |||
name: default | |||
portRange: "80" | |||
resourceID: computeglobalforwardingrule-${uniqueId} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... maybe we don't then :-) I was worried about compatibility, but as it's not server-generated I don't think it will trip anyone up!
}, | ||
"loadBalancingScheme": "EXTERNAL", | ||
"name": "computeregionalforwardingrule-${uniqueId}", | ||
"region": "projects/${projectId}/global/regions/us-central1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not be an issue because it's in the URL
|
||
{ | ||
"labelFingerprint": "abcdef0123A=", | ||
"labels": { | ||
"cnrm-test": "true", | ||
"label-one": "value-one", | ||
"label-one": "value-two", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the "always calls setLabels" behaviour you were talking about with the old controller?
@@ -776,10 +715,12 @@ X-Xss-Protection: 0 | |||
|
|||
--- | |||
|
|||
GET https://compute.googleapis.com/compute/v1/projects/${projectId}/global/operations/${operationID}?alt=json&prettyPrint=false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought this looked like we weren't checking the LRO on delete, but ... we are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the log.
I think that's because I made a mistake in mockgcp/mockcompute/regionalforwardingrulev1.go: Should use return s.startRegionalLRO not return s.startGlobalLRO. I updated the mock as well.
Looks good, a few questions but nothing blocking I don't think! Will LGTM but add hold, feel free to address questions here or in a separate PR as you see fit. /approve |
a6f7a2e
to
bf6bc4e
Compare
return nil, err | ||
|
||
} | ||
obj.Spec.NetworkRef.External = networkRef.External |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it might be clearer/safer if you did clear all those other fields, it's a nit because I agree it shouldn't change functionality.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justinsb The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
240941d
into
GoogleCloudPlatform:master
Change description
Tests you have done
make ready-pr
to ensure this PR is ready for review.