Add one-of matching for stop-during-backup labels - #842
Conversation
m90
left a comment
There was a problem hiding this comment.
Thank you very much for working on this. Two rather theoretical questions from my end:
- Would you think we should make the separator that is used for delimiting label values configurable too?
- Is it possible to escape a comma (or any other separator if configurable) in a
one-oflabel? I.e. can I have a label value be split intofooandbar,baz?
| # so a single container labeled `stop-during-backup=service1,service2` can be | ||
| # stopped by multiple instances of this image, each configured with a different | ||
| # value. | ||
| # LABEL_MATCH_BEHAVIOR="match" |
There was a problem hiding this comment.
I know it's a bit nonsensical by now, but all other label related settings are prefixed BACKUP, i.e. I would expect this to be BACKUP_LABEL_MATCH_BEHAVIOR. What do you think?
faff6ef to
cc90704
Compare
|
Renamed it to On the two questions:
|
|
My reasoning here is that I don't have any control over the consumers of the image, which means that if any of these additional options require a change in behavior, I can't add them anymore. This is a fundamental difference to an application project, where your argument makes perfect sense as you'd be the only consumer and can break things more easily. Hence, adding them might still make sense here, just so there is a set of behaviors and an interface that likely won't change anytime soon. I'd think making the separator configurable should be rather simple, I don't know about escaping though? |
|
Good questions.
On naming: agreed, |
|
Ok, then let's make the separator configurable, shall we? Like this, you could also work around the need for escaping I guess, so we should be all good. |
Closes #621
Right now a container's
docker-volume-backup.stop-during-backuplabel value has to match the configuredBACKUP_STOP_DURING_BACKUP_LABELvalue exactly. Since a Docker label can only hold one value per key, a single container cannot be picked up by two backup instances that use different values.This adds the
LABEL_MATCH_BEHAVIORoption you sketched out as the second variant in the issue. It defaults tomatch, which keeps the current exact behavior. When set toone-ofthe container's label value is split on commas, so labeling a containerstop-during-backup=service1,service2lets an instance configured with eitherservice1orservice2stop it.Matching already happens client side (we list all containers and filter in Go), so the Docker label filtering restrictions don't come into play here. It applies to both the
stop-during-backupandstop-during-backup-no-restartlabels. Added a unit test for the matcher and documented the option in the reference and the how-to.