Merge lp:~nijaba/charm-tools/peer-replay into lp:~charmers/charm-tools/trunk
| Status: | Merged |
|---|---|
| Approved by: | Clint Byrum on 2012-01-11 |
| Approved revision: | 130 |
| Merged at revision: | 114 |
| Proposed branch: | lp:~nijaba/charm-tools/peer-replay |
| Merge into: | lp:~charmers/charm-tools/trunk |
| Diff against target: |
794 lines (+539/-97) 2 files modified
helpers/sh/peer.sh (+377/-84) tests/helpers/test_peer.sh (+162/-13) |
| To merge this branch: | bzr merge lp:~nijaba/charm-tools/peer-replay |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Clint Byrum (community) | Approve on 2012-01-11 | ||
| Nick Barcet (community) | Resubmit on 2012-01-06 | ||
|
Review via email:
|
|||
Commit Message
Adds 3 new features:
* the possibility to do a ch_peer_[rsync|scp] outside of a peer relation (typically in a config-changed event) once at least one copy has been done within the peer relation. The copy will be done from the leader to all hosts to which it has done copies to previously
* the possibility to do a ch_peer_copy_replay which will redo all copies (scp or rsync) done previously to all hosts (typically in a config-changed event)
* ch_peer_
Description of the Change
A big commit which adds:
* the possibility to do a ch_peer_[rsync|scp] outside of a peer relation (typically in a config-changed event) once at least one copy has been done within the peer relation. The copy will be done from the leader to all hosts to which it has done copies to previously
* the possibility to do a ch_peer_copy_replay which will redo all copies (scp or rsync) done previously to all hosts (typically in a config-changed event)
* ch_peer_
This branch assumes that lp:~nijaba/charm-tools/buildd-fixes has been merged already.
- 112. By Nick Barcet on 2011-12-23
-
merging with buildd-
fixes-part- deux - 113. By Nick Barcet on 2011-12-23
-
fixes after API change
- 114. By Nick Barcet on 2012-01-04
-
ensure proper return results
- 115. By Nick Barcet on 2012-01-04
-
rebasing from trunk
- 116. By Nick Barcet on 2012-01-04
-
juju sets home to /home/ubuntu while user is root :(
- 117. By Nick Barcet on 2012-01-04
-
better test of ch_peer_copy_new
- 118. By Nick Barcet on 2012-01-04
-
need to replace all instances of our host place holder...
- 119. By Nick Barcet on 2012-01-05
-
deal with shell expansion better, home dir and multiple files
- 120. By Nick Barcet on 2012-01-05
-
unbound variable testing and wrongly place local fix
- 121. By Nick Barcet on 2012-01-05
-
did not know -z was not protecting with set -u
- 122. By Nick Barcet on 2012-01-05
-
resync with trunk
| Nick Barcet (nijaba) wrote : | # |
Ok, this branch is now working great.
| Clint Byrum (clint-fewbar) wrote : | # |
Hi Nick! Some blockers first:
[0]
+set -eu
Don't mess with this in helpers. There's never a reason to turn it off inside your helpers either. The script author needs to make this distinction knowingly, otherwise their script may not be able to handle the extra rigor. That said, all tests should set -eu.
[1]
Changing PermitRootLogin seems like overstepping our bounds in a charm helper. Perhaps raise an error if its attempted, and a separate ch_sshd_config_set PermitRootLogin yes call would be better. I'm worried that users will be upset that we so willingly gave all boxes root on all other boxes. Another way to go is to just not allow this to be done at all, and always require the use of a non-root user for transfers... which is what I would prefer actually.
[2]
97 + set +f
198 + eval "$copy_command $scp_options $p1 $path"
199 + set -f
What if it was already +f? Now you just turned globbing back on.
Also why are you doing eval?
$copy_command $scp_options $p1 $path
should work fine. Also its not clear *why* you don't want globbing, so a comment would be useful here.
[3]
546 +ch_peer_rsync -p $CH_portnum -o "-azq" "$CH_TEMPDIR/
547 +chres=$?
If ch_peer_rsync returns 0, this will move on and fail because of the set -u, because the || is still open so we are saying "run ch_peer_rsync, OR chres=$?".
I would think the safest way to achieve what I think is the desired logic would be
if ch_peer_rsync ... ; then
chres=0
else
chres=$?
fi
Those are the blockers. The rest are nit picks, but should be fixed:
[4]
+ juju-log "_ch_peer_
Guessing you forgot -l DEBUG
[5]
+ if [ ! x`echo "$HOME" | grep "$USER"` = x"$HOME" ] ; then
use x$VAR or "$VAR" .. not both. The x is used when you don't want to use quotes for some reason.
[6]
+ if [ -z "$list" ] || [ x"$list" = x"" ] ; then
These conditions are redundant..
[7]
+ if [ ! -n "$copies" ] ; then
! -n is better expressed as -z
[8]
ch_peer_
| Nick Barcet (nijaba) wrote : | # |
> [0]
>
> +set -eu
>
> Don't mess with this in helpers. There's never a reason to turn it off inside
> your helpers either. The script author needs to make this distinction
> knowingly, otherwise their script may not be able to handle the extra rigor.
> That said, all tests should set -eu.
fixed, thanks
> [1]
>
> Changing PermitRootLogin seems like overstepping our bounds in a charm helper.
> Perhaps raise an error if its attempted, and a separate ch_sshd_config_set
> PermitRootLogin yes call would be better. I'm worried that users will be upset
> that we so willingly gave all boxes root on all other boxes. Another way to go
> is to just not allow this to be done at all, and always require the use of a
> non-root user for transfers... which is what I would prefer actually.
ok, added ch_sshd_
Small question: how would you use another user in a hook? use 'sudo ubuntu' in front of the command?
> [2]
>
> 97 + set +f
> 198 + eval "$copy_command $scp_options $p1 $path"
> 199 + set -f
>
> What if it was already +f? Now you just turned globbing back on.
You are absolutely right ! I now store the state and restore it at the end.
> Also why are you doing eval?
>
> $copy_command $scp_options $p1 $path
>
> should work fine.
Agree that it should but it is giving me a" Missing trailing-' in remote-shell command." when running the ch_peer_rsync test. This has something to do with the quote interpretation which I could only solve by using eval. suggestion welcome.
> Also its not clear *why* you don't want globbing, so a
> comment would be useful here.
I need to turn off globbing so that the $paths variable is not expanded when on the paths ends with a * for example, as my loop expect pairs of paths and this would be messed up otherwise. I added a comment to explain this.
> [3]
>
> 546 +ch_peer_rsync -p $CH_portnum -o "-azq" "$CH_TEMPDIR/
> "$CH_TEMPDIR/
> 547 +chres=$?
>
> If ch_peer_rsync returns 0, this will move on and fail because of the set -u,
> because the || is still open so we are saying "run ch_peer_rsync, OR
> chres=$?".
>
> I would think the safest way to achieve what I think is the desired logic
> would be
>
> if ch_peer_rsync ... ; then
> chres=0
> else
> chres=$?
> fi
fixed, thanks
> Those are the blockers. The rest are nit picks, but should be fixed:
>
> [4]
>
> + juju-log "_ch_peer_
>
> Guessing you forgot -l DEBUG
This is a nice way to say I did not even know it existed....
> [5]
>
> + if [ ! x`echo "$HOME" | grep "$USER"` = x"$HOME" ] ; then
>
> use x$VAR or "$VAR" .. not both. The x is used when you don't want to use
> quotes for some reason.
Not according to http://
> [6]
>
>
> + if [ -z "$list" ] || [ x"$list" = x"" ] ; then
>
> These conditions are redundant..
fixed, thanks. bad understanding of -z on my side, ttytt.
> [7]
>
> + if [...
- 123. By <email address hidden> on 2012-01-06
-
address comments from https:/
/code.launchpad .net/~nijaba/ charm-tools/ peer-replay/ +merge/ 86721/comments/ 189159 - 124. By Nick Barcet on 2012-01-06
-
adapt mock_juju_log to print all params received
- 125. By Nick Barcet on 2012-01-06
-
some logic and typo fixes
- 126. By Nick Barcet on 2012-01-06
-
I thought I add removed this set -eu earlier...
- 127. By Nick Barcet on 2012-01-09
-
uneeded debug
- 128. By Nick Barcet on 2012-01-09
-
we have to assume that it's a file, even if it does not (yet) exist for future replay
- 129. By <email address hidden> on 2012-01-09
-
should not assume relation-list is sorted
- 130. By Nick Barcet on 2012-01-09
-
better logic and tests for peer leader functions
| Clint Byrum (clint-fewbar) wrote : | # |
Looks good Nick, please merge with a single commit message. :) Just so I'm clear what I mean:
bzr branch lp:charm-tools
cd charm-tools
bzr merge lp:~nijaba/charm-tools/peer-replay
bzr commit -m 'Adding peer-replay capability'
bzr push lp:charm-tools


Now using the new API and changes from buildd- fixes-part- deux