I set up a google cloud scheduler job that triggers a cloud function through HTTP. I can be sure that the cloud function is triggered and runs successfully - it has produced the expected outcome. However, the scheduler job still shows "failed" and the logger is like:
{
"insertId": "8ca551232347v49",
"jsonPayload": {
"jobName": "projects/john/locations/asia-southeast2/jobs/Get_food",
"status": "UNKNOWN",
"url": "https://asia-southeast2-john.cloudfunctions.net/Get_food",
"@type": "type.googleapis.com/google.cloud.scheduler.logging.AttemptFinished",
"targetType": "HTTP"
},
"httpRequest": {},
"resource": {
"type": "cloud_scheduler_job",
"labels": {
"job_id": "Get_food",
"location": "asia-southeast2",
"project_id": "john"
}
},
"timestamp": "2020-10-22T04:08:24.521610728Z",
"severity": "ERROR",
"logName": "projects/john/logs/cloudscheduler.googleapis.com%2Fexecutions",
"receiveTimestamp": "2020-10-22T04:08:24.521610728Z"
}
I have pasted the cloud function code below with edits necessary to remove sensitive information:
import requests
import pymysql
from pymysql.constants import CLIENT
from google.cloud import storage
import os
import time
from DingBot import DING_BOT
from decouple import config
import datetime
BUCKET_NAME = 'john-test-dataset'
FOLDER_IN_BUCKET = 'compressed_data'
LOCAL_PATH = '/tmp/'
TIMEOUT_TIME = 500
def run(request):
"""Responds to any HTTP request.
Args:
request (flask.Request): HTTP request object.
Returns:
The response text or any set of values that can be turned into a
Response object using
`make_response <http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>`.
"""
while True:
# some code that will be break the loop in about 200 seconds
DING_BOT.send_text(msg)
return 'ok'
what I can be sure of is that the line right before the end of the fucntion, DING_BOT.send_text(msg)
executed successfully. I have received the text message.
What cloud be wrong here?