Skip to content

CodeDeploy agent does not use force option of ruby symlink filetools #143 분석

americanomin edited this page Dec 18, 2018 · 26 revisions

분석 과정

문제 재현

로컬에서 AWS CLI으로 배포하기

aws deploy create-deployment 
--application-name what-is-quality-symbolic-test 
--deployment-config-name CodeDeployDefault.AllAtOnce 
--deployment-group-name what-is-quality-symbolic-test 
--file-exists-behavior OVERWRITE
--description "배포 설명" 
--s3-location bucket=배포할파일버킷위치,bundleType=zip,eTag=배포파일eTag,key=배포파일명

AWS CLI - Deploy Create Deployment

재현 현상

서버에서 Symlink 파일을 직접 생성한 후, 동일한 경로에 Symlink 파일을 만들어서 배포 시도.

로그
2018-12-15 15:43:59 ERROR [codedeploy-agent(2824)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Error during perform: Errno::EEXIST - File exists @ syserr_fail2_in - /tmp/apps/app/symlink-file.txt - /usr/lib/ruby/2.3.0/fileutils.rb:358:in `symlink'
/usr/lib/ruby/2.3.0/fileutils.rb:358:in `block in ln_s'
/usr/lib/ruby/2.3.0/fileutils.rb:1587:in `fu_each_src_dest0'
/usr/lib/ruby/2.3.0/fileutils.rb:356:in `ln_s'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/install_instruction.rb:236:in `execute'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/installer.rb:49:in `block (2 levels) in install'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/installer.rb:48:in `each'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/installer.rb:48:in `block in install'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/installer.rb:47:in `open'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/installer.rb:47:in `install'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:136:in `block in <class:CommandExecutor>'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:68:in `execute_command'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:114:in `process_command'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:96:in `acknowledge_and_process_command'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:75:in `block in perform'
/opt/codedeploy-agent/vendor/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:348:in `run_task'
/opt/codedeploy-agent/vendor/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:337:in `block (3 levels) in create_worker'
/opt/codedeploy-agent/vendor/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `loop'
/opt/codedeploy-agent/vendor/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `block (2 levels) in create_worker'
/opt/codedeploy-agent/vendor/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `catch'
/opt/codedeploy-agent/vendor/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `block in create_worker'
/opt/codedeploy-agent/vendor/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
2018-12-15 15:43:59 WARN  [codedeploy-agent(2824)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Calling PutHostCommandComplete: "Code Error" 

  • 이렇게 오류가 나면, 파일 복사가 중지되기 때문에, 일부 파일은 삭제되고, 일부 파일은 추가되는 이상 현상이 발생함.
  • 폴더 Symlink 오류 픽스 버전 (#152)으로 배포 테스트 시, OVERWRITE option을 줘도, RETAIN 방식으로 동작함.
    • 파일 Symlink으로 테스트한건데, 이땐 왜 오류가 안난건지 모르겠음 😦

OVERWRITE 옵션 영향범위 테스트 케이스

수동으로라도 테스트해봐야겠음 🤔

source 하위 파일 / 폴더가 Symlink인 경우

파일이 Symlink인 경우

  • source 파일이 Symlink이고, destination에 이미 파일이 존재하는 경우
    • AS-IS. Errno::EEXIST 오류 발생. 일부 파일만 배포됨.

폴더가 Symlink인 경우

  • source 폴더가 Symlink이고, destination에 이미 존재하는 폴더가 Symlink인 경우
  • source 폴더가 Symlink이고, destination에 이미 존재하는 폴더는 일반 파일인 경우

source가 Symlink인 경우

  • source가 파일인 경우
  • source가 폴더인 경우
Clone this wiki locally