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

etcdctl: fix migrate in outputing client.Node to json #6690

Merged
merged 1 commit into from
Oct 20, 2016

Conversation

hongchaodeng
Copy link
Contributor

We should use print/println instead of printf.

@hongchaodeng
Copy link
Contributor Author

cc @timothysc

@hongchaodeng
Copy link
Contributor Author

@wojtek-t FYI

@hongchaodeng
Copy link
Contributor Author

@xiang90 @gyuho

This should be backport-ed to 3.0?

Copy link
Contributor

@gyuho gyuho left a comment

Choose a reason for hiding this comment

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

lgtm

@gyuho
Copy link
Contributor

gyuho commented Oct 20, 2016

Only difference is the \n at the end of output. Did it break anything in Kubernetes?

Defer to @xiang90 on backporting.

@timothysc
Copy link

@hongchaodeng Did this fix the migrate failure?

@wojtek-t
Copy link
Contributor

@timothysc - what migration failure are you talking about? If there is a bug, this should be backported to 3.0

@timothysc
Copy link

@wojtek-t yes we found a bug in yesterday on a large migrate we were testing.

@timothysc
Copy link

timothysc commented Oct 20, 2016

verified this fixes the migration issue we came across, please backport/cherry pick to 3.0 branch.

@timothysc
Copy link

/cc @smarterclayton

@@ -220,7 +220,7 @@ func writeKeys(w io.Writer, n *store.NodeExtern) uint64 {
if err != nil {
ExitWithError(ExitError, err)
}
fmt.Fprintf(w, string(b))
fmt.Fprintln(w, string(b))
Copy link
Contributor

Choose a reason for hiding this comment

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

@hongchaodeng can you explain why do we need to change fprintf to fprintln in the commit message in detail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Copy link
Contributor

Choose a reason for hiding this comment

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

I read through https://golang.org/src/fmt/print.go. If seems the only difference is that println adds a \n. do you have an example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example for what?

Copy link
Contributor

Choose a reason for hiding this comment

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

what is the problem. how fprintf and fprintln behaviors differently in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how fprintf and fprintln behaviors differently in this case.

printf("%") => %!(MISSING)
print("%") => %

Also this should be https://golang.org/pkg/fmt/#Fprint not https://golang.org/pkg/fmt/#Fprintln

Why print? Why not println?

Copy link
Contributor

Choose a reason for hiding this comment

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

@hongchaodeng println adds a \n at the end of the line. why do we need that \n?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

println is easier for user to debug on the other end.

Copy link
Contributor

Choose a reason for hiding this comment

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

no. it is not. it adds a char, which it should not. input and output should be the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

printf("%") => %!(MISSING)
print("%") => %

can you also add this into commit message?

Using printf will try to parse the string and replace special
characters. In migrate code, we want to just output the raw
json string of client.Node.
For example,
    Printf("%\\") => %!\(MISSING)
    Print("%\\") => %\
Thus, we should use print instead.
@hongchaodeng
Copy link
Contributor Author

@xiang90 Fixed

@xiang90
Copy link
Contributor

xiang90 commented Oct 20, 2016

lgtm

@gyuho gyuho merged commit a47797f into etcd-io:master Oct 20, 2016
@wojtek-t
Copy link
Contributor

@mml - FYI

@xiang90 @hongchaodeng - when can we expect backport of this to 3.0 branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants