Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Fix multiline lock reason yaml corruption #978

Merged
merged 1 commit into from
Mar 7, 2018
Merged

Conversation

rndstr
Copy link
Contributor

@rndstr rndstr commented Mar 6, 2018

Lock reason messages can be spread over multiple lines. YAML's multiline
output omits indentation for empty lines. The regex looking for a
fragment to replace did not include these lines and therefore was not
removing the full multiline content but just until the first empty line.

One implication was that the flux.weave.works/locked_user annotation was
never cleared and the original locker wrongfully returned as the author of
the current lock.

This PR expands matching for existing annotations to include these empty
lines.

User locked with multiline and empty line:

metadata:
  annotations:
    flux.weave.works/locked: "true"
    flux.weave.works/locked_msg: |-
      first

      second
    flux.weave.works/locked_user: test <test@test.test>

After removing lock:

metadata:
  annotations:

      second
    flux.weave.works/locked_user: test <test@test.test>

Another person locks:

metadata:
  annotations:
    flux.weave.works/locked: "true"
    flux.weave.works/locked_msg: Do not update.
    flux.weave.works/locked_user: someone <else@test.test>

      second
    flux.weave.works/locked_user: test <test@test.test>

Lock reason messages can be spread over multiple lines. YAML's multiline
output omits indentation for empty lines. The regex looking for a
fragment to replace did not include these lines and therefore was not
removing the full multiline content but just until the first empty line.

One implication was that the `flux.weave.works/locked_user` annotation was
never cleared and the original locker wrongfully returned as the author of
the current lock.

This PR expands matching for existing annotations to include these empty
lines.

User locked with multiline and empty line:
```
metadata:
  annotations:
    flux.weave.works/locked: "true"
    flux.weave.works/locked_msg: |-
      first

      second
    flux.weave.works/locked_user: test <test@test.test>
```

After removing lock:
```
metadata:
  annotations:

      second
    flux.weave.works/locked_user: test <test@test.test>
```

Another person locks:
```
metadata:
  annotations:
    flux.weave.works/locked: "true"
    flux.weave.works/locked_msg: Do not update.
    flux.weave.works/locked_user: someone <else@test.test>

      second
    flux.weave.works/locked_user: test <test@test.test>
```
@rndstr rndstr requested review from squaremo and samb1729 March 6, 2018 04:22
@samb1729
Copy link
Contributor

samb1729 commented Mar 6, 2018

The necessity for this change may be obviated by #976.

@rndstr rndstr merged commit bd0af49 into master Mar 7, 2018
@rndstr rndstr deleted the policy-message-multiline branch March 7, 2018 21:22
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.

3 participants