[ 
https://ovirt-jira.atlassian.net/browse/OVIRT-899?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=23700#comment-23700
 ] 

Barak Korren commented on OVIRT-899:
------------------------------------

As we've talked, the code will probably work better over time if the loop is 
not infinite, like so:
{code}
MAX_LOCK_ATTEMPTS=120
LOCK_WAIT_INTERVAL=5
LOCK_PATH=$HOME/experimental_repo.lock

wait_for_lock() {
  trap "rm -f '$LOCK_PATH'" EXIT
  for ((i = 0; i < $MAX_LOCK_ATTEMPTS; i++)); do
    (set -o noclobber; > $LOCK_PATH) 2> /dev/null && return
    sleep $LOCK_WAIT_INTERVAL
  done
  echo "Timed out waiting for lock" >&2
  exit 1
}
{code}
 


> Create locking on experimental flow
> -----------------------------------
>
>                 Key: OVIRT-899
>                 URL: https://ovirt-jira.atlassian.net/browse/OVIRT-899
>             Project: oVirt - virtualization made easy
>          Issue Type: Task
>            Reporter: Gil Shinar
>            Assignee: infra
>
> In order to make experimental flow atomic, we need to do as follows:
> in deploy.sh script and in start_testing_latest.sh we need to add a loop in 
> the beginning of each script that does the following:
> *while 1:
> do
>   is_locked=$((echo aaa > my.lock) 2> /dev/null || echo is locked)
>   if [[ -z $is_locked ]]; then
>     break
>   else
>     sleep 5
>   fi
> done*
> Wrap the whole script with a  trap so in the end if each script we will be 
> able to remove my.lock no matter what happened.



--
This message was sent by Atlassian JIRA
(v1000.610.1#100023)
_______________________________________________
Infra mailing list
Infra@ovirt.org
http://lists.ovirt.org/mailman/listinfo/infra

Reply via email to