Merge ~vkuznets/cloud-init:cloud-init-per-dashes into cloud-init:master

Proposed by Vitaly Kuznetsov
Status: Merged
Approved by: Ryan Harper
Approved revision: 1482b56249dc14aa4b62d19c0f4d1261352c8d3b
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~vkuznets/cloud-init:cloud-init-per-dashes
Merge into: cloud-init:master
Diff against target: 26 lines (+7/-1)
1 file modified
tools/cloud-init-per (+7/-1)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Ryan Harper Needs Fixing
Review via email: mp+362024@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) :
review: Needs Information
Revision history for this message
Vitaly Kuznetsov (vkuznets) wrote :

That's exactly the reason - to not overwrite existing sem which may belong to a different bootper command.

Let's say I have "my-echo" and "my_echo" services. I currently have

/var/lib/cloud/instance/sem/bootper.my-echo.instance
/var/lib/cloud/instance/sem/bootper.my_echo.instance

files. Post-patch when "my_echo" service is being processed we will see
sem=/var/lib/cloud/instance/sem/bootper.my_echo.instance
sem_legacy=/var/lib/cloud/instance/sem/bootper.my-echo.instance

without '-n' /var/lib/cloud/instance/sem/bootper.my_echo.instance will be ruined.

I, of course, cannot be in this situation if I'm running cloud-init-per from cloud-init (because of the issue I'm trying to address with the patch). However, it's not forbidden to run cloud-init-per from somewhere else, just line a shell command and in this scanarion both 'my-echo' and 'my_echo' will actually work correctly.

Revision history for this message
Vitaly Kuznetsov (vkuznets) wrote :

Sorry, I probably screwed up and replied in a separate comment.

Revision history for this message
Ryan Harper (raharper) wrote :

Thanks; that's a good point about stand-alone execution.

review: Needs Fixing
Revision history for this message
Vitaly Kuznetsov (vkuznets) wrote :

Ryan Harper <email address hidden> writes:

> s/whith/with
>
> And let's leave a comment in here about the mv -n, to ensure
> we don't clobber sems that may have been created from calls
> outside of cloud-init.
>

Added, thanks!

--
Vitaly

Revision history for this message
Vitaly Kuznetsov (vkuznets) wrote :

Ping, please let me know if something in 'v2' still needs fixing. Thanks!

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:1482b56249dc14aa4b62d19c0f4d1261352c8d3b
https://jenkins.ubuntu.com/server/job/cloud-init-ci/563/
Executed test runs:
    FAILED: Checkout

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/563/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:1482b56249dc14aa4b62d19c0f4d1261352c8d3b
https://jenkins.ubuntu.com/server/job/cloud-init-ci/564/
Executed test runs:
    FAILED: Checkout

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/564/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

Kicking off a CI run on this.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:1482b56249dc14aa4b62d19c0f4d1261352c8d3b
https://jenkins.ubuntu.com/server/job/cloud-init-ci/565/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/565/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tools/cloud-init-per b/tools/cloud-init-per
2index 7d6754b..eae3e93 100755
3--- a/tools/cloud-init-per
4+++ b/tools/cloud-init-per
5@@ -38,7 +38,7 @@ fi
6 [ "$1" = "-h" -o "$1" = "--help" ] && { Usage ; exit 0; }
7 [ $# -ge 3 ] || { Usage 1>&2; exit 1; }
8 freq=$1
9-name=$2
10+name=${2/-/_}
11 shift 2;
12
13 [ "${name#*/}" = "${name}" ] || fail "name cannot contain a /"
14@@ -53,6 +53,12 @@ esac
15 [ -d "${sem%/*}" ] || mkdir -p "${sem%/*}" ||
16 fail "failed to make directory for ${sem}"
17
18+# Rename legacy sem files with dashes in their names. Do not overwrite existing
19+# sem files to prevent clobbering those which may have been created from calls
20+# outside of cloud-init.
21+sem_legacy="${sem/_/-}"
22+[ "$sem" != "$sem_legacy" -a -e "$sem_legacy" ] && mv -n "$sem_legacy" "$sem"
23+
24 [ "$freq" != "always" -a -e "$sem" ] && exit 0
25 "$@"
26 ret=$?

Subscribers

People subscribed via source and target branches