记一次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解决
posted @ 2021-03-05 13:53  蒲公英的狂想  阅读(1258)  评论(0编辑  收藏  举报