The packages in this module support Oscar running on the Google Cloud Platform (GCP). It is a separate module to avoid having the main Oscar module, golang.org/x/oscar, depend on GCP.
From the command line:
gcloud --project oscar-go-1 scheduler jobs pause gaby-run-prod --location us-central1
If that fails with a permission error, make sure you have authenticated with
gcloud auth application-default login
The gaby-prod service is deployed automatically on each push to master of the oscar repo via a cloud build trigger deploy-gaby-prod-on-push.
The services gaby-devel and gaby-prod can also be deployed manually following the instructions below.
From the UI:
deploy-gaby-devel
or deploy-gaby-prod
).Or, from the command line:
gcloud builds triggers run [TRIGGER_NAME] --branch master
Here, [TRIGGER_NAME] is one of deploy-gaby-devel
or deploy-gaby-prod
.
Check that the deploy was successful by monitoring the Cloud Build History. (Deploys take around 8 minutes to complete).
Run:
gcloud builds triggers run [TRIGGER_NAME] --sha [COMMIT]
where [TRIGGER_NAME] is one of deploy-gaby-devel
or deploy-gaby-prod
and [COMMIT] is the full commit hash.
Roll back a service from the UI:
Or from the command line:
gcloud run services [SERVICE] update-traffic --to-revisions [REVISION]=100
Here, [SERVICE] is either gaby-prod
or gaby-devel
and revision is the revision name to roll back to, which can be found in the revision history, e.g. gaby-prod-00004-t9p).
Firestore Cloud Run Cloud Build Cloud Error Reporting. Cloud Monitoring
Oscar errors, failures, and crashes are logged to Cloud Logging, along with other debugging messages.
Major errors and crashes are also organized and reported via Cloud Error Reporting. Notifications about new errors are also sent via email. Click on the “Configure Notifications” to manage notifications.
Cloud Build failures can be manually inspected at Cloud Build dashboard. To create an automatic alert:
resource.type= "build" logName="projects/oscar-go-1/logs/cloudaudit.googleapis.com%2Factivity" resource.labels.build_trigger_id="[TRIGGER_ID]" severity="ERROR"
where [TRIGGER_ID] is the ID of one of the triggers. You can find the trigger IDs by inspecting trigger information on Cloud Build page. 3. Run the query and make sure the results are as expected. 4. Click on “Create Alert”. 5. Fill in the information on alert name, description, and notifications.
You can inspect the alert information and results at Monitoring > Alerting
OSCAR_PROJECT=oscar-go-1
The GitHub API token and the Gemini API key are in the GCP Secret Manager, under hex-encoded names. You shouldn’t need to look at them. Programs that include the internal/gcp/gcpsecret package will be able to access them.
TODO