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

Pretty service inspect fails when TaskTemplate.Resources is nil #2661

Merged
merged 1 commit into from
Jul 30, 2020

Conversation

akerouanton
Copy link
Member

@akerouanton akerouanton commented Jul 28, 2020

- What I did

When doing docker service inspect --pretty on services without
TaskTemplate.Resources or TaskTemplate.Resources.Limits, the command
fails. This is due to a missing check on ResourceLimitPids().

This bug has been introduced by 395a6d5
and produces following error message:

Template parsing error: template: :139:10: executing "" at <.ResourceLimitPids>: error calling ResourceLimitPids: runtime error: invalid memory address or nil pointer dereference

- How I did it

- How to verify it

$ make binary # Build the binary from master branch
$ cat docker-compose.yaml
version: "3"

services:
  test:
    image: debian
    command: sleep 15
    deploy:
      mode: replicated
$ docker stack deploy --compose-file docker-compose.yaml test
$ build/docker service inspect --pretty test_test

- Description for the changelog

docker service inspect --pretty fails on tasks declared with no resources constraints.

- A picture of a cute animal (not mandatory but encouraged)

When doing `docker service inspect --pretty` on services without
`TaskTemplate.Resources` or `TaskTemplate.Resources.Limits`, the command
fails. This is due to a missing check on ResourceLimitPids().

This bug has been introduced by 395a6d5
and produces following error message:

```
Template parsing error: template: :139:10: executing "" at <.ResourceLimitPids>: error calling ResourceLimitPids: runtime error: invalid memory address or nil pointer dereference
```

Signed-off-by: Albin Kerouanton <[email protected]>
Copy link
Collaborator

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-commenter
Copy link

Codecov Report

Merging #2661 into master will decrease coverage by 0.00%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #2661      +/-   ##
==========================================
- Coverage   58.14%   58.13%   -0.01%     
==========================================
  Files         295      295              
  Lines       21198    21200       +2     
==========================================
  Hits        12325    12325              
- Misses       7966     7967       +1     
- Partials      907      908       +1     

@thaJeztah
Copy link
Member

This bug has been introduced by 395a6d5

Whoops! Thanks for fixing 😅

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah thaJeztah merged commit 5f979ee into docker:master Jul 30, 2020
@thaJeztah thaJeztah added this to the 20.03.0 milestone Jul 30, 2020
@akerouanton akerouanton deleted the fix-service-formatter branch October 27, 2021 20:33
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.

4 participants