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

Docs: clarify GCP service accounts. #2761

Merged
merged 5 commits into from
Nov 21, 2023
Merged

Docs: clarify GCP service accounts. #2761

merged 5 commits into from
Nov 21, 2023

Conversation

concretevitamin
Copy link
Collaborator

The error

google.auth.exceptions.RefreshError: Reauthentication is needed. Please run `gcloud auth application-default login` to reauthenticate.

has been reported by several users (#2738) for organizations that choose to auto-expire default credentials.

This PR clarifies our docs on how to use GCP service accounts, which avoid this error.

Tested (run the relevant ones):

  • Code formatting: bash format.sh
  • Any manual or new tests for this PR (please specify below): rendered locally
  • All smoke tests: pytest tests/test_smoke.py
  • Relevant individual smoke tests: pytest tests/test_smoke.py::test_fill_in_the_name
  • Backward compatibility tests: bash tests/backward_comaptibility_tests.sh

Copy link
Collaborator

@romilbhardwaj romilbhardwaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @concretevitamin - LGTM. Left some suggestions.

docs/source/cloud-setup/cloud-auth.rst Outdated Show resolved Hide resolved
docs/source/cloud-setup/cloud-permissions/gcp.rst Outdated Show resolved Hide resolved
Comment on lines 99 to 117
Note: If you encounter "*RemoveError: 'requests' is a dependency of conda and
cannot be removed from conda's operating environment*" when running :code:`conda
install -c conda-forge google-cloud-sdk`, try :code:`conda update --force conda`
first and rerun the command.

Note: if you encounter *Authorization Error (Error 400: invalid_request)* with the url generated by :code:`gcloud auth login`, try installing the latest version of the `Google Cloud SDK <https://cloud.google.com/sdk/docs/install>`_ (e.g., with :code:`conda install -c conda-forge google-cloud-sdk`) on **your local machine** (which opened the browser) and rerun the command.
Note: If you encounter "*Authorization Error (Error 400: invalid_request)*" with
the url generated by :code:`gcloud auth login`, try installing the latest
version of the `Google Cloud SDK <https://cloud.google.com/sdk/docs/install>`_
(e.g., with :code:`conda install -c conda-forge google-cloud-sdk`) on your local
machine (which opened the browser) and rerun the command.

.. tip::

If you are using multiple GCP projects, list all the projects by :code:`gcloud projects list` and activate one by :code:`gcloud config set project <PROJECT_ID>` (See `GCP docs <https://cloud.google.com/sdk/gcloud/reference/config/set>`_).
If you are using multiple GCP projects, list all the projects by :code:`gcloud projects list` and activate one by :code:`gcloud config set project <PROJECT_ID>` (see `GCP docs <https://cloud.google.com/sdk/gcloud/reference/config/set>`_).

To use service account to access GCP for SkyPilot, see :ref:`here<gcp-service-account>` for instructions.
**Optional**: To use service accounts to access GCP for SkyPilot, see
:ref:`here<gcp-service-account>` for instructions. A long-lived service account
on your local machine can avoid the periodic
"*google.auth.exceptions.RefreshError: Reauthentication is needed.*" error.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we wrap these into a note box and clearly enumerate the error and suggested fix in bullet points/table? Otherwise these notes are becoming hard to read and easy to miss.

E.g. something like

.. note::

  Here some commonly encountered errors and their fix:
    * "*RemoveError: 'requests' is a dependency of conda and
cannot be removed from conda's operating environment*" when running :code:`conda
install -c conda-forge google-cloud-sdk` - run :code:`conda update --force conda`
first and rerun the command.
    * "*Authorization Error (Error 400: invalid_request)*" with
the url generated by :code:`gcloud auth login` - install the latest
version of the `Google Cloud SDK <https://cloud.google.com/sdk/docs/install>`_
(e.g., with :code:`conda install -c conda-forge google-cloud-sdk`) on your local
machine (which opened the browser) and rerun the command.
    * "*google.auth.exceptions.RefreshError: Reauthentication is needed.*" - use a long-lived service account
on your local machine. See :ref:`here<gcp-service-account>` for instructions.

We can additionally include a separate mention of GCP service account support.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now put the errors in a dropdown, which I think makes the installation less daunting. Kept the first two bullets only as the last bullet is technically not encountered in installation.

docs/source/cloud-setup/cloud-auth.rst Outdated Show resolved Hide resolved
2. In the "Service Accounts" tab in the `IAM & Admin console
<https://console.cloud.google.com/iam-admin/iam>`__, click on the service
account to go to its detailed page. Click on the **KEYS** tab, then click on
**ADD KEY** to add a JSON key. The key will be downloaded automatically.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While creating the key, I was trying to look for an option to make it "long-lived" (as suggested by the tip above). Turns out service account keys that you create and download from IAM don't have an expiry time and stay valid until you delete them. Might be worth mentioning

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a clarification.

concretevitamin and others added 4 commits November 13, 2023 20:23
Co-authored-by: Romil Bhardwaj <romil.bhardwaj@berkeley.edu>
Co-authored-by: Romil Bhardwaj <romil.bhardwaj@berkeley.edu>
Co-authored-by: Romil Bhardwaj <romil.bhardwaj@berkeley.edu>
@concretevitamin concretevitamin merged commit 15e953a into master Nov 21, 2023
19 checks passed
@concretevitamin concretevitamin deleted the gcp-docs branch November 21, 2023 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants