Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Allow deploying latest build again #114

Merged
merged 1 commit into from
Mar 28, 2022
Merged

Conversation

cansjt
Copy link
Contributor

@cansjt cansjt commented Mar 28, 2022

The current deployable check does not allow to redeploy the same deployment once again. Meaning if your deployment gets corrupted somehow you cannot delete it and deploy it again.

As an example, Airflow (jobflow) currently as a bug due to missing support for certain kubernetes resources which can have it looses track of some of the resources it created in k8s. The only work around seem to delete and create again the deployment (cf. apache/airflow#21087).

This commit changes the check so the latest build can be redeployed.

The current deployable check does not allow to redeploy the same
deployment once again. Meaning if your deployment gets corrupted
somehow you cannot delete it and deploy it again.

As an example, Airflow (jobflow) currently as a bug due to missing
support for certain kubernetes resources which can have it looses
track of some of the resources it created in k8s. The only work
around seem to delete and create again the deployment (_cf._
apache/airflow#21087).
@cansjt cansjt self-assigned this Mar 28, 2022
Copy link
Member

@rasta-rocket rasta-rocket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +46 to +51
# List commits behind the latest deployment tag, to see if the current commit is not behind.
# Exclude the tagged commit itself so we can redeploy an already deployed, and thus tagged,
# commit.
# Why isn't it enough to check that "${deployed_sha1}" != "${current_sha1}"?
if { git rev-list "^${deployed_sha1}" | grep -q "${current_sha1}" ; }
then
Copy link
Contributor Author

@cansjt cansjt Mar 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the logic is a bit backwards here: what we want is to know if the latest commit taggged as a deployment is reachable from HEAD. In which case we are either ahead of the latest deployment or the latest deployment.

 -----o----o----o----o HEAD
       \-<= label

But what we check is whether the HEAD is behind the latest tag, which seem much more complicated to check.

The whole code from line 37 onwards, can be replaced with a single check:

if ! { git rev-list HEAD | \
       grep -q "$(git tag --sort version:refname --format "%(objectname)" --list "deploiment-*" | \
                                  tail -1)" ; }
then
    fatal "the current build is older than the deployed one"
fi

@cansjt cansjt merged commit be0a21c into master Mar 28, 2022
@cansjt cansjt deleted the allow-lastest-build-redeployment branch March 28, 2022 09:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants