Skip to content

Return warnings from service create/update when digest pinning fails#28421

Merged
aaronlehmann merged 1 commit intomoby:masterfrom
aaronlehmann:digest-pinning-warnings
Nov 18, 2016
Merged

Return warnings from service create/update when digest pinning fails#28421
aaronlehmann merged 1 commit intomoby:masterfrom
aaronlehmann:digest-pinning-warnings

Conversation

@aaronlehmann
Copy link

Modify the service update and create APIs to return optional warning
messages as part of the response. Populate these messages with an
informative reason when digest resolution fails.

This is a small API change, but significantly improves the UX. The user
can now get immediate feedback when they've specified a nonexistent
image or unreachable registry.

cc @nishanttotla @dnephin

@vieux
Copy link
Contributor

vieux commented Nov 15, 2016

@aaronlehmann can you please update swagger and use it to generate types ? /cc @dnephin

@aaronlehmann aaronlehmann added status/failing-ci Indicates that the PR in its current state fails the test suite and removed status/0-triage labels Nov 15, 2016
@aaronlehmann
Copy link
Author

@vieux: Can you please point me to some information on how to do that? ServiceCreateResponse already exists in client.go, so adding ServiceUpdateResponse next to it seemed like the right thing to do.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the only use case for the Warning right now is a failure to pin by digest. Should we make it a general string field then, as opposed to maybe a boolean or something else?

Copy link
Author

Choose a reason for hiding this comment

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

Not in favor of a boolean because it's important to communicate the actual error message. I think a general string field is necessary. However, we could add a boolean in addition to indicate whether pinning by digest happened if people think it's a good idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think another field is necessary in addition to a string Warning field, particularly because we're not taking any specific action if the pinning by digest fails.

@thaJeztah
Copy link
Member

ping @dnephin can you help with the Swagger changes?

@dnephin
Copy link
Member

dnephin commented Nov 15, 2016

@aaronlehmann

  1. Update api/swagger.yaml. At the same time change operationId: "PostServicesUpdate" to ServiceUpdate. Also change tags: - Services to tags: [Service] I've been normalizing as I go.
  2. Add -n ServiceUpdate to hack/generate-swagger-api.sh
  3. Run make swagger-gen (or hack/generate-swagger-api.sh directly from make shell)
  4. That should produce a new file at api/types/service
  5. Change the imports to use that struct

@aaronlehmann
Copy link
Author

@dnephin: Can you confirm that it's correct to generate ServiceUpdateResponse from swagger even though ServiceCreateResponse does not seem to be generated that way?

@aaronlehmann aaronlehmann force-pushed the digest-pinning-warnings branch from acbdad9 to ccfa9bc Compare November 15, 2016 17:42
@dnephin
Copy link
Member

dnephin commented Nov 15, 2016

Yes, that's correct. We're slowly migrating everything to the swagger generation in #27919. It would be good to any any new things using the new pattern.

@aaronlehmann
Copy link
Author

@dnephin: I've made some progress but am stuck on a few things.

Currently I'm getting this output:

// ServiceUpdateOKBody service update o k body
// swagger:model ServiceUpdateOKBody
type ServiceUpdateOKBody struct {

       // Optional warning message
       // Required: true
       Warning string `json:"Warning"`
}
  • The Required: true is false, and it's added automatically. I haven't found any way to suppress this. Adding required: [] under schema does not change anything. Adding required: false under Warning causes the structure not to be generated at all.
  • How can I add the omitempty property?

@aaronlehmann aaronlehmann force-pushed the digest-pinning-warnings branch from ccfa9bc to f0d2912 Compare November 15, 2016 19:11
@aaronlehmann
Copy link
Author

I think I figured it out.

PTAL

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

@aaronlehmann
Copy link
Author

Just occurred to me - should Warning be an array called Warnings to be consistent with ContainerCreateCreatedBody?

@aaronlehmann aaronlehmann removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Nov 15, 2016
@thaJeztah
Copy link
Member

@aaronlehmann should this be considered for 1.13?

@aaronlehmann
Copy link
Author

Yes please.

@aaronlehmann aaronlehmann force-pushed the digest-pinning-warnings branch from 252994e to a77a3a4 Compare November 16, 2016 22:42
@aaronlehmann
Copy link
Author

Updated to return an array of warnings. This matches other API endpoints like /containers/create.

PTAL

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Also; should this change be versioned (and only return warnings on API >= 1.25

Copy link
Author

Choose a reason for hiding this comment

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

I always forget.

Done.

Copy link
Author

Choose a reason for hiding this comment

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

re versioning: I'm not sure what our normal policy is on this kind of change, but it seems like a lot of extra complexity to do this unless we have a good reason. I expect that older clients would just ignore this field.

Copy link
Member

Choose a reason for hiding this comment

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

Hm, you may be right here; we document that additional fields may be returned by the API, so clients should ignore them.

@aaronlehmann aaronlehmann force-pushed the digest-pinning-warnings branch from a77a3a4 to b63d861 Compare November 16, 2016 23:37
@aaronlehmann
Copy link
Author

Updatd docker_remote_api_v1.26.md as well.

PTAL

@thaJeztah
Copy link
Member

(docs LGTM)

@vdemeester
Copy link
Member

@aaronlehmann needs a rebase 😓

…nning fails

Modify the service update and create APIs to return optional warning
messages as part of the response. Populate these messages with an
informative reason when digest resolution fails.

This is a small API change, but significantly improves the UX. The user
can now get immediate feedback when they've specified a nonexistent
image or unreachable registry.

Signed-off-by: Aaron Lehmann <[email protected]>
@aaronlehmann aaronlehmann force-pushed the digest-pinning-warnings branch from 5e6adf6 to 948e606 Compare November 18, 2016 17:31
@aaronlehmann
Copy link
Author

Rebased

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM (code & docs) 🐮

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants