-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
client: Use string concatenation instead of Sprintf #33536
Conversation
Signed-off-by: Aaron Lehmann <[email protected]>
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 if green
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.
👍
@@ -42,7 +42,7 @@ func (cli *Client) CopyToContainer(ctx context.Context, container, path string, | |||
query.Set("copyUIDGID", "true") | |||
} | |||
|
|||
apiPath := fmt.Sprintf("/containers/%s/archive", container) | |||
apiPath := "/containers/" + container + "/archive" |
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.
Wondering if we should use path.Join()
for these (although they're of course URL's, so probably won't make much of a difference)
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'd be okay with that. I don't have much of a preference either way.
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 think for now this is ok, as it's closest to what the existing code does. We should do a whole scan of all URL's we generate, because there's no escaping / handling of special characters in most locations
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
@tophj-ibm flaky test on z?
|
Hm, and flaky test on Windows;
|
The logic in I guess ideally the test could be rewritten to avoid sleeps and poll the PEM file on disk instead. Then if it still fails, we'd have more confidence that something is actually wrong. There's something very similar here: moby/integration-cli/docker_api_swarm_test.go Lines 214 to 224 in 376c75d
I can give this a try if I have a chance. cc @cyli |
@thaJeztah it used to be, although I haven't seen it fail in a few months and thought it was fixed. @aaronlehmann looking at the logs https://jenkins.dockerproject.org/job/Docker-PRs-s390x/3482/ in between the first and second restarts in checkSwarmUnlockedToLocked, the failing daemon starts up (is unlocked), starts its own leader election, and times out with "session initiation timed out". This happens a few times, it complains about not having a leader and then the 2nd restart occurs. So if I'm reading everything correctly, it does look like a spurious leader election on restart, which makes it never read the logs from the leader and lock. |
@aaronlehmann @tophj-ibm Thanks for finding that! |
Don't know what's wrong with WindowsRS1; https://jenkins.dockerproject.org/job/Docker-PRs-WoW-RS1/14661/console
|
All green now 🎉 |
Despite my C background, I dislike
Sprintf
and try to avoid it when I can. I've seen too many printf format string bugs. I tolerate it when it's used for actual formatting, but for simple string concatenation, I much prefer the+
operator. It makes code easier to read and allows more compile-time checking.