-
Notifications
You must be signed in to change notification settings - Fork 303
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
More composite types #742
More composite types #742
Conversation
Hi @spencerhance. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
b7ed973
to
f64ba6a
Compare
@@ -0,0 +1,105 @@ | |||
/* |
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.
What's the plan for this? Are we going to move forward with tracking the metrics here or is this a stopgap?
I filed an issue (GoogleCloudPlatform/k8s-cloud-provider#4) a while back to track these metrics in k8s-cloud-provider since it makes more sense in that context.
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 was thinking of it as a stopgap because I wasn't sure of the best way to fix the metrics long-term. In the case of that issue, wouldn't the metrics still live in ingress-gce but then just be passed along to the k8s-cloud-provider layer?
@@ -153,6 +155,9 @@ func genTypes(wr io.Writer) { | |||
// Note that the compute API's do not contain this field. It is for our | |||
// own bookkeeping purposes. | |||
Version meta.Version {{$backtick}}json:"-"{{$backtick}} | |||
// ResourceType keeps track of the intended type of the service (e.g. 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 you have an example of how this is used?
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.
Not currently, I added preemptively since I think we'll need a way of keeping track of this when integrating the composite types. Open to removing it for now though.
pkg/composite/composite.go
Outdated
Version meta.Version `json:"-"` | ||
// ResourceType keeps track of the intended type of the service (e.g. Global) | ||
// This is also an internal field purely for bookkeeping purposes | ||
ResourceType meta.KeyType `json:"-"` |
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 would add a space after ResourceType
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.
you probably mean \n
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.
Sorry yes I meant newline
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.
done
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 am doing another pass to look at the generator code
pkg/backends/backends.go
Outdated
return err | ||
} | ||
return nil | ||
} | ||
|
||
// Get implements Pool. | ||
func (b *Backends) Get(name string, version meta.Version) (*composite.BackendService, error) { | ||
be, err := composite.GetBackendService(name, version, b.cloud) | ||
be, err := composite.GetBackendService(name, version, b.cloud, meta.GlobalKey(name)) |
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 seems wrong, why does this take a name AND and a key?
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 key is just being used as a way of distinguishing if it should be global or regional.
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, so the name arg is redundnat
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.
ah I see, yeah that makes sense
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.
done
pkg/composite/composite.go
Outdated
Version meta.Version `json:"-"` | ||
// ResourceType keeps track of the intended type of the service (e.g. Global) | ||
// This is also an internal field purely for bookkeeping purposes | ||
ResourceType meta.KeyType `json:"-"` |
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.
you probably mean \n
Type string `json:"type,omitempty"` | ||
UdpHealthCheck *UDPHealthCheck `json:"udpHealthCheck,omitempty"` | ||
UnhealthyThreshold int64 `json:"unhealthyThreshold,omitempty"` | ||
googleapi.ServerResponse `json:"-"` |
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.
what is this?
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's included in the generated api code with this comment:
// ServerResponse contains the HTTP response code and headers from the
// server.
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.
now that I think about it, I can probably just parse the descriptions too so that the struct field comments are also retained.
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.
Added that in latest commit
pkg/composite/composite.go
Outdated
// ToAlpha converts our composite type into an alpha type. | ||
// This alpha type can be used in GCE API calls. | ||
func (forwardingRule *ForwardingRule) ToAlpha() (*computealpha.ForwardingRule, error) { | ||
bytes, err := json.Marshal(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.
this can be generic and I think there is already copyViaJSON util function with a signature like
func CopyViaJSON(dest, src interface{}) error
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.
hmm good point, that seems a lot cleaner
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 refactored the conversion functions to use copyViaJSON(). Is that what you were thinking?
pkg/composite/gen/main.go
Outdated
@@ -191,80 +196,240 @@ func genFuncs(wr io.Writer) { | |||
|
|||
{{range $type := $All}} | |||
{{if .IsMainService}} | |||
func Create{{.Name}}({{.VarName}} *{{.Name}}, cloud *gce.Cloud) error { | |||
|
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.
extra spaces here
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.
done
pkg/composite/gen/main.go
Outdated
|
||
|
||
{{if .IsDefaultRegionalService}} | ||
func Create{{.Name}}({{.VarName}} *{{.Name}}, cloud *gce.Cloud, key *meta.Key) error { |
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.
please make sure the whitespace makes sense
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.
Gave it another pass, should be more consistent now
415c0ef
to
59c0010
Compare
a858803
to
4585528
Compare
@bowei FYI I added the changes we discussed offline /assign bowei |
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.
/lgtm
@@ -0,0 +1,28 @@ | |||
/* | |||
Copyright 2017 The Kubernetes Authors. |
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.
2019
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.
@spencerhance Can you fix this? I'll re-lgtm after that.
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.
@rramkumar1 My bad. should be fixed now
b86c174
to
3fb325d
Compare
3fb325d
to
180df87
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rramkumar1, spencerhance 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 |
Blocked by: GoogleCloudPlatform/k8s-cloud-provider#12 GoogleCloudPlatform/k8s-cloud-provider#10
cloudprovider
togce_api