Commcare Deployement error

I am trying to upgrade commcare (self manage instance) to the latest version.

By following the documentation here Deploying CommCare HQ code changes i've executed the following commands :

  1. update-code :
    it indicates me that there are commcare-cloud has uncommitted changes:. Is this an issue?

  2. commcare-cloud deploy
    it return :
    [x.x.x.x] Executing task 'deploy_commcare'
    Are you sure you want to preindex and deploy to monolith? [y/N] y
    [x.x.x.x] Executing task '_setup_release'
    [x.x.x.x] Executing task 'create'
    [x.x.x.x] sudo: mkdir -p /home/cchq/www/monolith/releases/2022-06-29_17.28
    [x.x.x.x] Executing task 'update'
    [x.x.x.x] sudo: git submodule foreach "git fetch origin"
    [x.x.x.x] out: Entrée dans 'corehq/apps/hqmedia/static/hqmedia/MediaUploader'
    [x.x.x.x] out: fatal: impossible de se connecter à github.com :
    [x.x.x.x] out: github.com[0: x.x.x.x]: errno=Connexion terminée par expiration du délai d'attente
    [x.x.x.x] out:
    [x.x.x.x] out: fatal: run_command a retourné un statut non-nul pour corehq/apps/hqmedia/static/hqmedia/MediaUploader
    [x.x.x.x] out: .
    [x.x.x.x] out:

Fatal error: sudo() received nonzero return code 128 while executing!

Requested: git submodule foreach "git fetch origin"
Executed: sudo -S -p 'sudo password:' -H -u "cchq" /bin/bash -l -c "cd /home/cchq/www/monolith/current >/dev/null && git submodule foreach "git fetch origin""

Aborting.
!!! Parallel execution exception under host u'x.x.x.x':
Process x.x.x.x:
....
Underlying exception:
sudo() received nonzero return code 128 while executing!

Requested: git submodule foreach \"git fetch origin\"
Executed: sudo -S -p '\"'\"'sudo password:'\"'\"' -H  -u \"cchq\"  /bin/bash -l -c \"cd /home/cchq/www/monolith/current >/dev/null && git submodule foreach \\"git fetch origin\\"\"' --environment monolith"

Disconnecting from x.x.x.x... done.

Can you help me with this?
Thanks,

P.s :
I try to change repository to use https and git@ without success.

Hello Rodolphe,

It appears that there is some issue with git or github. I suggest you to try to run this command manually to troubleshoot the issue with git/github. Below is how to do this manually.

  • Login to the above VM where the code is getting deployed
  • Change to cchq user
  • CD into /home/cchq/www/monolith/releases/2022-06-29_17.28 directory
  • Execute git submodule foreach "git fetch origin"

Hi Sravan_Reddy,

Thank you for your help.

I have executed the command and I have this message :
fatal: not a git repository (or any of the parent directoriesà: .git

By the way, all this would not be to the fact that it fails to connect to github when I run commcare-cloud deploy as shown here :

x.x.x.x] sudo: git submodule foreach "git fetch origin"
[x.x.x.x] out: Entrée dans 'corehq/apps/hqmedia/static/hqmedia/MediaUploader'
[x.x.x.x] out: fatal: impossible de se connecter à github.com :
[x.x.x.x] out: github.com[0: x.x.x.x]: errno=Connexion terminée par expiration du délai d'attente
[x.x.x.x] out:

Hello Rodolphe,

I suspect this is still an issue with the remote URLs for the git repositories on your current release (located at /home/cchq/www/monolith/current).

If you login to the server and cd to that directory (similar to what Sravan asked above, but in the current release this time, not the new release) and run the following two commands:

git remote get-url origin
git submodule foreach 'git remote get-url origin'

This will print out the remote URL for the commcare-hq repository (first command) and all the remote URLs for the submodules (second command). I suspect some of those URLs need to be adjusted.

1 Like

Hi Joel,

Thank you for the guidelines.

When i cd to /home/cchq/www/monolith/current and execute :

  1. git remote -v
    origin GitHub - dimagi/commcare-hq: CommCareHQ is the server backend for CommCare, the world's largest platform for designing, managing, and deploying robust, offline-first, mobile applications to frontline workers worldwide (fetch)
    origin GitHub - dimagi/commcare-hq: CommCareHQ is the server backend for CommCare, the world's largest platform for designing, managing, and deploying robust, offline-first, mobile applications to frontline workers worldwide (push)

  2. git submodule foreach 'git remote get-url origin'
    Entrée dans 'corehq/apps/hqmedia/static/hqmedia/MediaUploader'
    git://github.com/dimagi/MediaUploader.git
    Entrée dans 'submodules/commcare-translations'
    git://github.com/dimagi/commcare-translations.git
    Entrée dans 'submodules/couchdbkit-aggregate'
    git://github.com/dimagi/couchdbkit-aggregate.git
    Entrée dans 'submodules/django-digest-src'
    git://github.com/dimagi/django-digest.git
    Entrée dans 'submodules/django-no-exceptions'
    git://github.com/dimagi/django-no-exceptions.git
    Entrée dans 'submodules/langcodes'
    git://github.com/dimagi/langcodes.git
    Entrée dans 'submodules/python-digest'
    git://github.com/dimagi/python-digest.git
    Entrée dans 'submodules/xml2json'
    git://github.com/dimagi/xml2json.git

Also in ~/.commcare-cloud/repo repository, remote repository is set on :
origin GitHub - dimagi/commcare-cloud: Tools for standing up and managing a CommCare HQ server environment (fetch)
origin GitHub - dimagi/commcare-cloud: Tools for standing up and managing a CommCare HQ server environment (push)

Are all these URLs correct?

Thanks for that information, Rodolphe.

The https:// URL is fine, but the submodules are using the old git:// URL format and need to be changed (either the https://github.com/ prefix or the git@github.com: prefix will work, more info at this GitHub doc).

For example, this is what I see on my system:

$ git remote get-url origin 
git@github.com:dimagi/commcare-hq.git

$ git submodule foreach 'git remote get-url origin'
Entering 'corehq/apps/hqmedia/static/hqmedia/MediaUploader'
git@github.com:dimagi/MediaUploader.git
Entering 'submodules/commcare-translations'
git@github.com:dimagi/commcare-translations.git
Entering 'submodules/couchdbkit-aggregate'
git@github.com:dimagi/couchdbkit-aggregate.git
Entering 'submodules/django-digest-src'
git@github.com:dimagi/django-digest.git
Entering 'submodules/django-no-exceptions'
git@github.com:dimagi/django-no-exceptions.git
Entering 'submodules/langcodes'
git@github.com:dimagi/langcodes.git
Entering 'submodules/python-digest'
git@github.com:dimagi/python-digest.git
Entering 'submodules/xml2json'
git@github.com:dimagi/xml2json.git
1 Like

I didn't pay attention to the url. Many thanks Joel for the very good remark.

So I first modified the submodules urls format with git@github.com format, but deploy was still not working then I used the https://github.com/ format.

With this last one the deploy really started, but I face another error now.

[x.x.x.x] sudo: virtualenv-clone /home/cchq/www/monolith/releases/2020-09-29_11.57/python_env-3.6 /home/cchq/www/monolith/releases/2022-07-01_18.34/python_env-3.6
[x.x.x.x] sudo: sed -i -e "s~/home/cchq/www/monolith/current/python_env-3.6~/home/cchq/www/monolith/releases/2022-07-01_18.34/python_env-3.6~g" $(find /home/cchq/www/monolith/releases/2022-07-01_18.34/python_env-3.6/bin/ -type f)
[x.x.x.x] sudo: export HOME=/home/cchq && source /home/cchq/www/monolith/releases/2022-07-01_18.34/python_env-3.6/bin/activate && pip uninstall -r /home/cchq/www/monolith/releases/2022-07-01_18.34/requirements/uninstall-requirements.txt --yes
[x.x.x.x] out: ERROR: Could not open requirements file: [Errno 2] Aucun fichier ou dossier de ce type: '/home/cchq/www/monolith/releases/2022-07-01_18.34/requirements/uninstall-requirements.txt'
[x.x.x.x] out:

Fatal error: sudo() received nonzero return code 1 while executing!

Requested: export HOME=/home/cchq && source /home/cchq/www/monolith/releases/2022-07-01_18.34/python_env-3.6/bin/activate && pip uninstall -r /home/cchq/www/monolith/releases/2022-07-01_18.34/requirements/uninstall-requirements.txt --yes
Executed: sudo -S -p 'sudo password:' -H -u "cchq" /bin/bash -l -c "cd /home/cchq/www/monolith/releases/2022-07-01_18.34 >/dev/null && export HOME=/home/cchq && source /home/cchq/www/monolith/releases/2022-07-01_18.34/python_env-3.6/bin/activate && pip uninstall -r /home/cchq/www/monolith/releases/2022-07-01_18.34/requirements/uninstall-requirements.txt --yes"

Aborting.
!!! Parallel execution exception under host u'x.x.x.x':

...
Underlying exception:
sudo() received nonzero return code 1 while executing!

Requested: export HOME=/home/cchq && source /home/cchq/www/monolith/releases/2022-07-01_18.34/python_env-3.6/bin/activate &&  pip uninstall -r /home/cchq/www/monolith/releases/2022-07-01_18.34/requirements/uninstall-requirements.txt --yes
Executed: sudo -S -p '\"'\"'sudo password:'\"'\"' -H  -u \"cchq\"  /bin/bash -l -c \"cd /home/cchq/www/monolith/releases/2022-07-01_18.34 >/dev/null && export HOME=/home/cchq && source /home/cchq/www/monolith/releases/2022-07-01_18.34/python_env-3.6/bin/activate &&  pip uninstall -r /home/cchq/www/monolith/releases/2022-07-01_18.34/requirements/uninstall-requirements.txt --yes\"' --environment monolith"

Disconnecting from x.x.x.x... done.

This error looks familiar to you?

Hmm unfortunately, no.

This "file not found" error is puzzling to me. I'm not familiar with that file or what part of a deploy needs it. Maybe someone who has more cchq familiarity will know when a deploy might expect this file?

1 Like

I get it.

Maybe I'll create another post to specify another more specific topic.

Thanks for the help!

1 Like