Changeset 545


Ignore:
Timestamp:
12/15/2011 17:11:55 (5 months ago)
Author:
ccowart
Message:

WIP: Fixing race condition. And committing to the right place (trunk).

Overall design change:

  • Commit modules in _reverse_ order
  • Keep a list of "committed" files and don't re-commit if we encounter the same filesystem path in a later module

I need some help reviewing this change, especially as it relates to the
install operation; I'm not convinced the implementation is complete yet.

See #120.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/confaudit.in

    r508 r545  
    109109tmproot=$(conf_tmp_dir) 
    110110live_root="${LIVE_ROOT}" 
     111statefile=$(conf_tmp_file) 
    111112 
    112113# Override LIVE_ROOT to commit into our temporary directory. 
     
    116117for layer in $(conf_get_recipe) ; do 
    117118    echo "Rolling on $layer..." 
    118     conf_rollout $layer || conf_cleanExit 
     119    conf_rollout $layer $statefile || conf_cleanExit 
    119120done 
    120121for file in $SINGULARITIES ; do 
  • trunk/confman.in

    r541 r545  
    248248 
    249249function commit_full { 
    250     local msg status modules module symlink abswork files 
     250    local msg status modules module symlink abswork files statefile 
    251251    local nocommit=true 
    252252    local opt OPTIND OPTARG 
     
    271271    abswork=$(conf_abswork) 
    272272     
    273     for module in $(conf_get_recipe); do 
     273    for module in $(conf_get_reverse_recipe); do 
    274274        modules=${modules:+${modules} }${module} 
    275275        for symlink in $(find ${WORK_PATH}/${module} \ 
     
    294294    echo "Commit operation started" >&2 
    295295    $nocommit || conf_commit_file $msg $files || return $? 
    296  
    297296    update 
    298297 
    299     for layer in $(conf_get_recipe) ; do 
     298    statefile=$(conf_tmp_file) 
     299    for layer in $(conf_get_reverse_recipe) ; do 
    300300        echo "Rolling on $layer..." 
    301         conf_rollout $layer || return $? 
     301        conf_rollout $layer $statefile || return $? 
    302302    done 
    303303    for file in $SINGULARITIES ; do 
     
    328328    local opt OPTIND OPTARG 
    329329    local module 
     330    local statefile 
    330331 
    331332    while getopts ":m:F:" opt ; do 
     
    362363    update 
    363364     
    364     for layer in $(conf_get_recipe) ; do 
     365    for layer in $(conf_get_reverse_recipe) ; do 
    365366        for file in "$@"; do 
    366367            module=$(conf_wfile_module $file) 
    367368            if conf_wfile_is_singularity $file; then 
    368                 conf_install $layer "${file%-$module}-${layer}" 
     369                conf_install $layer $statefile "${file%-$module}-${layer}" 
    369370            else 
    370                 conf_install $layer "$file" 
     371                conf_install $layer $statefile "$file" 
    371372            fi 
    372373        done 
     
    831832    local checkpoint=$2 
    832833    local clock=$3 
    833     local wcopy_lock system_lock 
     834    local wcopy_lock system_lock statefile 
    834835 
    835836    if [ -z "$2" ] ; then 
     
    841842        echo "Rolling $module back to $checkpoint $clock" >&2 
    842843        conf_rollback $module $checkpoint $clock || conf_cleanExit 
    843         for layer in $(conf_get_recipe) ; do 
     844        statefile=$(conf_tmp_file) 
     845        for layer in $(conf_get_reverse_recipe) ; do 
    844846            echo "Rolling on $layer..." 
    845             conf_rollout $layer || conf_cleanExit 
     847            conf_rollout $layer $statefile || conf_cleanExit 
    846848        done 
    847849 
     
    995997        local tmproot=$(conf_tmp_dir) 
    996998        local live_root="${LIVE_ROOT}" 
     999        local statefile 
    9971000 
    9981001        # Override LIVE_ROOT to commit into our tmporary directory. 
     
    10021005 
    10031006        echo "Audit operation started" >&2 
    1004         for layer in $(conf_get_recipe) ; do 
     1007        for layer in $(conf_get_reverse_recipe) ; do 
    10051008            echo "Rolling on $layer..." 
    1006             conf_rollout $layer || return $? 
     1009            conf_rollout $layer $statefile || return $? 
    10071010        done >/dev/null 
    10081011        for file in $SINGULARITIES ; do 
  • trunk/confmanlib.sh.in

    r542 r545  
    523523} 
    524524 
     525# Test to see if the pathname has been added to a statefile yet 
     526function conf_beenthere { 
     527    local statefile="$1" 
     528    local pathname="$2" 
     529    fgrep -q "$pathname" "$statefile" 
     530} 
     531 
     532# Record this file in the given statefile 
     533function conf_gothere { 
     534    local statefile="$1" 
     535    local pathname="$2" 
     536    echo "$pathname" >> $statefile 
     537} 
     538 
    525539# Roll out the specified module, optionally at the specified checkpoint 
    526 # eg:   conf_rollout MODULE [checkpoint] 
     540# A statefile is a place to record the files that have been rolled out to 
     541# prevent a lower-priority module from installing a committed file. 
     542# eg:   conf_rollout MODULE STATEFILE [checkpoint] 
    527543function conf_rollout { 
    528544        local module="$1" 
    529         if [ -z $2 ] ; then 
     545    local statefile="$2" 
     546        if [ -z $3 ] ; then 
    530547                local moduledir="${WORK_PATH}/$module" 
    531548        else  
     
    545562                local livedir=`echo $directory | ${sed_cmd} -e "s:$moduledir::"` 
    546563                livedir="${LIVE_ROOT}${livedir}" 
    547                 local owner=`conf_get_prop ${directory} owner` 
    548                 local group=`conf_get_prop ${directory} group` 
    549                 local mode=`conf_get_prop ${directory} mode` 
    550                 local opts="-d -o $owner -g $group -m $mode" 
    551                 local cmd="$SUDO $install_cmd $opts $livedir" 
    552                 echo $cmd 
    553                 $cmd 
    554         done 
     564        if ! conf_beenthere $statefile "$livedir" ; then 
     565                    local owner=`conf_get_prop ${directory} owner` 
     566                    local group=`conf_get_prop ${directory} group` 
     567                    local mode=`conf_get_prop ${directory} mode` 
     568                    local opts="-d -o $owner -g $group -m $mode" 
     569                    local cmd="$SUDO $install_cmd $opts $livedir" 
     570                    echo $cmd 
     571            conf_gothere $statefile "$livedir" 
     572                    $cmd 
     573        fi 
     574        done     
    555575        for file in `find -L $moduledir -type f | grep -v "\.svn"` ; do 
    556576                local livefile=`echo "$file" | ${sed_cmd} -e "s:$moduledir::"` 
     
    559579                local mode=`conf_get_prop ${file} mode` 
    560580        local symlink="`conf_get_prop ${file} symlink`" 
    561         file=`$readlink_cmd -m $file` 
    562         if [ -n "$symlink" ]; then 
    563             local cmd="$SUDO ln -snf $symlink ${LIVE_ROOT}$livefile" 
    564             echo $cmd 
    565             $cmd 
    566         else 
    567                     local opts="-o $owner -g $group -m $mode" 
    568                     local cmd="$SUDO $install_cmd $opts $file ${LIVE_ROOT}$livefile" 
     581        livefile="${LIVE_ROOT}${livefile}" 
     582        if ! conf_beenthere $statefile "$livefile" ; then 
     583            file=`$readlink_cmd -m $file` 
     584            if [ -n "$symlink" ]; then 
     585                local cmd="$SUDO ln -snf $symlink $livefile" 
     586            else 
     587                        local opts="-o $owner -g $group -m $mode" 
     588                        local cmd="$SUDO $install_cmd $opts $file $livefile" 
     589            fi 
    569590                    echo $cmd 
     591            conf_gothere $statefile "$livefile" 
    570592                    $cmd 
    571593        fi 
     
    648670    ABS_WORK=$(${readlink_cmd} -m "$WORK_PATH") 
    649671        local module="$1" 
    650     local file="$2" 
     672    local statefile="$2" 
     673    local file="$3" 
    651674    shift 2 
    652675    local livefile 
     
    662685    livefile="/${file#*/}" 
    663686    file="${ABS_WORK}/${module}${livefile}" 
     687    livefile="${LIVE_ROOT}${livefile}" 
    664688 
    665689        # See if it even exists 
    666690    if [ ! -e "$file" ] ; then 
    667691        conf_debug "$file" does not appear to exist 
    668         conf_install $module "$@" 
     692        conf_install $module $statefile "$@" 
    669693        return 1 
    670694    fi 
     
    683707     
    684708    if [ -n "$symlink" ] ; then 
    685         local cmd="$SUDO ln -snf $symlink ${LIVE_ROOT}$livefile" 
     709        local cmd="$SUDO ln -snf $symlink $livefile" 
    686710    else 
    687             local cmd="$SUDO $install_cmd $opts $file ${LIVE_ROOT}$livefile" 
    688     fi 
    689  
    690         ${NFS_HACK:-false} && chmod o+rx ${ABS_WORK} 
    691         echo $cmd 
    692         $cmd || failures=true 
    693         ${NFS_HACK:-false} && chmod o-rx ${ABS_WORK} 
     711            local cmd="$SUDO $install_cmd $opts $file $livefile" 
     712    fi 
     713 
     714    if ! conf_beenthere $statefile "$livefile" ; then 
     715            ${NFS_HACK:-false} && chmod o+rx ${ABS_WORK} 
     716            echo $cmd 
     717        conf_gothere $statefile "$lifefile" 
     718            $cmd || failures=true 
     719            ${NFS_HACK:-false} && chmod o-rx ${ABS_WORK} 
     720    fi 
    694721 
    695722    if [ -d "$file" ] ; then 
    696723        conf_debug "conf_install encountered a directory. Recursing." 
    697         conf_install $module $(find "$file" \ 
     724        conf_install $module $statefile $(find "$file" \ 
    698725            -mindepth 1 -maxdepth 1 -not -name '.svn') || failures=true 
    699726    fi 
    700727    conf_debug "conf_install recursing" 
    701         conf_install $module "$@" || failures=true 
     728        conf_install $module $statefile "$@" || failures=true 
    702729    conf_debug "conf_install returning" 
    703730    if $failures ; then  
     
    11521179} 
    11531180 
     1181# Gets a reversed copy of the recipe 
     1182function conf_get_reverse_recipe { 
     1183    local fwd_recipe=$(conf_get_recipe "$@") 
     1184    local rev_recipe 
     1185    for module in $fwd_recipe ; do 
     1186        rev_recipe="$module $rev_recipe" 
     1187    done 
     1188    echo $rev_recipe 
     1189} 
     1190 
    11541191# Spits the recipe, modules separated by whitespace, out on stdout 
    11551192function conf_get_recipe { 
  • trunk/confsync.in

    r540 r545  
    116116sys_revision=`conf_sysrev` 
    117117last_action=$(conf_lastact) 
     118statefile=$(conf_tmp_file) 
    118119 
    119120if [ -n "${sys_revision}" ] ; then 
     
    133134for layer in $(conf_get_recipe) ; do 
    134135    echo "Rolling on $layer..." 
    135     conf_rollout $layer || conf_cleanExit 
     136    conf_rollout $layer $statefile || conf_cleanExit 
    136137done 
    137138for file in $SINGULARITIES ; do 
Note: See TracChangeset for help on using the changeset viewer.