Skip to content

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

americanomin edited this page Dec 19, 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 파일을 만들어서 배포 시도.

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

depth 1 depth 2 condition result
appspec > source 하위 파일 / 폴더가 Symlink인 경우 파일이 Symlink인 경우 source 파일이 Symlink이고, destination에 같은 이름의 일반 파일 / Symlink 파일이 있는 경우 오류남 (폴더 Symlink 오류 픽스 버전 (#152)으로 배포 테스트 시, OVERWRITE option을 줘도, RETAIN 방식으로 동작함. 😦)
폴더가 Symlink인 경우 source 폴더가 Symlink이고, destination에 같은 이름의 일반 폴더가 있는 경우 오류안남. (복사된다. 그런데 이전에 있던 버그 때문에, Symlink가 복사되진 않는다. #199 이슈 픽스되면, Symlink 까지 잘 복사될거다.
source 폴더가 Symlink이고, destination에 같은 이름의 Symlink 폴더가 있는 경우 오류남
source 폴더가 Symlink이고, destination에 같은 이름의 일반 파일이 있는 경우 오류남

에러 로그

source 파일이 Symlink이고, destination에 같은 이름의 일반 파일 / 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" 

source 폴더가 Symlink이고, destination에 같은 이름의 Symlink 폴더가 있는 경우

source 폴더가 Symlink이고, destination에 같은 이름의 일반 파일이 있는 경우

2018-12-18 12:17:48 ERROR [codedeploy-agent(2824)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Error during perform: Errno::EEXIST - File exists @ dir_s_mkdir - /tmp/apps/app/181218-sym-folder - /usr/lib/ruby/2.3.0/fileutils.rb:253:in `mkdir'
/usr/lib/ruby/2.3.0/fileutils.rb:253:in `fu_mkdir'
/usr/lib/ruby/2.3.0/fileutils.rb:182:in `block in mkdir'
/usr/lib/ruby/2.3.0/fileutils.rb:181:in `each'
/usr/lib/ruby/2.3.0/fileutils.rb:181:in `mkdir'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/install_instruction.rb:255: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-18 12:17:48 WARN  [codedeploy-agent(2824)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Calling PutHostCommandComplete: "Code Error"
2018-12-18 12:17:48 INFO  [codedeploy-agent(2824)]: Version file found in /opt/codedeploy-agent/.version with agent version OFFICIAL_1.0-1.1597_deb.

기타 발견사항

  • Symlink source 폴더를 OVERWRITE 옵션으로 배포했을 때, 이미 폴더가 존재하는 경우 Symlink가 생성되지 않는다.
    • clean-up 파일에 Symlink source 폴더가 추가되지 않는다. Symlink가 연결되어있는 폴더의 하위 파일들만 뜬다.
    • OVERWRITE 상관없이 발생하는 오류인가.. ☹️

0fdac339-53b0-43d4-809a-26851ab1672f-cleanup

/tmp/apps/app/modules/.DS_Store
/tmp/apps/app/modules/site1
/tmp/apps/app/modules/site1/module2
/tmp/apps/app/modules/site1/module2/public
/tmp/apps/app/modules/site1/module2/public/test
/tmp/apps/app/modules/site1/module2/apps
/tmp/apps/app/modules/site1/module2/apps/test
/tmp/apps/app/modules/site1/module1
/tmp/apps/app/modules/site1/module1/public
/tmp/apps/app/modules/site1/module1/public/test
/tmp/apps/app/modules/site1/module1/apps
/tmp/apps/app/modules/site1/module1/apps/test
/tmp/apps/app/modules/site1/.DS_Store
/tmp/apps/app/symlink-folder/module2
/tmp/apps/app/symlink-folder/module2/public
/tmp/apps/app/symlink-folder/module2/public/test
/tmp/apps/app/symlink-folder/module2/apps
/tmp/apps/app/symlink-folder/module2/apps/test
/tmp/apps/app/symlink-folder/module1
/tmp/apps/app/symlink-folder/module1/public``` 

Clone this wiki locally