【发布时间】:2018-08-29 00:06:03
【问题描述】:
我正在尝试从 Cloud Function 触发 Dataflow 管道,该管道本身是在 GCS 存储桶中上传新文件时触发的。 当我上传文件时,云功能被正确触发,但几秒钟后超时,没有触发任何数据流。 下面是我的功能代码:
const google = require('googleapis');
const projectId = "iot-fitness-198120";
exports.moveDataFromGCStoPubSub = function(event, callback) {
const file = event.data;
if (file.resourceState === 'exists' && file.name) {
google.auth.getApplicationDefault(function (err, authClient, projectId) {
if (err) {
throw err;
}
if (authClient.createScopedRequired && authClient.createScopedRequired()) {
authClient = authClient.createScoped([
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/userinfo.email'
]);
}
console.log("File exists and client function is authenticated");
console.log(file);
const dataflow = google.dataflow({ version: 'v1b3', auth: authClient });
console.log(`Incoming data: ${file.name}`);
dataflow.projects.templates.create({
projectId: projectId,
resource: {
parameters: {
inputFile: `gs://${file.bucket}/${file.name}`,
outputTopic: `projects/iot-fitness-198120/topics/MemberFitnessData`
},
jobName: 'CStoPubSub',
gcsPath: 'gs://dataflow-templates/latest/GCS_Text_to_Cloud_PubSub',
staginglocation: 'gs://fitnessanalytics-tmp/tmp'
}
}, function(err, response) {
if (err) {
console.error("problem running dataflow template, error was: ", err);
}
console.log("Dataflow template response: ", response);
callback();
});
});
}
};
执行甚至没有记录以下行,console.log("File exists and client function is authenticated");这告诉我它甚至没有走那么远。
这是执行期间的日志输出:
2018-03-20 04:56:43.283 GST 数据流触发函数 52957909906492 函数执行耗时 60097 毫秒,状态为:'timeout'
2018-03-20 04:55:43.188 GST 数据流触发函数 52957909906492 函数执行开始
知道为什么它没有触发数据流但没有抛出错误消息吗?
【问题讨论】:
标签: javascript node.js timeout google-cloud-functions google-cloud-dataflow