GoogleCloudPlatform / reliable-task-scheduling-compute-engine-sample

Apache License 2.0
146 stars 137 forks source link

Running into HttpError when using python3 #24

Open antsarand opened 5 years ago

antsarand commented 5 years ago

I ran into the following issue when running the utility code using python3 (the issue doesn't happen with python2).

Exception in thread Thread-1: Traceback (most recent call last): File "/home/me/project/gce/cloud_handler.py", line 163, in write_log .execute(http=http) File "/home/me/.local/lib/python3.5/site- packages/googleapiclient/_helpers.py", line 130, in positional_wrapper return wrapped(*args, **kwargs) File "/home/me/.local/lib/python3.5/site- packages/googleapiclient/http.py", line 851, in execute raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: <HttpError 400 when requesting https://logging.googleapis.com/v1beta3/projects/b%27myprojectid%27/logs/task_runner/entries:write?alt=json returned "field [name] has issue [Invalid project resource name]">

The error occurs when writing logs:

`def write_log(self, record):

    {...}
    try:
        resp = self.client.projects().logs().entries().write(
            projectsId=self.project_id,
            logsId=self.logname,
            body=body)\
            .execute(http=http)  #ERROR HAPPENS HERE

    except Exception as e:
        sys.stderr.write(e.message + '\n')`

Any ideas on how to resolve this?

jpatokal commented 5 years ago

The sample in its current form requires Python 2.7 and has not been tested against 3. That said, it would be nice to update it and that error is rather mysterious. I'll follow up internally and get back to you.

vaibhavpancholi commented 4 years ago

Any update on the python migration of this?