記一次Drone無法觸發構建的問題定位與處理


問題

好巧不巧,當你晚上准備上線的時候,在下午臨近下班的時候CICD工具出問題了,提交代碼不能觸發構建,不能上線了,Drone那邊負責人也下班了,正好CICD關聯的公司git倉庫也出問題了(就是上次Drone構建失敗被誤會的部門),我們的構建服務也沒有相關的報錯日志,就順水推鍋取消了上線。

定位

問題沒有定位出來,晚上(別人下班后)立馬check線上的版本,把中間過程的日志都記錄一下看看問題出在哪

CICD流程及日志定位

梳理CICD流程,簡易的流程圖如下:

只有管理系統是我們自己的,部署驗證,相關日志如下:

2021-03-05  10:41:16.796 [XNIO-2 task-309] INFO   - ==============部署管理系統,環境:env-new-test===============
2021-03-05  10:41:16.800 [XNIO-2 task-309] INFO   - ==============cloneDir:/tmp/datahub/env-new-test,gitUrl:http://gitlab.xxx.cn/xxx/env-new-test.git===============
2021-03-05  10:41:16.800 [XNIO-2 task-309] INFO   - ==============拉取代碼===============
2021-03-05  10:41:18.089 [XNIO-2 task-309] INFO   - ==============拉取代碼===============
2021-03-05  10:41:18.099 [XNIO-2 task-309] INFO   - ==============deployLogs:businessline-engine:0.1.675,mark-center-new:1.0.124-release.995,*******===============
2021-03-05  10:41:18.107 [XNIO-2 task-309] INFO   - ==============git push===============

沒有報錯日志,Git提交也成功了,但是就是沒有觸發構建(上面的鍋推錯了)

柳暗花明

第二天一上班,拉着大佬討論,大佬看了一下,果然和公司git倉庫那邊沒有關系(我們沒用,drone也沒依賴);一般drone沒有觸發構建原因有二:

1、自己設置的event限制(可自查)   
2、repo session過期 (可關閉repo開關,sync repo后再打開開關)

event限制

這個其實是drone.yml里面的pipeline.deploy.when的配置,相關配置如下:

pipeline:
   deploy:
      image: cicd-maven-***:1.0.2
      when:
         event:
         - push
         branch: master

這玩意八百年沒有變過,所以直接排除。

repo session過期

drone的repo session過期機制不是太清楚(后面有機會再研究),直接在drone的右上角點開Repositories菜單,把repo的開關先關閉再打開,再次提交恢復正常。自此問題解決,在此記錄一下,證君清白

后續來了

大佬指出來,這個過期和你的Cookie過期有關系,盡量不要保持cookies,使用的時候重新登錄基本就會避免這個問題,問題的原因基本就浮出水面了,我們先查閱一下官網:傳送門
Drone uses cookies to authenticate client requests and maintain the user session. This document provides resources for customizing cookie creation.
Drone signs authentication cookies using a secret key that is randomly generated when the server starts. Every time you restart the server a new key is generated, which means existing sessions are terminated. We can avoid terminating existing sessions on restart by providing the server with a static secret key.
Drone creates cookies with a default timeout of 30 days. When the cookie expires the user sessions is terminated and the user will be required to login. You can customize the cookie timeout through the environment.

意思是Drone的cookie默認會保持30天,如果Repository的操作人有超過30天沒有重新登錄,Cookie就會過期,會導致上述問題出現,這樣基本就能解釋清楚了

回顧一下最近幾個月Drone構建失敗的原因:

  • 第一次:之前Git Repository的負責人離職,當時盲猜是git帳號被清理,批量失敗(現在看來應當和這次的原因一樣),重新關閉打開repo解決
  • 第二次:Drone鏡像倉庫緩存不生效,阿里雲鏡像加速服務連接超時
  • 第三次:cookie過期,重新關閉打開repo解決


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM