Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

pod: now reject duplicate volume names in manifest #687

Merged
merged 2 commits into from
May 17, 2017

Conversation

lucab
Copy link
Contributor

@lucab lucab commented Apr 28, 2017

Noteworthy: validation check now rejects manifest with duplicate volume names.

This PR adds a validation check on the volumes array to ensure that it doesn't contain any duplicate-named volumes (and corresponding tests). Also, it clarifies string-typing of annotations.

The array "volumes" is indexed via the "name" field on each volume
object. This ensures that names are unique to avoid ambiguity in
mount-volume matching, by rejecting pod manifests containing
duplicate-named volumes.
@@ -256,7 +256,7 @@ JSON Schema for the Image Manifest (app image manifest, ACI manifest), conformin
* **authors** contact details of the people or organization responsible for the image (freeform string)
* **homepage** URL to find more information on the image (string, must be a URL with scheme HTTP or HTTPS)
* **documentation** URL to get documentation on the image (string, must be a URL with scheme HTTP or HTTPS)
* **appc.io/executor/supports-systemd-notify** (boolean, optional, defaults to "false" if unset) if set to true, the application SHOULD use the sd\_notify mechanism to signal when it is ready. Also it SHOULD be able to detect if the executor had not set up the sd\_notify mechanism and skip the notification without error ([sd_notify()](https://www.freedesktop.org/software/systemd/man/sd_notify.html) from libsystemd does that automatically).
* **appc.io/executor/supports-systemd-notify** (string boolean, optional, defaults to "false" if unset) if set to "true", the application SHOULD use the sd\_notify mechanism to signal when it is ready. Also it SHOULD be able to detect if the executor had not set up the sd\_notify mechanism and skip the notification without error ([sd_notify()](https://www.freedesktop.org/software/systemd/man/sd_notify.html) from libsystemd does that automatically).
Copy link
Member

Choose a reason for hiding this comment

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

Wait, why is this a string, if it can only be "true" or "false"?

Was it before this PR, and this is just a docs update? I don't see the change to the types here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As @jonboulle said, this just fixes a wrong example/wording conflicting with the previous definition of annotations a couple of lines above: value is an arbitrary string.

@jonboulle
Copy link
Contributor

jonboulle commented Apr 30, 2017 via email

Copy link
Contributor

@euank euank left a comment

Choose a reason for hiding this comment

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

This is backwards incompatible, but it's also right.

LGTM, but let's make sure this gets called out in a release note at least.

@@ -83,6 +83,15 @@ func (pm *PodManifest) assertValid() error {
if pm.ACKind != PodManifestKind {
return pmKindError
}

// ensure volumes names are unique (unique key)
volNames := make(map[types.ACName]bool, len(pm.Volumes))
Copy link
Contributor

Choose a reason for hiding this comment

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

dumb nit, we can save a couple bits if we use struct{} in place of bool. I'm fine with it either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought this was golang-idiomatic to make the if-has-key check more compact. The same pattern is used in other places in appc/spec, so I'd leave it as is.

@lucab lucab changed the title pod: improve volumes and annotations type story pod: now reject duplicate volume names in manifest May 2, 2017
@lucab
Copy link
Contributor Author

lucab commented May 2, 2017

@euank thanks for feedback, I've updated title and PR comment to highlight that this is now rejecting out-of-spec manifests that were previously accepted. This way the information should also propagate into release notes.

@euank
Copy link
Contributor

euank commented May 2, 2017

rkt's release notes are what really need this imo. Still 👍 from me

@jonboulle jonboulle merged commit 846ceef into appc:master May 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants