Skip to content

Introduce profiles#98

Closed
ndeloof wants to merge 1 commit into
compose-spec:masterfrom
ndeloof:profiles
Closed

Introduce profiles#98
ndeloof wants to merge 1 commit into
compose-spec:masterfrom
ndeloof:profiles

Conversation

@ndeloof

@ndeloof ndeloof commented Sep 2, 2020

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:
Introduce profiles in compose schema and specification.
This is based on #97 discussion, but does not cover the override file proposal, which could be proposed in a follow-up PR.

Which issue(s) this PR fixes:
see #97

Signed-off-by: Nicolas De Loof <[email protected]>
@ndeloof
ndeloof requested review from EricHripko and rumpl and removed request for EricHripko September 2, 2020 07:42
Comment thread spec.md
Comment on lines +187 to +196
services:
foo:
image: foo
bar:
image: bar
profiles: ["test"]
zot:
image: zot
profiles: ["debug"]
depends_on: ["bar"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
services:
foo:
image: foo
bar:
image: bar
profiles: ["test"]
zot:
image: zot
profiles: ["debug"]
depends_on: ["bar"]
services:
foo:
image: foo
bar:
image: bar
profiles:
- test
zot:
depends_on:
- bar
image: zot
profiles:
- debug

Comment thread spec.md

- Compose application model parsed with no profile enabled only contains the `foo` service.
- If profile `test` is enabled, model contains both the `foo` and `bar` service.
- If profile `debug` is enabled, model contains both the `foo` and `zot` service, but not `bar`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
- If profile `debug` is enabled, model contains both the `foo` and `zot` service, but not `bar`
- If profile `debug` is enabled, model contains both `foo` and `zot` services, but not `bar`

Comment thread spec.md
implementation when none of the listed profiles match the active ones, until the target component is
explicitly targeted by a command.

References to other services (by `links`, `extends` or shared resource syntax `service:xxx`) MUST not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The term "shared resource syntax service:xxx" is not defined anywhere in the spec document.

Where can a newcomer learn what is it? It would be good if there was at least a hyperlink here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is referring to system resources shareable between services or with the host, where you can specify the resource with the service:[service name] syntax, see network_mode and ipc in the spec.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the clarification. If the document included these links to the spec that would be really helpful for other people, too. Do you think it can be added?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Now I see that this snippet was already merged in https://github.com/compose-spec/compose-spec/pull/110/files#diff-bc6661da34ecae62fbe724bb93fd69b91a7f81143f2683a81163231de7e3b545R182.

My comment should really be placed there. The gist of it stands: could a link network_mode and ipc be added in the document?

@acran

acran commented Sep 2, 2020

Copy link
Copy Markdown
Contributor

With the follow-up PR for override files in mind: should we maybe narrow down the valid profile names? These should exclude all invalid characters for filesystem paths and maybe also / and \?

Also having a profile name start with - could make parsing command lines hard:

# start profile named "--build"
compose up --profile --build

@ndeloof

ndeloof commented Sep 2, 2020

Copy link
Copy Markdown
Collaborator Author

About restriction on profile name, I suggest we re-use work done on #60 and define [a-zA-Z0-9][a-zA-Z0-9_.-]+ as a global pattern for "names".

@EricHripko EricHripko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks like a great start and a lovely potential addition to the spec 🙌 I got one chunky point of discussion inline and a few minor suggestions 💬

Comment thread spec.md
References to other services (by `links`, `extends` or shared resource syntax `service:xxx`) MUST not
automatically enable a component that would otherwise have been ignored by active profiles.

#### illustration sample

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#### illustration sample
#### Illustration sample

Since other headings uppercase first letter

Comment thread spec.md

### profiles

`profiles` defines a list of named profile for volume to be enabled. When not set, volume is always enabled.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
`profiles` defines a list of named profile for volume to be enabled. When not set, volume is always enabled.
`profiles` defines a list of named profiles for volume to be enabled under. When not set, volume is always enabled.

Comment thread spec.md

### profiles

`profiles` defines a list of named profile for network to be enabled. When not set, network is always enabled

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
`profiles` defines a list of named profile for network to be enabled. When not set, network is always enabled
`profiles` defines a list of named profiles for network to be enabled under. When not set, network is always enabled

Comment thread spec.md

### profiles

`profiles` defines a list of named profile for service to be enabled. When not set, service is always enabled.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
`profiles` defines a list of named profile for service to be enabled. When not set, service is always enabled.
`profiles` defines a list of named profiles for service to be enabled under. When not set, service is always enabled.

Comment thread spec.md
All top-level elements support a `profiles` attribute to define a list of named profiles. Elements without
a `profiles` attribute set MUST always be enabled. The enclosing component MUST be ignored by compose
implementation when none of the listed profiles match the active ones, until the target component is
explicitly targeted by a command.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It feels a bit strange that users can get (what is essentially) a one-off profile with always-on services + just the target service. This might get rather confusing since we're ignoring profiles attribute on the target service, but enforcing it everywhere else.

Is it worth to fomalise this a bit more by saying that compose run/up TARGET will activate the profiles of the target service? I appreciate that this probably makes the lives of Compose implementors harder (especially considering the follow-up profile-specific files proposal), but this functionality in isolation seems more confusing than beneficial.

@EricHripko

Copy link
Copy Markdown
Collaborator

@ndeloof - have you had a chance to break this out into a smaller initial profile proposal?

@ndeloof

ndeloof commented Oct 20, 2020

Copy link
Copy Markdown
Collaborator Author

@EricHripko I have been pretty busy, feel free to take ownership on this topic if you can

@acran

acran commented Oct 20, 2020

Copy link
Copy Markdown
Contributor

@ndeloof I'd gladly support here, what can I do to advance this PR?

AFAIK the next step was to reduce the scope of this PR to a minimum and add further use cases with additional PRs? But for me this PR already is quite limited in scope, so what should be cut for the first step? I would only think of limiting the profiles key word to the service model.

If that would be okay, I could create a new PR with this and incorporate the pending feedback from here (since I can not take over this PR??).

@ndeloof

ndeloof commented Oct 20, 2020

Copy link
Copy Markdown
Collaborator Author

@acran yes indeed, we agreed on reducing scope to profile attribute introduction with minimal "magic" so we cover some basic use-cases and can have further debates on the more advanced ones.
Feel free to create another PR and cherry-pick any relevant parts from this one

@acran

acran commented Oct 21, 2020

Copy link
Copy Markdown
Contributor

I created a new PR with hopefully all the feedback incorporated in #110. Please have a look (=

@EricHripko

Copy link
Copy Markdown
Collaborator

This is awesome - thanks for picking it up @acran 🙂

@ndeloof

ndeloof commented Jan 28, 2021

Copy link
Copy Markdown
Collaborator Author

closing as obsolete

@ndeloof ndeloof closed this Jan 28, 2021
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.

5 participants