Skip to content

Commit

Permalink
migrate: fix condition to work with failed cleanup
Browse files Browse the repository at this point in the history
- add tmux to admin image
- change CMD to tmux
  • Loading branch information
fridim committed Oct 20, 2023
1 parent 50db727 commit 90586dc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
20 changes: 16 additions & 4 deletions Containerfile.admin
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ RUN dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x
gcc \
git \
jq \
libevent \
libevent-devel \
make \
nc \
ncurses-devel \
net-tools \
openssl \
postgresql \
Expand All @@ -33,10 +37,18 @@ RUN dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x
unzip \
vim \
wget \
&& cd /tmp \
&& TMUX_VERSION="3.3a" \
&& curl --silent --location https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz -O \
&& tar -zxf tmux-*.tar.gz \
&& cd tmux-*/ \
&& ./configure \
&& make && sudo make install \
&& dnf clean all \
&& VERSION=4.1.0 \
&& curl --silent --location https://github.com/Orange-OpenSource/hurl/releases/download/$VERSION/hurl-$VERSION-x86_64-unknown-linux-gnu.tar.gz \
| tar -xz -C /usr/local/bin --strip-components=1 --wildcards '*/hurl' '*/hurlfmt'
&& HURL_VERSION=4.1.0 \
&& curl --silent --location https://github.com/Orange-OpenSource/hurl/releases/download/${HURL_VERSION}/hurl-${HURL_VERSION}-x86_64-unknown-linux-gnu.tar.gz \
| tar -xz -C /usr/local/bin --strip-components=1 --wildcards '*/hurl' '*/hurlfmt' \
&& rm -rf /tmp/* && rm -rf /var/cache/dnf/* && rm -rf /var/log/dnf*

COPY --from=docker.io/migrate/migrate /usr/local/bin/migrate /usr/local/bin/migrate
WORKDIR /sandbox/
Expand All @@ -47,7 +59,7 @@ COPY --from=builder /sandbox/build/sandbox-* ./
COPY --from=builder /sandbox/tools ./tools
COPY --from=builder /sandbox/tests ./tests
COPY --from=builder /sandbox/db ./db
CMD ["/bin/bash"]
CMD ["/usr/local/bin/tmux", "new-session", "-s", "sandbox", "-c", "/sandbox"]


ENV DESCRIPTION="Image for Admins to interact with the Sandbox API"
Expand Down
21 changes: 12 additions & 9 deletions tools/migrate_aws_account_dynamodb_prod_to_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,25 @@
'S': sandbox
}
},
UpdateExpression="set available = :a, #c = :c",
UpdateExpression="set available = :false, to_cleanup = :false, #c = :comment",
ExpressionAttributeNames={
'#c': 'comment'
},
ExpressionAttributeValues={
':a': {
':false': {
'BOOL': False
},
':b': {
':true': {
'BOOL': True
},
':c': {
':comment': {
'S': 'Migrating from prod to dev'
},
':inprogress': {
'S': 'cleanup in progress'
}
},
ConditionExpression="available = :b OR #c = :c",
ConditionExpression="#c = :comment OR available = :true OR (to_cleanup = :true AND conan_status <> :inprogress)",
)

except Exception as e:
Expand Down Expand Up @@ -112,19 +115,19 @@
'S': sandbox
}
},
UpdateExpression="set to_cleanup = :a, #c = :c",
UpdateExpression="set to_cleanup = :true, #c = :comment",
ExpressionAttributeNames={
'#c': 'comment'
},
ExpressionAttributeValues={
':a': {
':true': {
'BOOL': True
},
':c': {
':comment': {
'S': 'Migrating from prod to dev'
}
},
ConditionExpression=" #c = :c",
ConditionExpression=" #c = :comment",
)

except Exception as e:
Expand Down

0 comments on commit 90586dc

Please sign in to comment.