diff --git a/contrib/grpcplugins/action/plugin-clair/go.mod b/contrib/grpcplugins/action/plugin-clair/go.mod index 9f00c1e6ff..31caeab3b5 100644 --- a/contrib/grpcplugins/action/plugin-clair/go.mod +++ b/contrib/grpcplugins/action/plugin-clair/go.mod @@ -6,7 +6,7 @@ replace github.com/ovh/cds => ../../../../ replace github.com/docker/docker => github.com/moby/moby v17.12.0-ce-rc1.0.20200528182317-b47e74255811+incompatible -replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.6.0 +replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.4.2 replace github.com/codegangsta/cli v1.22.2 => github.com/urfave/cli v1.22.2 @@ -16,7 +16,6 @@ replace github.com/opencontainers/runc v0.1.1 => github.com/opencontainers/runc require ( github.com/Microsoft/hcsshim v0.8.9 // indirect - github.com/Sirupsen/logrus v0.0.0-00010101000000-000000000000 // indirect github.com/containerd/containerd v1.3.4 // indirect github.com/containerd/continuity v0.0.0-20200413184840-d3ef23f19fbb // indirect github.com/docker/distribution v2.7.1+incompatible @@ -36,7 +35,6 @@ require ( github.com/prometheus/client_golang v1.1.0 github.com/quay/clair/v2 v2.1.4 github.com/spf13/viper v1.7.0 - github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect github.com/vbatts/tar-split v0.11.1 // indirect golang.org/x/net v0.0.0-20200602114024-627f9648deb9 ) diff --git a/contrib/grpcplugins/action/plugin-clair/go.sum b/contrib/grpcplugins/action/plugin-clair/go.sum index aa0b637e43..6139091f4e 100644 --- a/contrib/grpcplugins/action/plugin-clair/go.sum +++ b/contrib/grpcplugins/action/plugin-clair/go.sum @@ -56,8 +56,6 @@ github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= @@ -198,7 +196,6 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -276,9 +273,7 @@ github.com/jgsqware/xnet v0.0.0-20170203143001-13630f0737d2/go.mod h1:IAg/pDB4Re github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -298,8 +293,6 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -364,9 +357,7 @@ github.com/mndrix/tap-go v0.0.0-20170113192335-56cca451570b h1:/1WAr2jAZnfxlWW3M github.com/mndrix/tap-go v0.0.0-20170113192335-56cca451570b/go.mod h1:pzzDgJWZ34fGzaAZGFW22KVZDfyrYW+QABMrWnJBnSs= github.com/moby/moby v17.12.0-ce-rc1.0.20200528182317-b47e74255811+incompatible h1:H+QgMHAfk7fWdJycnicK2/U0VVhg0EeIdQFFLXdZcvc= github.com/moby/moby v17.12.0-ce-rc1.0.20200528182317-b47e74255811+incompatible/go.mod h1:fDXVQ6+S340veQPv35CzDahGBmHsiclFwfEygB/TWMc= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= @@ -398,8 +389,6 @@ github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3I github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/opencontainers/runc v0.1.1 h1:GlxAyO6x8rfZYN9Tt0Kti5a/cP41iuiO2yYT0IJGY8Y= -github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/runc v1.0.0-rc9 h1:/k06BMULKF5hidyoZymkoDCzdJzltZpz/UU4LguQVtc= github.com/opencontainers/runc v1.0.0-rc9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= @@ -449,9 +438,6 @@ github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v0.9.4 h1:Y8E/JaaPbmFSW2V81Ab/d8yZFYQQGbni1b1jPcG9Y6A= github.com/prometheus/client_golang v0.9.4/go.mod h1:oCXIBxdI62A4cR6aTRJCgetEjecSIYzOEaeAn4iYEpM= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.1.0 h1:BQ53HtBmfOitExawJ6LokA4x8ov/z0SYYb0+HxJfRI8= -github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= github.com/prometheus/client_model v0.0.0-20170216185247-6f3806018612/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -466,8 +452,6 @@ github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.6.0 h1:kRhiuYSXR3+uv2IbVbZhUxK5zVD/2pp3Gd2PpvPkpEo= -github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= github.com/prometheus/procfs v0.0.0-20170502131342-d098ca18df8b/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -476,8 +460,6 @@ github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURmKE= -github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/quay/clair/v2 v2.1.4 h1:C+ZscJo98hF/vDT7AU1sTcgsSTYqb3+FQL4UY1x73OI= github.com/quay/clair/v2 v2.1.4/go.mod h1:W98TX5hlrJA0+InaAtyM0R7x8e5SVonTSTj/Pj7ZGiY= @@ -546,8 +528,6 @@ github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c h1:+aPplBwWcHBo6q9xrfWdMrT9o4kltkmmvpemgIjep/8= -github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c/go.mod h1:SbErYREK7xXdsRiigaQiQkI9McGRzYMvlKYaP3Nimdk= github.com/tevino/abool v0.0.0-20170917061928-9b9efcf221b5/go.mod h1:f1SCnEOt6sc3fOJfPQDRDzHOtSXuTtnz0ImG9kPRDV0= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -569,7 +549,6 @@ github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMx github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yesnault/go-toml v0.0.0-20191205182532-f5ef6cee7945/go.mod h1:SsMrIuedaKvK8GekjwjVv8gMnHNAuvoINpKCARzdsEQ= -github.com/yesnault/gorp v2.0.0+incompatible/go.mod h1:7nhqtxBPZoPXx86SqUzP/OFLd8prnhkydPk51uJthQc= github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed/go.mod h1:9w6KSdZh23UWqOywWsRLUcJUrUNjRh4Ql3z9uVgnSP4= github.com/yuin/gopher-lua v0.0.0-20170901023928-8c2befcd3908/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU= github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs= @@ -627,7 +606,6 @@ golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= @@ -663,7 +641,6 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190514135907-3a4b5fb9f71f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/engine/api/test/test.go b/engine/api/test/test.go index 13bf93dc67..15add7e0e4 100644 --- a/engine/api/test/test.go +++ b/engine/api/test/test.go @@ -39,7 +39,7 @@ var ( ) func init() { - log.Initialize(&log.Conf{Level: "debug"}) + log.Initialize(context.TODO(), &log.Conf{Level: "debug"}) } type Bootstrapf func(context.Context, sdk.DefaultValues, func() *gorp.DbMap) error diff --git a/engine/cmd_start.go b/engine/cmd_start.go index d8c7faa3bb..ffedc6b456 100644 --- a/engine/cmd_start.go +++ b/engine/cmd_start.go @@ -268,10 +268,8 @@ See $ engine config command for more details. GraylogFieldCDSArch: sdk.GOARCH, GraylogFieldCDSServiceName: strings.Join(names, "_"), GraylogFieldCDSServiceType: strings.Join(types, "_"), - Ctx: ctx, } - // TODO Logger: each service should have it own logger - log.Initialize(&logConf) + log.Initialize(ctx, &logConf) // Sort the slice of services we have to start to be sure to start the API au first sort.Slice(serviceConfs, func(i, j int) bool { diff --git a/engine/hatchery/hatchery_helper_test.go b/engine/hatchery/hatchery_helper_test.go index 1e1d89bb16..1ea8a3bcf1 100644 --- a/engine/hatchery/hatchery_helper_test.go +++ b/engine/hatchery/hatchery_helper_test.go @@ -26,7 +26,7 @@ import ( ) func init() { - log.Initialize(&log.Conf{Level: "debug"}) + log.Initialize(context.TODO(), &log.Conf{Level: "debug"}) } func InitWebsocketTestServer(t *testing.T) *httptest.Server { diff --git a/engine/hatchery/serve.go b/engine/hatchery/serve.go index 70d9582625..68d9be05dd 100644 --- a/engine/hatchery/serve.go +++ b/engine/hatchery/serve.go @@ -193,7 +193,7 @@ func (c *Common) getPanicDumpListHandler() service.Handler { func (c *Common) InitServiceLogger() error { var signer jose.Signer if c.Common.ServiceInstance.LogServerAdress != "" { - logger, err := log.New(c.Common.ServiceInstance.LogServerAdress) + logger, _, err := log.New(context.Background(), c.Common.ServiceInstance.LogServerAdress) if err != nil { return sdk.WithStack(err) } diff --git a/engine/hatchery/swarm/helper_test.go b/engine/hatchery/swarm/helper_test.go index c8c80f9c09..dd794e5997 100644 --- a/engine/hatchery/swarm/helper_test.go +++ b/engine/hatchery/swarm/helper_test.go @@ -1,12 +1,13 @@ package swarm import ( + "testing" + "time" + "github.com/ovh/cds/engine/hatchery" "github.com/ovh/cds/sdk/cdsclient" "github.com/stretchr/testify/require" "gopkg.in/h2non/gock.v1" - "testing" - "time" docker "github.com/docker/docker/client" "github.com/ovh/cds/sdk/log" @@ -14,7 +15,7 @@ import ( ) func init() { - log.Initialize(&log.Conf{Level: "debug"}) + log.Initialize(context.TODO(), &log.Conf{Level: "debug"}) } func testSwarmHatchery(t *testing.T) *HatcherySwarm { diff --git a/engine/hooks/tasks_github_test.go b/engine/hooks/tasks_github_test.go index 26560b2738..c56be85811 100644 --- a/engine/hooks/tasks_github_test.go +++ b/engine/hooks/tasks_github_test.go @@ -12,7 +12,7 @@ import ( ) func init() { - log.Initialize(&log.Conf{Level: "debug"}) + log.Initialize(context.TODO(), &log.Conf{Level: "debug"}) } func Test_doWebHookExecutionGithub(t *testing.T) { diff --git a/engine/hooks/tasks_gitlab_test.go b/engine/hooks/tasks_gitlab_test.go index 42599dfd29..d35b495c84 100644 --- a/engine/hooks/tasks_gitlab_test.go +++ b/engine/hooks/tasks_gitlab_test.go @@ -13,7 +13,7 @@ import ( ) func init() { - log.Initialize(&log.Conf{Level: "debug"}) + log.Initialize(context.TODO(), &log.Conf{Level: "debug"}) } func Test_doWebHookExecutionGitlab(t *testing.T) { diff --git a/engine/hooks/tasks_test.go b/engine/hooks/tasks_test.go index e5fb038a04..41373da7bb 100644 --- a/engine/hooks/tasks_test.go +++ b/engine/hooks/tasks_test.go @@ -17,7 +17,7 @@ import ( ) func init() { - log.Initialize(&log.Conf{Level: "debug"}) + log.Initialize(context.TODO(), &log.Conf{Level: "debug"}) } func Test_doWebHookExecution(t *testing.T) { diff --git a/engine/repositories/repositories_test.go b/engine/repositories/repositories_test.go index 3fd180abe0..e94e355bdb 100644 --- a/engine/repositories/repositories_test.go +++ b/engine/repositories/repositories_test.go @@ -30,7 +30,7 @@ var ( ) func init() { - log.Initialize(&log.Conf{Level: "debug"}) + log.Initialize(context.TODO(), &log.Conf{Level: "debug"}) } func newTestService(t *testing.T) (*Service, error) { diff --git a/engine/vcs/vcs_test.go b/engine/vcs/vcs_test.go index b47db9c443..7ef45669cf 100644 --- a/engine/vcs/vcs_test.go +++ b/engine/vcs/vcs_test.go @@ -29,7 +29,7 @@ var ( ) func init() { - log.Initialize(&log.Conf{Level: "debug"}) + log.Initialize(context.TODO(), &log.Conf{Level: "debug"}) } func newTestService(t *testing.T) (*Service, error) { diff --git a/engine/worker/cmd.go b/engine/worker/cmd.go index 64d3eb3ee3..e80524c375 100644 --- a/engine/worker/cmd.go +++ b/engine/worker/cmd.go @@ -120,7 +120,7 @@ func initFromFlags(cmd *cobra.Command, w *internal.CurrentWorker) { basedir = os.TempDir() } - log.Initialize(&log.Conf{ + log.Initialize(context.Background(), &log.Conf{ Level: FlagString(cmd, flagLogLevel), GraylogProtocol: FlagString(cmd, flagGraylogProtocol), GraylogHost: FlagString(cmd, flagGraylogHost), diff --git a/engine/worker/internal/action/builtin_script_test.go b/engine/worker/internal/action/builtin_script_test.go index 4a89d37273..910e563da9 100644 --- a/engine/worker/internal/action/builtin_script_test.go +++ b/engine/worker/internal/action/builtin_script_test.go @@ -1,6 +1,7 @@ package action import ( + "context" "testing" "github.com/ovh/cds/sdk" @@ -11,7 +12,7 @@ import ( ) func init() { - log.Initialize(&log.Conf{Level: "debug"}) + log.Initialize(context.TODO(), &log.Conf{Level: "debug"}) } func Test_prepareScriptContent(t *testing.T) { diff --git a/engine/worker/internal/action/test_helper.go b/engine/worker/internal/action/test_helper.go index caa324aa8a..1d1b590746 100644 --- a/engine/worker/internal/action/test_helper.go +++ b/engine/worker/internal/action/test_helper.go @@ -1,6 +1,7 @@ package action import ( + "bytes" "context" "fmt" "os" @@ -26,38 +27,39 @@ type TestWorker struct { keyDirectory *afero.BasePathFile client cdsclient.WorkerInterface Params []sdk.Parameter + logBuffer bytes.Buffer } -func (w TestWorker) WorkingDirectory() *afero.BasePathFile { +func (w *TestWorker) WorkingDirectory() *afero.BasePathFile { return w.workingDirectory } -func (w TestWorker) KeyDirectory() *afero.BasePathFile { +func (w *TestWorker) KeyDirectory() *afero.BasePathFile { return w.keyDirectory } -func (w TestWorker) Blur(i interface{}) error { +func (w *TestWorker) Blur(i interface{}) error { w.t.Log("Blur") return nil } -func (w TestWorker) Parameters() []sdk.Parameter { +func (w *TestWorker) Parameters() []sdk.Parameter { return w.Params } -func (w TestWorker) Client() cdsclient.WorkerInterface { +func (w *TestWorker) Client() cdsclient.WorkerInterface { return w.client } -func (_ TestWorker) Environ() []string { +func (_ *TestWorker) Environ() []string { return os.Environ() } -func (_ TestWorker) HTTPPort() int32 { +func (_ *TestWorker) HTTPPort() int32 { return 0 } -func (_ TestWorker) Name() string { +func (_ *TestWorker) Name() string { return "test" } @@ -65,24 +67,26 @@ func (wk TestWorker) BaseDir() afero.Fs { return wk.workspace } -func (_ TestWorker) Register(ctx context.Context) error { +func (_ *TestWorker) Register(ctx context.Context) error { return nil } -func (_ TestWorker) Take(ctx context.Context, job sdk.WorkflowNodeJobRun) error { +func (_ *TestWorker) Take(ctx context.Context, job sdk.WorkflowNodeJobRun) error { return nil } -func (_ TestWorker) ProcessJob(job sdk.WorkflowNodeJobRunData) sdk.Result { +func (_ *TestWorker) ProcessJob(job sdk.WorkflowNodeJobRunData) sdk.Result { return sdk.Result{} } -func (w TestWorker) SendLog(ctx context.Context, level workerruntime.Level, format string) { - w.t.Log("SendLog> [" + string(level) + "] " + format) - +func (w *TestWorker) SendLog(ctx context.Context, level workerruntime.Level, format string) { + s := "SendLog> [" + string(level) + "] " + format + w.t.Log(s) + _, err := w.logBuffer.WriteString(s) + require.NoError(w.t, err) } -func (_ TestWorker) Unregister(ctx context.Context) error { +func (_ *TestWorker) Unregister(ctx context.Context) error { return nil } -func (w TestWorker) InstallKey(key sdk.Variable) (*workerruntime.KeyResponse, error) { +func (w *TestWorker) InstallKey(key sdk.Variable) (*workerruntime.KeyResponse, error) { installedKeyPath := path.Join(w.keyDirectory.Name(), key.Name) err := vcs.CleanAllSSHKeys(w.BaseDir(), w.keyDirectory.Name()) require.NoError(w.t, err) @@ -101,7 +105,7 @@ func (w TestWorker) InstallKey(key sdk.Variable) (*workerruntime.KeyResponse, er }, nil } -func (w TestWorker) InstallKeyTo(key sdk.Variable, destinationPath string) (*workerruntime.KeyResponse, error) { +func (w *TestWorker) InstallKeyTo(key sdk.Variable, destinationPath string) (*workerruntime.KeyResponse, error) { var installedKeyPath string w.t.Logf("InstallKey> destination : %s", destinationPath) @@ -120,7 +124,7 @@ func (w TestWorker) InstallKeyTo(key sdk.Variable, destinationPath string) (*wor var _ workerruntime.Runtime = new(TestWorker) -func SetupTest(t *testing.T) (TestWorker, context.Context) { +func SetupTest(t *testing.T) (*TestWorker, context.Context) { fs := afero.NewOsFs() basedir := "test-" + test.GetTestName(t) + "-" + sdk.RandomString(10) + "-" + fmt.Sprintf("%d", time.Now().Unix()) log.Debug("creating basedir %s", basedir) @@ -151,5 +155,5 @@ func SetupTest(t *testing.T) (TestWorker, context.Context) { ctx = workerruntime.SetKeysDirectory(ctx, wk.keyDirectory) ctx = workerruntime.SetJobID(ctx, 666) - return wk, ctx + return &wk, ctx } diff --git a/engine/worker/internal/run.go b/engine/worker/internal/run.go index cd3ec18387..3ec74f150b 100644 --- a/engine/worker/internal/run.go +++ b/engine/worker/internal/run.go @@ -224,10 +224,11 @@ func (w *CurrentWorker) runAction(ctx context.Context, a sdk.Action, jobID int64 //If the action if a edge of the action tree; run it switch a.Type { case sdk.BuiltinAction: - return w.runBuiltin(ctx, a, secrets) + res := w.runBuiltin(ctx, a, secrets) + return res case sdk.PluginAction: - //Run the plugin - return w.runGRPCPlugin(ctx, a) + res := w.runGRPCPlugin(ctx, a) + return res } // There is is no children actions (action is empty) to do, success ! @@ -512,7 +513,7 @@ func (w *CurrentWorker) ProcessJob(jobInfo sdk.WorkflowNodeJobRunData) (res sdk. ctx = workerruntime.SetStepOrder(ctx, 0) // start logger routine with a large buffer - w.logger.logChan = make(chan sdk.Log, 100000) + w.logger.logChan = make(chan sdk.Log) go func() { if err := w.logProcessor(ctx, jobInfo.NodeJobRun.ID); err != nil { log.Error(ctx, "processJob> Logs processor error: %v", err) diff --git a/engine/worker/internal/start_test.go b/engine/worker/internal/start_test.go index cf4f2d262b..d78f636576 100644 --- a/engine/worker/internal/start_test.go +++ b/engine/worker/internal/start_test.go @@ -25,7 +25,7 @@ import ( ) func init() { - log.Initialize(&log.Conf{Level: "debug"}) + log.Initialize(context.TODO(), &log.Conf{Level: "debug"}) } func TestStartWorkerWithABookedJob(t *testing.T) { diff --git a/engine/worker/internal/take.go b/engine/worker/internal/take.go index 9e110e5b3e..f48ac99f73 100644 --- a/engine/worker/internal/take.go +++ b/engine/worker/internal/take.go @@ -46,12 +46,14 @@ func (w *CurrentWorker) Take(ctx context.Context, job sdk.WorkflowNodeJobRun) er } if info.GelfServiceAddr != "" { - log.Info(ctx, "Setup step logger") - logger, err := log.New(info.GelfServiceAddr) + log.Info(ctx, "Setup step logger %s", info.GelfServiceAddr) + l, h, err := log.New(ctx, info.GelfServiceAddr) if err != nil { return sdk.WithStack(err) } - w.logger.stepLogger = logger + w.logger.gelfLogger = new(logger) + w.logger.gelfLogger.logger = l + w.logger.gelfLogger.hook = h } start := time.Now() diff --git a/engine/worker/internal/types.go b/engine/worker/internal/types.go index cae040a84e..cc998f525d 100644 --- a/engine/worker/internal/types.go +++ b/engine/worker/internal/types.go @@ -18,6 +18,7 @@ import ( "github.com/ovh/cds/sdk/cdsclient" "github.com/ovh/cds/sdk/jws" "github.com/ovh/cds/sdk/log" + loghook "github.com/ovh/cds/sdk/log/hook" ) const ( @@ -28,6 +29,11 @@ const ( CDSApiUrl = "CDS_API_URL" ) +type logger struct { + hook *loghook.Hook + logger *logrus.Logger +} + type CurrentWorker struct { id string model sdk.Model @@ -36,7 +42,7 @@ type CurrentWorker struct { logger struct { logChan chan sdk.Log llist *list.List - stepLogger *logrus.Logger + gelfLogger *logger } httpPort int32 register struct { @@ -96,7 +102,7 @@ func (wk *CurrentWorker) SendLog(ctx context.Context, level workerruntime.Level, jobID, _ := workerruntime.JobID(ctx) stepOrder, err := workerruntime.StepOrder(ctx) - if wk.logger.stepLogger == nil { + if wk.logger.gelfLogger == nil { if !strings.HasSuffix(s, "\n") { s += "\n" } @@ -134,8 +140,8 @@ func (wk *CurrentWorker) SendLog(ctx context.Context, level workerruntime.Level, if err != nil { log.Error(ctx, "unable to sign logs: %v", err) } - wk.logger.stepLogger.WithField(log.ExtraFieldSignature, signature).Log(logLevel, s) - + wk.logger.gelfLogger.logger.WithField(log.ExtraFieldSignature, signature).Log(logLevel, s) + wk.logger.gelfLogger.hook.Flush() } func (wk *CurrentWorker) Name() string { diff --git a/go.mod b/go.mod index 93e337ceff..80d0eafac1 100644 --- a/go.mod +++ b/go.mod @@ -93,7 +93,6 @@ require ( github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/itsjamie/gin-cors v0.0.0-20160420130702-97b4a9da7933 github.com/jefferai/jsonx v0.0.0-20160721235117-9cc31c3135ee // indirect - github.com/jstemmer/go-junit-report v0.9.1 // indirect github.com/jtolds/gls v4.2.1+incompatible // indirect github.com/juju/errors v0.0.0-20190207033735-e65537c515d7 // indirect github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect @@ -103,10 +102,10 @@ require ( github.com/keybase/go-crypto v0.0.0-20181127160227-255a5089e85a github.com/keybase/go-keychain v0.0.0-20190828020956-aa639f275ae1 github.com/keybase/go.dbus v0.0.0-20190710215703-a33a09c8a604 - github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/kr/pty v1.1.8 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/lib/pq v1.0.0 + github.com/lytics/logrus v0.0.0-20170528191427-4389a17ed024 // indirect github.com/magiconair/properties v1.8.1 // indirect github.com/mailru/easyjson v0.0.0-20171120080333-32fa128f234d // indirect github.com/marstr/guid v1.1.0 // indirect @@ -161,7 +160,7 @@ require ( github.com/sethgrid/pester v0.0.0-20171127025028-760f8913c048 // indirect github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197 github.com/shirou/gopsutil v0.0.0-20170406131756-e49a95f3d5f8 - github.com/sirupsen/logrus v1.4.2 + github.com/sirupsen/logrus v1.6.0 github.com/smartystreets/assertions v0.0.0-20170213163019-15adfb6b24e2 // indirect github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a // indirect github.com/spf13/afero v1.2.2 @@ -181,7 +180,6 @@ require ( github.com/xanzy/go-gitlab v0.15.0 github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/yesnault/go-toml v0.0.0-20191205182532-f5ef6cee7945 - github.com/yesnault/gorp v2.0.0+incompatible // indirect github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed github.com/yuin/gopher-lua v0.0.0-20170901023928-8c2befcd3908 github.com/ziutek/mymysql v1.5.4 // indirect @@ -211,7 +209,7 @@ require ( gopkg.in/stomp.v1 v1.0.1 // indirect gopkg.in/vmihailenco/msgpack.v2 v2.9.1 // indirect gopkg.in/yaml.v2 v2.2.4 - gotest.tools v2.1.0+incompatible + gotest.tools v2.1.0+incompatible // indirect k8s.io/api v0.0.0-20181204000039-89a74a8d264d k8s.io/apimachinery v0.0.0-20190223094358-dcb391cde5ca k8s.io/client-go v10.0.0+incompatible diff --git a/go.sum b/go.sum index 2b0e2e19a4..79448c2203 100644 --- a/go.sum +++ b/go.sum @@ -138,8 +138,6 @@ github.com/frankban/quicktest v1.6.0 h1:Cd62nl66vQsx8Uv1t8M0eICyxIwZG7MxiAOrdnnU github.com/frankban/quicktest v1.6.0/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o= github.com/fsamin/go-dump v1.0.9 h1:3MAneAJLnGfKTJtFEAdgrD+QqqK2Hwj7EJUQMQZcDls= github.com/fsamin/go-dump v1.0.9/go.mod h1:ZgKd2aOXAFFbbFuUgvQhu7mwTlI3d3qnTICMWdvAa9o= -github.com/fsamin/go-repo v0.1.6 h1:2ZEljhqi6Iscwe0lC2nXsI4b5AxOToZ+kVfuItSoQsQ= -github.com/fsamin/go-repo v0.1.6/go.mod h1:JRLbo6sPXvAwwGs5RgifFk1pXiefeGf0hyHifEg1Vw4= github.com/fsamin/go-repo v0.1.7 h1:cQ+ALKxDzxuNAqbvn8gT7yQSb9iO7ax15QgTGLfFaU8= github.com/fsamin/go-repo v0.1.7/go.mod h1:JRLbo6sPXvAwwGs5RgifFk1pXiefeGf0hyHifEg1Vw4= github.com/fsamin/go-shredder v0.0.0-20180118184739-b2488aedb5be h1:UhjSvwE1gxUYfekK9BXZ/LL55we9Avg+2Pt0PIlMYCk= @@ -298,8 +296,6 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/juju/errors v0.0.0-20190207033735-e65537c515d7 h1:dMIPRDg6gi7CUp0Kj2+HxqJ5kTr1iAdzsXYIrLCNSmU= @@ -318,8 +314,8 @@ github.com/keybase/go.dbus v0.0.0-20190710215703-a33a09c8a604/go.mod h1:a8clEhrr github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -500,8 +496,8 @@ github.com/shirou/gopsutil v0.0.0-20170406131756-e49a95f3d5f8 h1:05R1OwSk31dkzqf github.com/shirou/gopsutil v0.0.0-20170406131756-e49a95f3d5f8/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/smartystreets/assertions v0.0.0-20170213163019-15adfb6b24e2 h1:/pp2hwWaiQp5Y2z2kQI27abzNecMhv0iVd8brrY/jP0= github.com/smartystreets/assertions v0.0.0-20170213163019-15adfb6b24e2/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a h1:JSvGDIbmil4Ui/dDdFBExb7/cmkNjyX5F97oglmvCDo= @@ -565,8 +561,6 @@ github.com/yesnault/go-keychain v0.0.0-20190829085436-f78f7ae28786 h1:3i+IgAiigX github.com/yesnault/go-keychain v0.0.0-20190829085436-f78f7ae28786/go.mod h1:EzotOW21xnO2Lld4dB8qr2bSnzi3nGtE9FG33n/y2Q8= github.com/yesnault/go-toml v0.0.0-20191205182532-f5ef6cee7945 h1:icS0gqYJLvPFpni3gxPml7gCSdCcJx72RrbkVgmvw80= github.com/yesnault/go-toml v0.0.0-20191205182532-f5ef6cee7945/go.mod h1:SsMrIuedaKvK8GekjwjVv8gMnHNAuvoINpKCARzdsEQ= -github.com/yesnault/gorp v2.0.0+incompatible h1:4pwtvWrXQTAgGVnzAB0X5jX/mWRQEa8zmcdNT5U8jyg= -github.com/yesnault/gorp v2.0.0+incompatible/go.mod h1:7nhqtxBPZoPXx86SqUzP/OFLd8prnhkydPk51uJthQc= github.com/yesnault/gorp v2.0.1-0.20200325154225-2dc6d8c2da37+incompatible h1:8M+L4IKModOdc0ZsH0kHJiqZ7CmWF4yH8yy4InZxKyY= github.com/yesnault/gorp v2.0.1-0.20200325154225-2dc6d8c2da37+incompatible/go.mod h1:7nhqtxBPZoPXx86SqUzP/OFLd8prnhkydPk51uJthQc= github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed h1:I1vcLHWU9m30rA90rMrKPu0eD3NDA4FBlkB8WMaDyUw= diff --git a/sdk/log/log.go b/sdk/log/log.go index 617830653e..dad041dfbc 100644 --- a/sdk/log/log.go +++ b/sdk/log/log.go @@ -25,7 +25,6 @@ type Conf struct { GraylogFieldCDSVersion string GraylogFieldCDSOS string GraylogFieldCDSArch string - Ctx context.Context } const ( @@ -69,7 +68,7 @@ func logWithLogger(level string, fields log.Fields, format string, values ...int } // Initialize init log level -func Initialize(conf *Conf) { +func Initialize(ctx context.Context, conf *Conf) { switch conf.Level { case "debug": log.SetLevel(log.DebugLevel) @@ -135,12 +134,9 @@ func Initialize(conf *Conf) { } } - if conf.Ctx == nil { - conf.Ctx = context.Background() - } go func() { - <-conf.Ctx.Done() - log.Info(conf.Ctx, "Draining logs") + <-ctx.Done() + Info(ctx, "Draining logs...") if hook != nil { hook.Flush() } @@ -261,7 +257,7 @@ type SignatureService struct { WorkerName string } -func New(logServerAddr string) (*log.Logger, error) { +func New(ctx context.Context, logServerAddr string) (*log.Logger, *loghook.Hook, error) { newLogger := log.New() graylogcfg := &loghook.Config{ Addr: logServerAddr, @@ -270,8 +266,14 @@ func New(logServerAddr string) (*log.Logger, error) { extra := map[string]interface{}{} hook, err := loghook.NewHook(graylogcfg, extra) if err != nil { - return nil, fmt.Errorf("unable to add hook: %v", err) + return nil, nil, fmt.Errorf("unable to add hook: %v", err) } newLogger.AddHook(hook) - return newLogger, nil + + go func() { + <-ctx.Done() + hook.Flush() + }() + + return newLogger, hook, nil } diff --git a/ui/src/app/views/workflow/run/node/pipeline/step/step.log.html b/ui/src/app/views/workflow/run/node/pipeline/step/step.log.html index effeacddd2..8ef928be0c 100644 --- a/ui/src/app/views/workflow/run/node/pipeline/step/step.log.html +++ b/ui/src/app/views/workflow/run/node/pipeline/step/step.log.html @@ -45,11 +45,10 @@
{{logLine.lineNumber}} |