Example #1
0
 def hint(self):
     """
     Provides a hint about the root cause of the issue
     """
     project_id = Recipe._get_project_id()
     print("\n".join((
         'Product ratings are managed by the "rating service", hosted on Google AppEngine.',
         "The service provides APIs that allow other services to get and update products' ratings.",
         "The rating data is kept up-to-date by periodically calling an API endpoint that collects",
         "all recently sent new rating scores for each product and calculates the new rating",
         "based on the old value and the new scores. Try to check if the rating service operates normally.",
     )))
Example #2
0
 def restore_service(self):
     """
     Resume Cloud scheduler job to restore calls to recollect API of
     the rating service
     """
     logging.info("Resuming scheduled job of the rating service")
     print("Restoring broken operations...")
     project_id = Recipe._get_project_id()
     if not project_id:
         print("Failed: cannot find project id.")
         logging.error("Failed pausing scheduled job: no project id.")
         exit(1)
     resume_command = "gcloud scheduler jobs resume ratingservice-recollect-job --project {pid}".format(
         pid=project_id)
     _, err_str = Recipe._run_command(resume_command)
     if "ERROR:" in str(err_str, "utf-8"):
         print(err_str)
         logging.error("Failed executing service restoring command:" +
                       err_str)
     else:
         print("...done")
         logging.info("Scheduled job of the rating service resumed")