Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Composer copy_environment.py script fails under Python3 #1895

Copy link
Copy link
Closed
@wwlian

Description

@wwlian
Issue body actions

In which file did you encounter the issue?

https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/composer/tools/copy_environment.py

Did you change the file? If so, how?

No

Describe the issue

When copying an environment, the script fails with the following stack trace:

Composer operation successful.
Starting database transfer.
Obtaining service account `REDACTED` credentials to access SQL database.
Traceback (most recent call last):
File "copy_environment.py", line 732, in <module>
"diskSizeGb": args.override_disk_size_gb,
File "copy_environment.py", line 711, in clone_environment
copy_database(project, existing_env, new_env, running_as_service_account)
File "copy_environment.py", line 598, in copy_database
iam_client, project, gke_service_account_name
File "copy_environment.py", line 298, in create_service_account_key
base64.b64decode(service_account_key.get("privateKeyData", ""))
File "/usr/lib/python3.5/ast.py", line 84, in literal_eval
return _convert(node_or_string)
File "/usr/lib/python3.5/ast.py", line 83, in _convert
raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: b'{\n "type": "service_account",\n "project_id": "...", ....}'

Root cause is that in Python 3, base64.b64decode returns a byte string which gets passed to ast.literal_eval(), which expects a string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.