Skip to content

Commit

Permalink
snapshot: override_constraint (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
baabeetaa authored Jun 30, 2023
1 parent 3cad3cb commit 8af88fc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions snapshot/docker_service_create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,19 @@ if [[ -z $snapshot_storage_node ]]; then
MOUNT_OPT="--mount type=bind,source=$MOUNT_SRC,destination=/snapshot"
fi

constraint="node.hostname==$HOST"
if [ $( echo "${chain_name}" | egrep -c "archive" ) -eq 0 ]; then
# if pruned node, place on node with cosmosia.snapshot.pruned label, see https://github.com/notional-labs/cosmosia/issues/375
constraint="node.labels.cosmosia.snapshot.pruned==true"

# use override constraint if found
override_constraint=$(docker node ls -f node.label=cosmosia.snapshot.${chain_name}=true | tail -n +2 |awk '{print $2}')
if [[ -z $override_constraint ]]; then
echo "No override_constraint found"
constraint="node.hostname==$HOST"
if [ $( echo "${chain_name}" | egrep -c "archive" ) -eq 0 ]; then
# if pruned node, place on node with cosmosia.snapshot.pruned label, see https://github.com/notional-labs/cosmosia/issues/375
constraint="node.labels.cosmosia.snapshot.pruned==true"
fi
else
echo "Found override_constraint=${override_constraint}"
constraint="node.labels.cosmosia.snapshot.${chain_name}==true"
fi

echo "constraint= ${constraint}"
Expand Down

0 comments on commit 8af88fc

Please sign in to comment.