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

update PodSpec.Host to PodSpec.NodeName #8853

Merged
merged 1 commit into from May 28, 2015

Conversation

caesarxuchao
Copy link
Member

update PodSpec.Host to PodSpec.NodeName in /pkg/api/types.go and /pkg/api/v1/types.go

fix #6895

@bgrant0607 @krousey

@bgrant0607 bgrant0607 added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label May 27, 2015
// the the scheduler simply schedules this pod onto that host, assuming that it fits
// resource requirements.
Host string `json:"host,omitempty" description:"host requested for this pod"`
NodeName string `json:"nodeName,omitempty" description:"host requested for this pod"`
Copy link
Member

Choose a reason for hiding this comment

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

Please change the description tag, also: node requested for this pod.

@bgrant0607 bgrant0607 self-assigned this May 27, 2015
@bgrant0607
Copy link
Member

Fails gofmt

@bgrant0607
Copy link
Member

Ref #7018

@caesarxuchao
Copy link
Member Author

Updated. PTAL. Thanks.

@bgrant0607
Copy link
Member

Doesn't build. Regenerate pkg/api/deep_copy_generated.go

@caesarxuchao
Copy link
Member Author

Yeah, I have the problem when I work on #6797 today. It's strange this problem didn't occur yesterday. I will get back to this PR after fixing #6797.

@bgrant0607
Copy link
Member

@wojtek-t We're having trouble with the generated conversions. Is it obvious what we're doing wrong?

@caesarxuchao
Copy link
Member Author

Hi @wojtek-t, no big deals, I just want to know what's the best practice when one tried to update the api, e.g., update PodSpec.Host to PodSpec.Nodename.

here are the steps that I want to take, but these don't work:

  1. change a field name (e.g. Host->NodeName) in api/types.go and api/v1/types.go
  2. add functions in v1beta3/conversion.go to convert "Host" in v1beta3 to "NodeName" in internal version
  3. run hack/update-generated-conversion.sh and hack/update-generated-deep-copies.sh.
    This doesn't work because in step 3, the scripts complain that the v1beta3/conversion-generated.go and deep-copies_generated.go contain undeclared field name "Host"

So I have to manually update various -generated.go, and then these update- scripts are happy. However, at this point, I have already made all the changes manually, there is no work left for these update-* scripts. Please let me know if there is a better way. Thanks.

@@ -19,6 +19,8 @@ package controller
import (
"fmt"

"sync/atomic"
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is something wrong with the goimports. I will fix it. Thanks.

@bgrant0607
Copy link
Member

Building the generator should not build the previously generated code. That seems wrong.

@caesarxuchao
Copy link
Member Author

In cmd/genconversion/conversion.go:

     "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
     _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1"
     _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
     _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
     _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"

So to build the generator, it requires the conversion_generated.go files in these packages to be correct.

@bgrant0607
Copy link
Member

I understand that's the way it is. I was saying it shouldn't be that way. :-)

The generated code just needs to build, though, right? It doesn't need to work? If you commented out the lines it complained about, would the generator build and then regenerate the conversions?

@caesarxuchao
Copy link
Member Author

Yeah, that should work. That seems to be the best option.

@wojtek-t
Copy link
Member

@caesarxuchao - yes, unfortunately this is the easiest way to do it. Basically, what you can do is to remove the whole code from */conversions_generated.go files, and running:
hack/update-generated-conversions.sh will regenerate them.
I agree it's not convenient and shouldn't work like this but it's not trivial to fix it.

@bgrant0607
Copy link
Member

@wojtek-t
Copy link
Member

@bgrant0607 - I thought about it and I know how to fix the problem. Will fix the real issue instead of updating documentation :)

@caesarxuchao
Copy link
Member Author

"remove the whole code from */conversions_generated.go" won't work, because some functions in conversion.go depend on code in conversions_generated.go

@wojtek-t, I'm looking forward to your fix : )

if newPod.Spec.Host != oldPod.Spec.Host {
allErrs = append(allErrs, errs.NewFieldInvalid("status.host", newPod.Spec.Host, "pod host cannot be changed directly"))
if newPod.Spec.NodeName != oldPod.Spec.NodeName {
allErrs = append(allErrs, errs.NewFieldInvalid("status.nodeName", newPod.Spec.NodeName, "pod host cannot be changed directly"))
Copy link
Member

Choose a reason for hiding this comment

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

s/host/node/ in error message

@wojtek-t
Copy link
Member

@caesarxuchao unfortunately my fix doesn't work because what you wrote. Updated instructions are in #8921

@bgrant0607
Copy link
Member

Tests failing:

_output/local/go/src/github.com/GoogleCloudPlatform/kubernetes/pkg/api/deep_copy_generated.go:1377: out.Host undefined (type *PodSpec has no field or method Host)

@caesarxuchao caesarxuchao force-pushed the HostToNodeName branch 2 times, most recently from 241087d to 89cd3ab Compare May 28, 2015 17:35
@caesarxuchao
Copy link
Member Author

@bgrant0607 Updated and rebased. Let's wait for the Shippable results. Thanks.

@bgrant0607
Copy link
Member

Shippable failed already:

 github.com/GoogleCloudPlatform/kubernetes/test/soak/serve_hostnames
test/soak/serve_hostnames/serve_hostnames.go:188: unknown "github.com/GoogleCloudPlatform/kubernetes/pkg/api".PodSpec field 'Host' in struct literal

@caesarxuchao
Copy link
Member Author

There is something wrong in field.selector. I'm taking a look.

@caesarxuchao
Copy link
Member Author

@bgrant0607 Shippable is green

@bgrant0607
Copy link
Member

Please squash the commits.

@bgrant0607
Copy link
Member

LGTM once squashed.

@bgrant0607 bgrant0607 added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 28, 2015
@caesarxuchao
Copy link
Member Author

Squashed. Thanks.

thockin added a commit that referenced this pull request May 28, 2015
update PodSpec.Host to PodSpec.NodeName
@thockin thockin merged commit 081ab3a into kubernetes:master May 28, 2015
@caesarxuchao caesarxuchao deleted the HostToNodeName branch May 12, 2020 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename PodSpec.Host to PodSpec.NodeName
5 participants