Skip to content

Commit

Permalink
Fix: Promotions fail in hammerbox with dirty requirements (#6239, PR #…
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes-ucsc committed May 26, 2024
2 parents 8c6a348 + 3df842e commit 3f7f6ce
Show file tree
Hide file tree
Showing 19 changed files with 217 additions and 94 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE/anvilprod-promotion.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Connected issue: #0000
- [ ] Reviewed build logs for anomalies on GitLab `anvilprod`
- [ ] Ran `_select anvilprod.shared && make -C terraform/shared apply` <sub>or this PR is not labeled `deploy:shared`</sub>
- [ ] Deleted PR branch from GitHub
- [ ] Deleted PR branch from GitLab `anvilprod`
- [ ] Moved connected issue to *Merged stable* column on ZenHub
- [ ] Moved promoted issues from *Merged lower* to *Merged stable* column on ZenHub
- [ ] Moved promoted issues from *Lower* to *Stable* column on ZenHub
Expand Down
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE/prod-hotfix.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ Connected issue: #0000
- [ ] Build passes on GitLab `prod`
- [ ] Reviewed build logs for anomalies on GitLab `prod`
- [ ] Deleted PR branch from GitHub
- [ ] Deleted PR branch from GitLab `prod`


### Operator (reindex)
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ def emit(t: T, target_branch: str):
'content': f'Deleted PR branch from GitLab `{d}`'
}
for d, s in t.target_deployments(target_branch).items()
if t is not t.promotion
if s is not None
),
*iif(t is T.promotion, [
{
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ test:
timeout: 1h 30m
script:
- make format
- test "$AZUL_IS_SANDBOX" = 1 && make requirements_update
- python -m azul -t config.deployment.is_lower_sandbox && make requirements_update
- make -C lambdas openapi
- make environment.boot
- make -C .github
Expand Down
6 changes: 6 additions & 0 deletions UPGRADING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ reverted. This is all fairly informal and loosely defined. Hopefully we won't
have too many entries in this file.


#6239 Promotions fail in hammerbox with dirty requirements
==========================================================

Remove the variable ``AZUL_IS_SANDBOX`` from all personal deployments.


#4655 All bucket names should default to qualified_bucket_name()
================================================================

Expand Down
2 changes: 0 additions & 2 deletions deployments/anvilbox/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ def env() -> Mapping[str, Optional[str]]:
#
'AZUL_DEPLOYMENT_STAGE': 'anvilbox' if is_sandbox else None,

'AZUL_IS_SANDBOX': str(int(is_sandbox)),

# This deployment uses a subdomain of the `anvildev` deployment's
# domain.
#
Expand Down
2 changes: 0 additions & 2 deletions deployments/hammerbox/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,6 @@ def env() -> Mapping[str, Optional[str]]:
#
'AZUL_DEPLOYMENT_STAGE': 'hammerbox' if is_sandbox else None,

'AZUL_IS_SANDBOX': str(int(is_sandbox)),

# This deployment uses a subdomain of the `anvilprod` deployment's
# domain.
#
Expand Down
2 changes: 0 additions & 2 deletions deployments/sandbox/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ def env() -> Mapping[str, Optional[str]]:
#
'AZUL_DEPLOYMENT_STAGE': 'sandbox' if is_sandbox else None,

'AZUL_IS_SANDBOX': str(int(is_sandbox)),

# This deployment uses a subdomain of the `dev` deployment's domain.
#
'AZUL_DOMAIN_NAME': 'dev.singlecell.gi.ucsc.edu',
Expand Down
62 changes: 60 additions & 2 deletions environment
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ _logout() {
}

_logout_completely() {
# We don't use `&&` between function invocations because failing to log out of
# one realm shouldn't prevent us from attempting to log out of the others.
# We don't use `&&` between function invocations because failing to log out of
# one realm shouldn't prevent us from attempting to log out of the others.
_logout_google
_logout
_logout_docker_ecr
Expand Down Expand Up @@ -258,6 +258,64 @@ _revenv() {
fi
}

_clone() {
if [[ -z "$1" || -z "$2" ]]; then
echo "Need two arguments: the name of the deployment to select in the"
echo "project clone and the name of the branch to check out in it."
return 1
fi
if [ -n "$VIRTUAL_ENV" ]; then
echo "Run 'deactivate' first"
return 2
fi
if [ "$(basename "$PWD")" != azul ]; then
echo "The name of the current project directory must be 'azul'"
return 3
fi
deployment="$1"
branch="$2"
(
set -e
git worktree add "../azul.${deployment}" "${branch}"
cd "../azul.${deployment}"
(cd terraform/gitlab/vpn && git submodule update --init easy-rsa)
rsync -rvlm \
-f '+ */' \
-f '+ environment.local.py' \
-f '+ /deployments/*.local/environment*.py' \
-f '- *' \
../azul/ \
.
source environment
_link "${deployment}"
_refresh
make virtualenv
source .venv/bin/activate
make requirements envhook
deactivate
rsync -av ../azul/.idea .
mv .idea/azul.iml ".idea/azul.${deployment}.iml"
sed -e '/<component name="ProjectId".*/d' \
-e s#\<module\ name=\"azul\"#\<module\ name=\""azul.${deployment}"\"#g \
-i '' \
.idea/workspace.xml
sed -e s#.idea/azul.iml#.idea/azul."${deployment}".iml#g \
-i '' \
.idea/modules.xml
echo ""
echo "You can now open the directory"
echo ""
pwd
echo ""
echo "as a project in PyCharm. Be sure to verify that the right .venv "
echo "is configured as the Python interpreter in the project settings."
echo ""
echo "To remove the clone, close the project in PyCharm, delete the"
echo "project directory, and run 'git worktree prune'"
echo ""
)
}

# We disable `envhook.py` to avoid redundancy. The `envhook.py` script imports
# `export_environment.py`, too. We could also pass -S to `python3` but that
# causes problems on Travis (`importlib.util` failing to import `contextlib`).
Expand Down
6 changes: 0 additions & 6 deletions environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,12 +840,6 @@ def env() -> Mapping[str, Optional[str]]:
#
'azul_browser_sites': json.dumps({}),

# 1 if current deployment is a main deployment with the sole purpose of
# testing feature branches in GitLab before they are merged to the
# develop branch, 0 otherwise. Personal deployments have this set to 0.
#
'AZUL_IS_SANDBOX': '0',

# A list of names of AWS IAM roles that should be given permission to
# manage incidents with AWS support as defined in CIS rule 1.20:
#
Expand Down
16 changes: 10 additions & 6 deletions scripts/check_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,28 @@

def default_deployment(branch: Optional[str]) -> Optional[str]:
deployments = config.shared_deployments_for_branch(branch)
return None if deployments is None else deployments[0]
return None if deployments is None else deployments[0].name


class BranchDeploymentMismatch(Exception):

def __init__(self,
branch: Optional[str],
deployment: str,
allowed: Optional[Sequence[str]]
deployment: config.Deployment,
allowed: Optional[Sequence[config.Deployment]]
) -> None:
branch = 'Detached head' if branch is None else f'Branch {branch!r}'
allowed = '' if allowed is None else f'one of {set(allowed)!r} or '
super().__init__(f'{branch} cannot be deployed to {deployment!r}, '
if allowed is None:
allowed = ''
else:
allowed = f'one of {set(d.name for d in allowed)!r} or '
super().__init__(f'{branch} cannot be deployed to {deployment.name!r}, '
f'only {allowed}personal deployments.')


def check_branch(branch: Optional[str], deployment: str) -> None:
if config.is_shared_deployment(deployment):
deployment = config.Deployment(deployment)
if deployment.is_shared:
deployments = config.shared_deployments_for_branch(branch)
if deployments is None or deployment not in deployments:
raise BranchDeploymentMismatch(branch, deployment, deployments)
Expand Down
2 changes: 1 addition & 1 deletion scripts/update_subgraph_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def default_common_prefix(self) -> str:
try:
func = getattr(environment, 'common_prefix')
except AttributeError:
assert not config.is_sandbox_or_personal_deployment, environment.__path__
assert config.deployment.is_main, environment.__path__
return ''
else:
return func(self.count)
Expand Down
Loading

0 comments on commit 3f7f6ce

Please sign in to comment.