Amazon Elastic Beanstalk + Django + Sentry returning Raven.exceptions.Invalidgitrepository

Asked

Viewed 216 times

5

I’m trying to deploy to AWS Elastic Beanstalk. My project has a structure where Django’s Settings is in the Settings folder:

|projeto
|--settings
|----settings.py

It contains the configuration as:

RAVEN_CONFIG = {
    'dsn': 'https://----------:[email protected]/------',
    'release': raven.fetch_git_sha(os.path.dirname(os.pardir)),
}

I believe the error is in the line of release, I’ve changed it anyway, tried with 2 levels above, tried everything and it returns error that did not identify git repository (which exists).

File "/opt/python/run/venv/local/lib/python3.4/site-packages/raven/versioning.py", line 25, in fetch_git_sha
'Cannot identify HEAD for git repository at %s' % (path,))
raven.exceptions.InvalidGitRepository: Cannot identify HEAD for git repository at. 

Because of this error I can’t get Séntry to run on Elastic Beanstalk. I also tried with the template they have in the tutorial with wsgi calling Sentry. Also gives the same error. Probably because config is valid for any installation method used.

  • Could you add more details about the error, for example the log? Usually there is an explanation about the error.

  • The log is what I put in the post itself. File "/opt/python/run/venv/local/lib/python3.4/site-packages/raven/versioning.py", line 25, in fetch_git_sha
'Cannot identify HEAD for git repository at %s' % (path,))
raven.exceptions.InvalidGitRepository: Cannot identify HEAD for git repository at.

  • I understand he couldn’t get the git head...but my folder . git goes along in the deploy. I don’t understand why he has to take the head of git to run Ntry, but anyway he should take.

  • Somewhere in the configuration is there space to configure the project’s local/path? Because it tries to find {path}/. git/HEAD and when it does not find it, it displays the error "Repository at {path}", as it is exiting "Repository at .", so the path is currently "." which appears to be incorrect. https://github.com/getsentry/raven-python/blob/master/raven/versioning.py#L22

  • Of curiosity, some reason to separate the file settings.py inside another folder? If you move it to the root, it works again?

  • Tried to gitclone the repository you took? Copying and pasting might not be enough.

  • @leonardopessoa already moved and still did not work, but the reason is only to organize the project. Anyway he was already in a folder that was the project itself. But I think that’s not the problem, because the log message is related to git. But in Amazon elasticbeanstalk the repository folder doesn’t even go to the deploy

  • @Leonancarvalho makes no sense to make a git clone in Elastic Beanstalk.... its deployment process is automated.

  • @Renato I’ve seen this link you sent, is the line of the code that he gives the error. I checked this configuration, which would be PYTHONPATH if I’m not mistaken. The problem is that the Elastic Beanstalk deploy does not even send the folder. git, I connected via ssh and saw the folders it uses in the instance and there is no .git. I am simply giving up Sentry on AWS EBS and using logging to throw the errors in a db and email.

Show 4 more comments

1 answer

1

Elasticbeanstalk does not use git to deploy revisions of the application. It uses "Bundles" of the entire application stored in S3 (a zip/tarball of the entire repository, without the .git).

You need to pull the revision (sha, version etc.) from somewhere other than the sha of the git. You can also include this in the Bundle, before deploying (i.e. git rev-parse HEAD > ./git-current-head && eb deploy), and read in the code.

  • I tried to put the hardcoded git sha on Sentry and it didn’t roll. This your solution would be suitable if it worked hardcoded, correct? 'release': 'qualquermerdadeshahardcoded', ignoring this function of Raven.fetch_git_sha I don’t understand why the hell does Sentry want to git sha...if the . git folder doesn’t go together in Bundle it will do what with that sha? Woe my config line would get the sha straight? Pq in Raven versioning it requires having a . git folder with the HEAD file inside.

  • Raven wants to give you feedback on which version is running on your app and giving errors. Then he helps you with this helper to get the sha from git. But in Elasticbeanstalk you don’t have git, so you need to translate differently; for example by writing the sha in a file and using this value from 'release': ....

  • In my app (using Codedeploy, not EB; but it’s similar), I do it. No deploy: git rev-parse HEAD > ./git-current-head In the code: 'release': open(os.path.join(os.path.dirname(__file__, '../git-current-head')).read().strip()

  • You can just erase the release also and it will work. The only question is that you lose this useful information (which version of the app is running).

  • Apparently you could also take this metadata from the file that EB creates: http://stackoverflow.com/a/28488069/2648256

  • blz, I will test this method today, if it works out the points will be yours :) I really think q the most screwed me was q he was not updating the Bundle and even deleting all the files from Current/app, I know there because

  • I don’t know, but I figure if the deploy fails, he’ll skip the review. The AWS automatic deploy services also do weird things like stay in a loop trying to provision, fail, destroy the instance and go up a new... etc.

  • Didn’t work in the end?

  • Not yet, I’ve set up a new environment just to test and keep making mistakes. I’ll try more this week.

  • @Karlzillner that didn’t work?

  • No. I abandoned the idea and made a monitor of errors in the nail.

  • x.x that thing..

Show 7 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.