Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option so clever deploy can do a clever restart automatically if remote commit is the same #276

Closed
jygastaud opened this issue Oct 18, 2018 · 11 comments · Fixed by #598
Assignees
Labels
command:deploy Tasks related to the deploy command discussing-design enhancement

Comments

@jygastaud
Copy link
Contributor

Actually, if you want to deploy the same commit twice, even with -f option, the command will return an error [ERROR] The clever-cloud application is up-to-date. Try this command to restart the application: clever restart.

Without force option, restart sounds like fine.
However deploy with --force option should still be OK.

Current use case is : deploying from Gitlab-CI, triggering manual action that will rebuild the website and run every CC HOOKS.

@hsablonniere
Copy link
Member

hsablonniere commented Oct 18, 2018

Interesting...

So right now here's the output:

$ clever deploy
[ERROR] The clever-cloud application is up-to-date. Try this command to restart the application:
        clever restart

exit status: 1

$ clever deploy --force
[ERROR] The clever-cloud application is up-to-date. Try this command to restart the application:
        clever restart

exit status: 1

It seems like you don't want to change the situation for clever deploy but you expect a different behaviour from clever deploy --force. I see two possibilities:

  1. A bit like what a git push would do: we just log that everything is up to date without any errors.
  2. Forcing the deploy would mean you want to automatically trigger a restart if the remote is already up to date.

This seems simple but I think it requires some thinking...

@jygastaud
Copy link
Contributor Author

jygastaud commented Oct 18, 2018

It seems like you don't want to change the situation for clever deploy

true

About the possibilities, it's more the 2 that I expect.

As a side note, --force option before 1.0.0 has the same behavior of git push --force.
Looks like it's not the case anymore.

@BlackYoup
Copy link
Member

IIRC, we used the same behavior that git has . clever deploy --force == git push --force. If there is nothing to push, no deployment is started and if you want to restart, you have to use the clever redeploy command.

@hsablonniere
Copy link
Member

Here's what you have with version 0.10.1:

$ clever-old deploy       
Pushing source code to Clever Cloud.
[ERROR] The clever-cloud application is up-to-date. Try `clever restart` to restart the application

exit status: 0

$ clever-old deploy -f
Pushing source code to Clever Cloud.
[ERROR] The clever-cloud application is up-to-date. Try `clever restart` to restart the application

exit status: 0

We "just" fixed the fact that logging an error should also return an exit status code 1 and log to stderr.

@jygastaud
Copy link
Contributor Author

ok, looks like my brain is a liar (and my CI to 😄 )

An other option to not change the behavior describe by @BlackYoup is to add a not option.
Something like --restart that can run a restart if git commit are the same ?

@jeremybastin1207
Copy link

Hi,

Any update on this issue ? It would be really useful to deploy twice on the same commit.

@hsablonniere
Copy link
Member

Hi @jeremybastin1207, thanks for you message.

This project clearly lacked some love in the past years and we're sorry about that. We recently put the project back on tracks and we're putting more time and effort on it.

About this issue, this is clearly a "simple to implement" and a "not that complex to design".

We'll be discussing the design of this issue next tuesday with @aurrelhebert and see what we can quickly move forward with 😉

@hsablonniere
Copy link
Member

Observations:

  • git push with same remote commit returns Everything up-to-date and exit 0
  • git push --force with same remote commit returns Everything up-to-date and exit 0
  • clever restart has a --without-cache option for the restart

@aurrelhebert aurrelhebert added the command:deploy Tasks related to the deploy command label Jul 25, 2023
@hsablonniere
Copy link
Member

hsablonniere commented Jul 26, 2023

We discussed this issue with @aurrelhebert and here's our report.

Context

Users want to use the clever-tools in their CI (GitLab, GitHub, Jenkins...). The classic scenario is:

  • Someone does a git push (or merge) which triggers the CI tool
  • The CI tool runs the job (checks, tests, validations...)
  • If everything passes, the CI tool wants to deploy the commit to Clever Cloud

A clever deploy should be enough but there are some caveats:

  • if the git history was rewritten, clever deploy will fail and require --force
  • if the commit to be deployed is the same as the remote commit, clever deploy and clever deploy --force will fail and inform the user to do a clever restart.

There's no way to detect a clever deploy failed because the remote commit was the same.
Therefore, users cannot safely and automatically trigger et clever restart in this very situation (remote commit is the same).

The need

Users need a "please deploy this commit even if it's already the one on the remote".

  • Could be combined with "please deploy this commit even if the git history was rewritter"
    • this is the --force option of clever deploy
  • Could be combined with "when deploying, don't use the build cache et force the build"
    • this is the --without-cache of clever restart

The proposition

Here are some examples to explain the current behaviour and our propositions.

Current behaviour

clever deploy
  • fails if remote commit is the same
  • fails if git history was rewritten

clever deploy --force
  • fails if remote commit is the same
  • works, even if git history was rewritten

New --same-commit-policy param

The name is a bit long but explicit and self-explanatory.

clever deploy --same-commit-policy=restart
  • works, even if remote commit is the same
    • the restart (or start if app was stopped) will try to use the build cache
  • fails if git history was rewritten

clever deploy --same-commit-policy=rebuild
  • works, even if remote commit is the same
    • the restart (or start if app was stopped) will NOT use the build cache
  • fails if git history was rewritten

clever deploy --same-commit-policy=ignore
  • if remote commit is the same
    • no deployment is triggered
    • but the command does not error
  • fails if git history was rewritten

clever deploy --same-commit-policy=error
clever deploy

NOTE: error is the default value, same as not using the param explicitly

Combine --force and --same-commit-policy

Depending on what you need, you could combine --force and --same-commit-policy.

clever deploy --force --same-commit-policy=restart
  • works, even if remote commit is the same
    • the restart (or start if app was stopped) will try to use the build cache
  • works, even if git history was rewritten

clever deploy --force --same-commit-policy=rebuild
  • works, even if remote commit is the same
    • the restart (or start if app was stopped) will NOT use the build cache
  • works, even if git history was rewritten

clever deploy --force --same-commit-policy=ignore
  • if remote commit is the same
    • no deployment is triggered
    • but the command does not error
  • works, even if git history was rewritten

Request for comments

Please tell us what you think of this. It will be combined with other works on the clever deploy command with --timeout, --watch=false and discussions about deploying a specific commit or tag.

poke @jeremybastin1207 @jygastaud

@hsablonniere hsablonniere changed the title Deploy command with --force option doesn't work properly Add an option so clever deploy can do a clever restart automatically if remote commit is the same Jul 26, 2023
@jeremybastin1207
Copy link

Hi @hsablonniere,
Thanks for this detailed report. The command "clever deploy --force --same-commit-policy=rebuild" fullfills my need to re-deploy on the same commit with a rewritten git history.

@hsablonniere
Copy link
Member

@jeremybastin1207 Thank you for your feedbacks. Sorry for the holiday delay :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command:deploy Tasks related to the deploy command discussing-design enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants