今天使用CF(v145) 上传app,进行测试,发现一直无法上传成功,总是处于uploading 状态,查看后台日志,发现一直在调用接口:
10.106.1.46, 10.106.1.34 - - [07/May/2014 17:06:00] "GET /v2/jobs/3278adea-acbd-4bb0-8301-89ec6d69961f HTTP/1.1" 200 230 0.0088
查询这个job是否完成,根据现象这个job好像一直处于未完成状态,查看CF 中的CloudController 源码:
-
def upload(guid)
-
-
app = find_guid_and_validate_access(:update, guid)
-
-
logger.error "app=#{app} resourcee=#{params["resources"]}"
-
raise Errors::AppBitsUploadInvalid, "missing :resources" unless params["resources"]
-
-
uploaded_zip_of_files_not_in_blobstore_path = CloudController::DependencyLocator.instance.upload_handler.uploaded_file(params, "application")
-
-
logger.error "uploaded_zip_of_files_not_in_blobstore_path=#{uploaded_zip_of_files_not_in_blobstore_path}"
-
app_bits_packer_job = AppBitsPackerJob.new(guid, uploaded_zip_of_files_not_in_blobstore_path, json_param("resources"))
-
-
if params["async"] == "true"
-
logger.error "async is true"
-
job = Delayed::Job.enqueue(app_bits_packer_job, queue: LocalQueue.new(config))
-
[HTTP::CREATED, JobPresenter.new(job).to_json]
-
else
-
logger.error "async is false"
-
app_bits_packer_job.perform
-
[HTTP::CREATED, "{}"]
-
end
-
rescue VCAP::CloudController::Errors::AppBitsUploadInvalid, VCAP::CloudController::Errors::AppPackageInvalid
-
app.mark_as_failed_to_stage
-
raise
-
end
控制台 push app 时,是采用的异步,传入了参数async=true,将生成package的job 放入了Delayed::Job 队列。在AppBitsPackerJob 中增加了日志,发现,该任务就没有被执行。
查看启动cloud_controller_jobs 的脚本
-
case $1 in
-
-
start)
-
pid_guard $PIDFILE "Cloud controller jobs"
-
-
mkdir -p $RUN_DIR
-
mkdir -p $LOG_DIR
-
-
chown vcap:vcap $RUN_DIR
-
chown vcap:vcap $LOG_DIR
-
-
echo $$ > $PIDFILE
-
chown vcap:vcap $PIDFILE
-
-
cd $CC_PACKAGE_DIR/cloud_controller_ng
-
export QUEUES=cc-micro_ng-0,$GENERIC_QUEUE
-
exec chpst -u vcap:vcap bundle exec rake jobs:work \
-
>>$LOG_DIR/jobs_work.stdout.log 2>>$LOG_DIR/jobs_work.stderr.log
-
;;
红色部分是应该是队列名称,想起之前修改过CloudController的index。修改为了1.
-
bulk_api:
-
auth_user: bulk_api
-
auth_password: "c1oudc0w"
-
-
nginx:
-
use_nginx: false
-
instance_socket: "/var/vcap/sys/run/cloud_controller_ng/cloud_controller.sock"
-
-
index: 1
-
name: micro_ng
-
-
info:
-
name: vcap
-
build: "2222"
-
version: 2
-
support_address:
-
description: Cloud Foundry sponsored by Pivotal
-
api_version: 2.0.0
查看cc数据库,数据表delay_jobs 每个delayed job 的queue 标记,猜测是由于 队列名称不一致导致的。
修改后,恢复正常。
CloudFoundry 将这个index 参数放在配置文件,不知道是要做什么用。。。。