Thanks to visit codestin.com
Credit goes to github.com

Skip to content

lint changes part 1#8423

Merged
tiborvass merged 6 commits into
moby:masterfrom
unclejack:lint_changes
Oct 21, 2014
Merged

lint changes part 1#8423
tiborvass merged 6 commits into
moby:masterfrom
unclejack:lint_changes

Conversation

@unclejack

Copy link
Copy Markdown
Contributor

This PR does some linting on the code. Each commit lints a separate part of the code. This PR is mostly focused on code changes for some packages. Instead of making all possible changes, this focuses mostly on the variable and mehtod naming.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <[email protected]> (github: unclejack)
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <[email protected]> (github: unclejack)
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <[email protected]> (github: unclejack)
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <[email protected]> (github: unclejack)
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <[email protected]> (github: unclejack)
@jessfraz

jessfraz commented Oct 7, 2014

Copy link
Copy Markdown
Contributor

LGTM

@crosbymichael

Copy link
Copy Markdown
Contributor

dont' merge before 1.3, still on lockdown

@jessfraz

jessfraz commented Oct 7, 2014

Copy link
Copy Markdown
Contributor

i know dissss :)

@tiborvass

Copy link
Copy Markdown
Contributor

LGTM

tiborvass added a commit that referenced this pull request Oct 21, 2014
@tiborvass tiborvass merged commit 9df3e45 into moby:master Oct 21, 2014
@unclejack unclejack deleted the lint_changes branch October 21, 2014 16:17
@estesp

estesp commented Oct 23, 2014

Copy link
Copy Markdown
Contributor

Sorry that I just noticed this while looking at another issue--but changing the api/server/server.go HTTP error handling string match to "no such" from "No such" (to handle truncIndex change of errors string to lowercase "n") means that quite a few uses of the API will now return 500 instead of the proper 404 that is expected (for example, I had fixed this for wait in PR #8107).

We either need to resolve all the places below (minus a few that just happen to use the "No such" wording but aren't really coming via this codepath), or change it back to "No such". As an aside I would like to help make this more robust so string matching isn't the method by which HTTP response codes are determined.

./graph/service.go: return job.Errorf("No such image: %s", name)
./graph/service.go: return job.Errorf("No such image: %s", name)
./graph/tags.go:                return false, fmt.Errorf("No such tag: %s:%s", repoName, tag)
./graph/tags.go:        return false, fmt.Errorf("No such repository: %s", repoName)
./daemon/wait.go:   return job.Errorf("%s: No such container: %s", job.Name, name)
./daemon/copy.go:   return job.Errorf("No such container: %s", name)
./daemon/start.go:      return job.Errorf("No such container: %s", name)
./daemon/stop.go:       return job.Errorf("No such container: %s\n", name)
./daemon/top.go:    return job.Errorf("No such container: %s", name)
./daemon/exec.go:   return nil, fmt.Errorf("No such exec instance '%s' found in daemon", name)
./daemon/exec.go:       return nil, fmt.Errorf("No such container: %s", name)
./daemon/changes.go:        return job.Errorf("No such container: %s", name)
./daemon/attach.go:     return job.Errorf("No such container: %s", name)
./daemon/pause.go:      return job.Errorf("No such container: %s", name)
./daemon/pause.go:      return job.Errorf("No such container: %s", name)
./daemon/kill.go:       return job.Errorf("No such container: %s", name)
./daemon/logs.go:       return job.Errorf("No such container: %s", name)
./daemon/export.go: return job.Errorf("No such container: %s", name)
./daemon/restart.go:        return job.Errorf("No such container: %s\n", name)
./daemon/resize.go: return job.Errorf("No such container: %s", name)
./daemon/commit.go:     return job.Errorf("No such container: %s", name)
./daemon/inspect.go:    return job.Errorf("No such container: %s", name)
./daemon/image_delete.go:           return fmt.Errorf("No such image: %s:%s", repoName, tag)
./daemon/image_delete.go:       return fmt.Errorf("No such image: %s", name)
./daemon/create.go:         return job.Errorf("No such image: %s (tag: %s)", config.Image, tag)
./daemon/delete.go:     return job.Errorf("No such container: %s", name)

@LK4D4

LK4D4 commented Oct 23, 2014

Copy link
Copy Markdown
Contributor

@estesp I think this was fixed by #8692

@estesp

estesp commented Oct 23, 2014

Copy link
Copy Markdown
Contributor

@LK4D4 that fixes one codepath that was relying on specific-case error text, but we should probably implement the same ignore-case style in this set of checks: https://github.com/docker/docker/blob/master/api/server/server.go#L95

Right now, all those responses from jobs with "No such" are falling through and ending up with HTTP 500 instead of 404. I'll generate a PR for this as it will help prevent these kinds of unintended consequences at least with case changes in the messages. Verified that this is the case:

  • docker binary prior to lint patch in /usr/bin:
> GET /containers/askasdj/json HTTP/1.1

< HTTP/1.1 404 Not Found
< Content-Type: text/plain; charset=utf-8
< Date: Thu, 23 Oct 2014 16:58:58 GMT
< Content-Length: 27
  • docker binary from master today in /usr/bin:
> GET /containers/askasdj/json HTTP/1.1

< HTTP/1.1 500 Internal Server Error
< Content-Type: text/plain; charset=utf-8
< Date: Thu, 23 Oct 2014 17:00:38 GMT
< Content-Length: 27

Interestingly, we have one API test checking for 404 in integration, but as luck would have it, it is the one API that has it's own handing of strings, and was unaffected by the lint change: https://github.com/docker/docker/blob/master/api/server/server.go#L1053

@estesp

estesp commented Oct 23, 2014

Copy link
Copy Markdown
Contributor

FYI #8733 is submitted to resolve this issue

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants