ããã«ã¡ã¯ãæè¡é¨ éçºåºç¤ã°ã«ã¼ãã®å¤§ç³ã§ãã
ä»åã¯ã¯ãã¯ãããã§å©ç¨ããã¦ããRuby製ã®ã¸ã§ã管çãã¼ã«kuroko2ã«ã¤ãã¦ç´¹ä»ãããã¨æãã¾ãã
kuroko2 ã¨ã¯
ã¯ãã¯ãããã§ã¯2011å¹´é ãããkurokoã¨ããã¸ã§ã管çãã¼ã«ãããã¾ããã ããã¦ç¾å¨ãkurokoã®å¾ç¶ã®ã¸ã§ã管çãã¼ã«ã¨ãã¦kuroko2ã2014å¹´ã«kurokoã®éçºè ã§ãããå½æã®æè¡é¨é· takai ã«ãã£ã¦éçºããç¾å¨ã«è³ã£ã¦ãã¾ãã
åç¨ã®ã¸ã§ã管çãã¼ã«ã¯æããããã¾ãããããæè¿ã¯AirflowãAzkabanãªã©ã®OSSã®ãã¼ã«ãåå¨ãã¦ãããããããèªç¤¾ã§ã¸ã§ã管çãã¼ã«ãä½ãå¿ è¦ã¯ç¡ãã®ããããã¾ããã ããããkurokoãéçºãããå½æã¯ããã¾ã§ã®å®æ度ã®OSSã®ã¸ã§ã管çãã¼ã«ã¯åå¨ãã¦ããªãã£ãã¨ãããã¨ã¨ãéå»ã®ãããè³ç£ãåé¡ãªãåä½ããããã¨ã§ããæ©è½è¿½å ãªã©èªåãã¡ã®æãå½¢ã«ç´ æ©ãé²åããããããããèªç¤¾è£½ã®ã¸ã§ã管çãã¼ã«ã使ã£ã¦ãã¾ãã
ã¢ã¼ããã¯ãã£
Web UI
Web UIã®ä¸»ãªæ©è½ã¯ä»¥ä¸ã®ãããªãã®ã«ãªãã¾ãã
- ã¸ã§ãã®å®ç¾© (å¾è¿°) ã¨ãã¹ã±ã¸ã¥ã¼ã«ã®å®ç¾©ã管çè ãã¨ã©ã¼ã®éç¥æ¹æ³ãªã©ã®è¨å®
- ã¸ã§ãã®æåå®è¡
- å®è¡ä¸ã®ã¸ã§ãã®ç¢ºèªãå®è¡ä¸ã®ã¸ã§ãã®å¼·å¶åæ¢ãªã©ã®ãªãã¬ã¼ã·ã§ã³
- å®è¡å±¥æ´ãå®è¡æã®ãã°ç¢ºèª
job-scheduler
cronã¹ã¿ã¤ã«ã§è¨å®ãããã¹ã±ã¸ã¥ã¼ã«ã«åããã¦å®è¡ããã¹ãã¸ã§ããworkflow-processorã¸ä¼ãã¾ãã
workflow-processor
ã¸ã§ãã®å®ç¾©ããå®éã«å®è¡ãããã³ãã³ããã¯ã¼ã¯ããã¼ãcommand-executorã¸ä¼ãã¾ãã ã¾ããå®è¡ä¸ã®ã¸ã§ãã«å¯¾ããkill signalãã¨ã©ã¼æã®ãªãã©ã¤ãªã©ã®æä½ãWeb UIãéãã¦workflow-processorçµç±ã§è¡ããã¾ãã
command-executor
command-executorã¨ããå®éã®ã³ãã³ãå®è¡ã責åã¨ããã¯ã¼ã«ã¼ãè¤æ°å°ã®EC2 ã¤ã³ã¹ã¿ã³ã¹ä¸ã§åä½ããå®è¡å¯è½ãªã¸ã§ããé次å®è¡ãã¾ãã command-executorã¯åæã«ãå®è¡ç¶æ ã確èªããcommand-monitorã¨å¼ã°ããã¯ã¼ã«ã¼ã¨ãWeb UIçµç±ã§éä¿¡ããã kill Signal ãåãåãå®è¡ä¸ã®ããããåæ¢ãããcommand-killerã¨å¼ã°ããã¯ã¼ã«ã¼ãèµ·åããã¾ãã
ã¾ãã1ã¤ã®ãã·ã³ä¸ã§è¤æ°ã®command-executorãåä½ãã¦ãã®ã§ã大éã®ã¡ã¢ãªãCPUãæ¶è²»ãããããªãããã®å ´åã¯ãããã«åãããæ§è½ã®å°ç¨ã®ã¤ã³ã¹ã¿ã³ã¹ãç«ã¦ãããã«åãã¦ã¸ã§ããå®è¡ãããã¨ãå¯è½ã§ãã
æ©è½
ã¸ã§ãã®å®ç¾©æ¹æ³
ã¡ã³ããã³ã¹ãé害æã«ã¯ã¤ã³ãã©ãã¼ã ã確èªãããã¨ããããããä»ã®é¨ç½²ãè¦ãã¨ãã®ããã«ãã©ã®ãããªã¸ã§ããªã®ããã©ã®ãããªå½±é¿ãããã®ããé害æã«ã©ã®ãããªå¯¾å¿ãããã¹ãããææ¡ã§ãããã¨ãéè¦ã§ãã kuroko2ã§ã¯ãè¨å®æã«å ¥åããã¸ã§ãã®å 容説æã®ããã¹ããã£ã¼ã«ãã«ããã¬ã¼ã¹ãã«ãã¼ã¨ãã¦ãã³ãã¬ã¼ããç¨æããã¦ãããMarkdownè¨æ³ãæ¡ç¨ãããã¨ã§ããããã®æ å ±ãè¨è¿°ã管çããããããã«å·¥å¤«ãããã¦ãã¾ãã
kuroko2 script
å ·ä½çãªã¸ã§ãã®å®ç¾©ã¯ kuroko2 script ã¨å¼ã°ããDSLãè¨è¿°ãã¦ããã¾ãã
æãåºæ¬çãªè¨è¿°ä¾ã¯ä¸è¨ã®ããã«ãªãã¾ãã
execute: echo "Hello, world"
execute:
ã®å¾ã«æ¸ããããã®ã¯ãcommand-executorããã·ã§ã«ã«ãã®ã¾ã¾æ¸¡ãããåãªãã·ã§ã«ã³ãã³ãã«ãªãã¾ãã
ã¯ãã¯ãããã§ã¯ãå¤ãã®ã¢ããªã±ã¼ã·ã§ã³ã§Railsãæ¡ç¨ãã¦ãã¾ãã
Railsã¢ããªã±ã¼ã·ã§ã³ã®ãããã«ã¤ãã¦ã¯ app/batches
以ä¸ã«ç®¡çãã rails runner
ã³ãã³ãã§å®è¡ã§ããããã«ãã¦ãã¾ãã
kuroko2ã§ã¯ãã®ãããªRailsã¢ããªã±ã¼ã·ã§ã³ç¨ã«ãRubyãRailsã«é¢ããç°å¢å¤æ°ãèªåã§è¨å®ãã execute
ãæ¡å¼µããDSLãç¨æãã¦ããããçµç±ãã¦ããããå®è¡ãã¦ãã¾ãã
ãã¡ãããRails以å¤ã«ã対å¿ãã¦ãã¾ãã å ·ä½çãªä¾ã¨ãã¦ãaamine ã®SQLããããã¬ã¼ã ã¯ã¼ã¯ã§ãã bricolage ã kuroko2 ããå®è¡ããã¦ãã¾ãã 詳細㪠bricolage ã«ã¤ãã¦ã®èª¬æã¯ãã巨大ãªããããåå²ãã¦æ§æãã ãSQLããããã¬ã¼ã ã¯ã¼ã¯Bricolageãã ãåç §ãã ããã
ã¯ã¼ã¯ããã¼ç®¡ç
ä¸è¨ã®ã¸ã§ãå®ç¾©DSLã¯ãï¼ã¤ã®ãããå®è¡ãå®ç¾©ããã ãã§ãªããä¾åé¢ä¿ã«ãããããªè¤æ°ã®ããããï¼ã¤ã®ã¸ã§ãã¨ãã¦å®ç¾©ãããã¨ãã§ãã¾ãã
execute: command1 execute: command2
ä¸è¨ã¯command1ãcommand2ã®é çªã§é次å®è¡ãããã ãã§ãããããã«
execute: command1 fork: execute: command2-a execute: command2-b execute: command3
ã®ããã«ãcommand2-aã¨command2-bã¯ä¸¦åå®è¡ãããï¼ã¤ã®å®è¡ãçµäºããã¨ããã§ãcommand3ãå®è¡ããããããªã¯ã¼ã¯ããã¼ãå®ç¾©ãããã¨ãã§ãã¾ãã ã¾ããä¾ãã°command2-bãã¨ã©ã¼ã«ãªã£ãå ´åãããã§ã¯ã¼ã¯ããã¼ã¯ä¸æåæ¢ããå®è¡ããªãã©ã¤ãããã¯ã¹ãããããããã¨ãã§ãã¾ãã
ãããã¯ã»ãã®ä¸ä¾ã§ããããã®ä»ã«ãã
- batch_runner - railsã¢ããªã±ã¼ã·ã§ã³ç¨ã®ãããå®è¡ã³ãã³ã
- env - ãããã«æ¸¡ãç°å¢å¤æ°ãè¨å®ã§ãã
- sub_process - ä»ã®ã¸ã§ããå®è¡ãã
- timeout - è¨å®ãããæéãéããå ´åã¯ã¸ã§ããéä¸ã§çµäºããã
- expected_time - æ³å®å®è¡æéãè¶ ãããã¸ã§ãã®ç®¡çè ã«ã¢ã©ã¼ããéã
ä¸è¨ã®ãããªDSLãããã¾ãã ããã«DSLã®è¿½å ãç°¡åã«è¡ããããã«ãªã£ã¦ãããä»å¾ã®ç°å¢å¤åãªã©ã«æè»ã«å¯¾å¿ã§ããããã«è¨è¨ããã¦ãã¾ãã
ã¸ã§ãå®è¡ã®ç®¡ç
ã¨ã©ã¼ãç¶æ ã®ç®¡çã«ã¤ãã¦
ã¸ã§ãå®è¡ä¸ã«ä½ããã®åå ã§ã¨ã©ã¼ãèµ·ããã¨ãã®kuroko2ã®æåã«ã¤ãã¦èª¬æãã¾ãã
kuroko2 ã¯ã¸ã§ãã«ãWORKING, ERROR, SUCCESS, CANCEL ã¹ãã¼ã¿ã¹ãæã£ã¦ããä¸è¨ã®ãããªæµãã«ãªãã¾ãã
çµç«¯ã¹ãã¼ã¿ã¹ã¯ãSUCCESSã¨CANCELã«ãªããERRORã®å ´åã¯ã¸ã§ãå ã®ã¨ã©ã¼ãèµ·ãããããããªãã©ã¤ãã¹ãããããããã¯ã¸ã§ãèªä½ããã£ã³ã»ã«ãã¾ãã
ERRORãçµç«¯ã¹ãã¼ã¿ã¹ã§ã¯ãªãçç±ã¯ãERRORã«ãªã£ãã¨ãããã¨ã¯éä¸ã¾ã§ããå®è¡ã§ããå®äºãã¦ããªãã¨ããæå³ã§WORKINGã¨åãæ±ããã¨ããçç±ã§ããããã«ERRORã®ç¶æ ãããªãã©ã¤ãè¡ãããããªæ©è½ã¨ãªã£ã¦ãã¾ãã
ã¾ããã¨ã©ã¼ãçºçããã¨ãã¯ãã¡ã¼ã«ããã£ããã§ç®¡çè ã«éç¥ããã¨ã©ã¼ã®ã¾ã¾æ¾ç½®ããã¦ããå ´åã«ãã¨ã©ã¼ã®ç¶æ ã解決ãããã¾ã§ã¢ã©ã¼ãã¡ã¼ã«ãéä¿¡ãã¾ãã ãããã®æ©è½ã«ãã£ã¦ãã¨ã©ã¼ãçºçããå ´åã«ã¯ç®¡çè ã¯ç´ æ©ãæ°ã¥ãã¦å¯¾å¿ãè¡ããã¨ãã§ããã¸ã§ããã¨ã©ã¼ã®ã¾ã¾æ¾ç½®ããããããªäºæ ãé²ããããã«ãªã£ã¦ãã¾ãã
å¤éå®è¡ã«ã¤ãã¦
ãããå®è¡ã®éã«æ°ãã¤ããã¹ããã®ã¨ãã¦ãåãããããå¤éã«å®è¡ããã¦ãã¾ããã¨ã§ãã ãããã®å®è¡ãæ³å®å¤ã«æéããããã¹ã±ã¸ã¥ã¼ãªã³ã°ããã次ã®å®è¡ã®æéã«ãªã£ã¦ãã¾ã£ãããæå³ããæåã§å¤éã«å®è¡ãã¦ã¾ãäºæ ã«ç¹ãããã¨ãããã¾ãã
å¤éå®è¡ãé¿ããã³ã¼ããããã¹ã¦ã®ãããã«åå¥ã«å®è£ ãã¦ããã®ã¯éª¨ãæãããããkuroko2ã¯ã¸ã§ãã®å®ç¾©ã¨ãã¦ãå¤éå®è¡ã®å¯å¦ãå®ç¾©ã§ããããã«ãªã£ã¦ãã¾ãã
ã¨ã©ã¼ãèµ·ããã¨ãã«ã¹ã±ã¸ã¥ã¼ã«ãããã¸ã§ãã®å®è¡ãæ¢ãã
ä¾ãã°ã1æ¥1åå¿ ãå®è¡ããããã¨ãåæã§ã1æ¥ã§ãæ¯æãã«ãªã£ã¦ãã¾ãã¨ãã¼ã¿ã«é½é½¬ãçãã¦ãã¾ããããæ¥ä»ã®é çªéãã«å®è¡ããªããã°ãããªããããããã£ãã¨ãã¾ãã
ãããã£ãããããã¨ã©ã¼ã«ãªã£ãå ´åããã®æ¥ã®ãã¡ã«æ å½è ããªã«ããªã§ããã°åé¡ãªãã§ãããããã絶対ã«è¡ããã¨ããä¿è¨¼ã¯ããã¾ããã
kuroko2ã§ã¯ã¸ã§ããã¨ã©ã¼ã«ãªãä¸è¨ã®ERRORã¹ãã¼ã¿ã¹ã®ã¾ã¾ã®å±¥æ´ãåå¨ãã¦ããå ´åããã以éã®ã¸ã§ãã®ã¹ã±ã¸ã¥ã¼ã«ãèªåã§ãã£ã³ã»ã«ããæ©è½ãããã¾ãããã¹ã¦ãªã«ããªãè¡ããã¨ã©ã¼ã解決ãããã¨ããã§ã¹ã±ã¸ã¥ã¼ã«éãã«å®è¡ããããã«åéããã¾ãã
ããã¯ç¹ã«ä¼æ¥ãé£ä¼ãªã©ããã«å¯¾å¿ã§ããªãå ´åã«ãææªã®äºæ ãèµ·ããªããããªé²å¾¡çã¨ãã¦æå¹ã§ãã
ã¸ã§ãã®ä¸è¦§ç®¡ç
kuroko2ã§ã¯å¤§éã«ã¸ã§ãã管çãã¦ãããããã¸ã§ããç´ æ©ãæ¢ãããã¨ãã管çãã¦ããã¸ã§ãã®ç¶æ ãç´ æ©ãç¥ãããã¨ã¯é常ã«éè¦ã§ãã kuroko2ã®Web UIã«ã¯æ¤ç´¢æ©è½ãããã·ã¥ãã¼ãããã以ä¸ã®ãããªæ©è½ãæä¾ããã¦ãã¾ãã
- èªåã管çãã¦ããã¸ã§ãããæ°ã«å ¥ãã«ç»é²ããã¸ã§ããä¸è¦§ã§ç¢ºèªã§ãã
- ã¿ã°ã§çµãè¾¼ã¿ãã§ãã
- 次åå®è¡äºå®æéã確èªã§ãããã®æéã§ã½ã¼ããããã¨ã§ããããã®å®è¡äºå®ãããã
- æ¤ç´¢æ©è½
- å®è¡ä¸ã®ã¸ã§ãã®ä¸è¦§
Dockerã³ã³ããã®æ´»ç¨
kuroko2ã®æ¬ ç¹ã¨ãã¦ãæ°è¦ã®ããã¸ã§ã¯ãã§æ°ãã«ã¢ããªã±ã¼ã·ã§ã³ãããããå®è¡ãããã¨ãã«ã¯ããã®ã¢ããªã±ã¼ã·ã§ã³ãåä½ã§ããããã«ç°å¢æ§ç¯ã®ä½æ¥ãçºçãã¦ãã¾ããã¨ã§ãã
社å ã§ã¯ãeagletmt ã«ããDockerç°å¢ã®æ´åãé²ãããã¦ããããããå®è¡ã«é¢ãã¦ãDockerã®æ©æµãåããããããã«ãªã£ã¦ãã¾ãã å ·ä½çã«ã¯ãDockerã¤ã¡ã¼ã¸ãã¸ã§ãå®è¡ã®éã«pullãã³ã³ãããç«ã¡ä¸ããDockerã³ã³ããå ã§ã³ãã³ããå®è¡ã§ããããã«ãããã®ã§ãã
Dockerãå©ç¨ãããã¨ã§ãã¢ããªã±ã¼ã·ã§ã³ãµã¼ãã¼ã«ã使ããDockerã¤ã¡ã¼ã¸ãï¼ã¤ä½ãã ãã§ã¸ã§ã管çã·ã¹ãã ä¸ã§ã®ç°å¢æ§ç¯ãè¡ãå¿ è¦ãªããã¸ã§ã管çã·ã¹ãã ä¸ã§ããããå®è¡ã§ããããã«ãªãã¾ããã
æå¾ã«
ã¯ãã¯ãããã§å©ç¨ããã¦ããã¸ã§ã管çã·ã¹ãã ã¨ãã®å¨è¾ºã«ã¤ãã¦ç°¡åã«ç´¹ä»ãã¾ããã
æ®å¿µãªããkuroko2ã¯ãªã¼ãã³ã½ã¼ã¹åã®äºå®ã¯ããã¾ããããä»åç´¹ä»ããéç¨æ¹æ³ãæ©è½ãªã©ã®ç¥è¦ã¯éå»ã®çµé¨ã失æãå ã«ãããã®ãå¤ããã¸ã§ã管çããããå®è¡ã®ç®¡çãè¡ãã¨ã³ã¸ãã¢ã«ã¨ã£ã¦ã¯ãåããããªæ©ã¿ãåé¡ãæ±ãã¦ãããããã®ã§ã¯ãªããã¨æãã¾ãã ãããã£ãæ¹ã ã«ã¨ã£ã¦ãä»åã®è¨äºãåèã«ãªãã°å¹¸ãã§ãã