mirror of
https://github.com/containerd/containerd.git
synced 2026-08-12 22:16:27 +00:00
go.{mod,sum}: bump NRI to v0.8.0, re-vendor.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
This commit is contained in:
6
go.mod
6
go.mod
@@ -20,9 +20,9 @@ require (
|
||||
github.com/containerd/go-runc v1.0.0
|
||||
github.com/containerd/imgcrypt v1.1.8
|
||||
github.com/containerd/log v0.1.0
|
||||
github.com/containerd/nri v0.6.1
|
||||
github.com/containerd/nri v0.8.0
|
||||
github.com/containerd/platforms v0.2.1
|
||||
github.com/containerd/ttrpc v1.2.5
|
||||
github.com/containerd/ttrpc v1.2.7
|
||||
github.com/containerd/typeurl/v2 v2.1.1
|
||||
github.com/containerd/zfs v1.1.0
|
||||
github.com/containernetworking/cni v1.1.2
|
||||
@@ -101,7 +101,7 @@ require (
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.3 // indirect
|
||||
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
|
||||
github.com/go-logr/logr v1.3.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
|
||||
27
go.sum
27
go.sum
@@ -194,8 +194,8 @@ github.com/containerd/imgcrypt v1.1.8/go.mod h1:x6QvFIkMyO2qGIY2zXc88ivEzcbgvLdW
|
||||
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
|
||||
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
|
||||
github.com/containerd/nri v0.0.0-20201007170849-eb1350a75164/go.mod h1:+2wGSDGFYfE5+So4M5syatU0N0f0LbWpuqyMi4/BE8c=
|
||||
github.com/containerd/nri v0.6.1 h1:xSQ6elnQ4Ynidm9u49ARK9wRKHs80HCUI+bkXOxV4mA=
|
||||
github.com/containerd/nri v0.6.1/go.mod h1:7+sX3wNx+LR7RzhjnJiUkFDhn18P5Bg/0VnJ/uXpRJM=
|
||||
github.com/containerd/nri v0.8.0 h1:n1S753B9lX8RFrHYeSgwVvS1yaUcHjxbB+f+xzEncRI=
|
||||
github.com/containerd/nri v0.8.0/go.mod h1:uSkgBrCdEtAiEz4vnrq8gmAC4EnVAM5Klt0OuK5rZYQ=
|
||||
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
|
||||
github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw=
|
||||
github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o=
|
||||
@@ -203,8 +203,8 @@ github.com/containerd/ttrpc v0.0.0-20190828172938-92c8520ef9f8/go.mod h1:PvCDdDG
|
||||
github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c/go.mod h1:LPm1u0xBw8r8NOKoOdNMeVHSawSsltak+Ihv+etqsE8=
|
||||
github.com/containerd/ttrpc v1.0.1/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8httJEt98Y=
|
||||
github.com/containerd/ttrpc v1.0.2/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8httJEt98Y=
|
||||
github.com/containerd/ttrpc v1.2.5 h1:IFckT1EFQoFBMG4c3sMdT8EP3/aKfumK1msY+Ze4oLU=
|
||||
github.com/containerd/ttrpc v1.2.5/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o=
|
||||
github.com/containerd/ttrpc v1.2.7 h1:qIrroQvuOL9HQ1X6KHe2ohc7p+HP/0VE6XPU7elJRqQ=
|
||||
github.com/containerd/ttrpc v1.2.7/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o=
|
||||
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
|
||||
github.com/containerd/typeurl v0.0.0-20190911142611-5eb25027c9fd/go.mod h1:GeKYzf2pQcqv7tJ0AoCuuhtnqhva5LNU3U+OyKxxJpk=
|
||||
github.com/containerd/typeurl v1.0.1/go.mod h1:TB1hUtrpaiO88KEK56ijojHS1+NeF0izUACaJW2mdXg=
|
||||
@@ -321,8 +321,8 @@ github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7
|
||||
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
|
||||
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
|
||||
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
|
||||
@@ -339,7 +339,10 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh
|
||||
github.com/go-openapi/swag v0.19.14 h1:gm3vOOXfiuw5i9p5N9xJvfjvuofpyvLA9Wr6QfK5Fng=
|
||||
github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
|
||||
github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
|
||||
github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
|
||||
github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
|
||||
@@ -422,6 +425,8 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf
|
||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg=
|
||||
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
@@ -580,16 +585,16 @@ github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vv
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
||||
github.com/onsi/ginkgo/v2 v2.5.0 h1:TRtrvv2vdQqzkwrQ1ke6vtXf7IK34RBUJafIy1wMwls=
|
||||
github.com/onsi/ginkgo/v2 v2.5.0/go.mod h1:Luc4sArBICYCS8THh8v3i3i5CuSZO+RaQRaJoeNwomw=
|
||||
github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0=
|
||||
github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA=
|
||||
github.com/onsi/gomega v0.0.0-20151007035656-2152b45fa28a/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
github.com/onsi/gomega v1.24.2 h1:J/tulyYK6JwBldPViHJReihxxZ+22FHs0piGjQAvoUE=
|
||||
github.com/onsi/gomega v1.24.2/go.mod h1:gs3J10IS7Z7r7eXRoNJIrNqU4ToQukCJhFtKrWgHWnk=
|
||||
github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os=
|
||||
github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo=
|
||||
github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||
@@ -1089,6 +1094,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
@@ -13,7 +13,7 @@ require (
|
||||
github.com/containerd/go-runc v1.0.0
|
||||
github.com/containerd/log v0.1.0
|
||||
github.com/containerd/platforms v0.2.1
|
||||
github.com/containerd/ttrpc v1.2.5
|
||||
github.com/containerd/ttrpc v1.2.7
|
||||
github.com/containerd/typeurl/v2 v2.1.1
|
||||
github.com/google/uuid v1.4.0
|
||||
github.com/opencontainers/go-digest v1.0.0
|
||||
@@ -40,7 +40,7 @@ require (
|
||||
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.3 // indirect
|
||||
github.com/go-logr/logr v1.3.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
|
||||
@@ -1258,9 +1258,15 @@ github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
|
||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M=
|
||||
github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E=
|
||||
github.com/chromedp/cdproto v0.0.0-20230802225258-3cf4e6d46a89/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs=
|
||||
github.com/chromedp/chromedp v0.9.2/go.mod h1:LkSXJKONWTCHAfQasKFUZI+mxqS4tZqhmtGzzhLsnLs=
|
||||
github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
|
||||
github.com/cilium/ebpf v0.0.0-20200702112145-1c8d4c9ef775/go.mod h1:7cR51M8ViRLIdUjrmSXlK9pkrsDlLHbO8jiB8X8JnOc=
|
||||
github.com/cilium/ebpf v0.4.0/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs=
|
||||
github.com/cilium/ebpf v0.6.2/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs=
|
||||
@@ -1320,7 +1326,7 @@ github.com/containerd/go-runc v1.0.0/go.mod h1:cNU0ZbCgCQVZK4lgG3P+9tn9/PaJNmoDX
|
||||
github.com/containerd/imgcrypt v1.1.8/go.mod h1:x6QvFIkMyO2qGIY2zXc88ivEzcbgvLdWjoZyGqDap5U=
|
||||
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
|
||||
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
|
||||
github.com/containerd/nri v0.6.1/go.mod h1:7+sX3wNx+LR7RzhjnJiUkFDhn18P5Bg/0VnJ/uXpRJM=
|
||||
github.com/containerd/nri v0.8.0/go.mod h1:uSkgBrCdEtAiEz4vnrq8gmAC4EnVAM5Klt0OuK5rZYQ=
|
||||
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
|
||||
github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw=
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.4.1/go.mod h1:x7Q9dg9QYb4+ELgxmo4gBUeJB0tl5dqH1Sdz0nJU1QM=
|
||||
@@ -1328,9 +1334,10 @@ github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNA
|
||||
github.com/containerd/ttrpc v1.0.2/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8httJEt98Y=
|
||||
github.com/containerd/ttrpc v1.1.0/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Evzy5KFQpQ=
|
||||
github.com/containerd/ttrpc v1.1.2/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Evzy5KFQpQ=
|
||||
github.com/containerd/ttrpc v1.2.3/go.mod h1:ieWsXucbb8Mj9PH0rXCw1i8IunRbbAiDkpXkbfflWBM=
|
||||
github.com/containerd/ttrpc v1.2.5 h1:IFckT1EFQoFBMG4c3sMdT8EP3/aKfumK1msY+Ze4oLU=
|
||||
github.com/containerd/ttrpc v1.2.5/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o=
|
||||
github.com/containerd/ttrpc v1.2.6-0.20240827082320-b5cd6e4b3287/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o=
|
||||
github.com/containerd/ttrpc v1.2.7 h1:qIrroQvuOL9HQ1X6KHe2ohc7p+HP/0VE6XPU7elJRqQ=
|
||||
github.com/containerd/ttrpc v1.2.7/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o=
|
||||
github.com/containerd/typeurl v1.0.1/go.mod h1:TB1hUtrpaiO88KEK56ijojHS1+NeF0izUACaJW2mdXg=
|
||||
github.com/containerd/typeurl v1.0.2/go.mod h1:9trJWW2sRlGub4wZJRTW83VtbOLS6hwcDZXTn6oPz9s=
|
||||
github.com/containerd/typeurl/v2 v2.1.1 h1:3Q4Pt7i8nYwy2KmQWIw2+1hTvwTE/6w9FqcttATPO/4=
|
||||
@@ -1489,8 +1496,10 @@ github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
|
||||
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4=
|
||||
@@ -1512,7 +1521,12 @@ github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhO
|
||||
github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
|
||||
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
||||
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
|
||||
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY=
|
||||
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
@@ -1624,6 +1638,7 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLe
|
||||
github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/s2a-go v0.1.0/go.mod h1:OJpEgntRZo8ugHpF9hkoLJbS5dSI20XZeXJ9JVywLlM=
|
||||
github.com/google/s2a-go v0.1.3/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A=
|
||||
@@ -1702,6 +1717,7 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
|
||||
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
|
||||
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
@@ -1758,6 +1774,7 @@ github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs=
|
||||
github.com/lestrrat-go/backoff/v2 v2.0.8/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y=
|
||||
github.com/lestrrat-go/blackmagic v1.0.0/go.mod h1:TNgH//0vYSs8VXDCfkZLgIrVTTXQELZffUV0tz3MtdQ=
|
||||
github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E=
|
||||
@@ -1776,6 +1793,7 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN
|
||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
||||
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
@@ -1862,6 +1880,19 @@ github.com/onsi/ginkgo/v2 v2.3.0/go.mod h1:Eew0uilEqZmIEZr8JrvYlvOM7Rr6xzTmMV8Ay
|
||||
github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo=
|
||||
github.com/onsi/ginkgo/v2 v2.5.0/go.mod h1:Luc4sArBICYCS8THh8v3i3i5CuSZO+RaQRaJoeNwomw=
|
||||
github.com/onsi/ginkgo/v2 v2.6.1/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo=
|
||||
github.com/onsi/ginkgo/v2 v2.7.0/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo=
|
||||
github.com/onsi/ginkgo/v2 v2.8.1/go.mod h1:N1/NbDngAFcSLdyZ+/aYTYGSlq9qMCS/cNKGJjy+csc=
|
||||
github.com/onsi/ginkgo/v2 v2.9.0/go.mod h1:4xkjoL/tZv4SMWeww56BU5kAt19mVB47gTWxmrTcxyk=
|
||||
github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo=
|
||||
github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts=
|
||||
github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k=
|
||||
github.com/onsi/ginkgo/v2 v2.9.7/go.mod h1:cxrmXWykAwTwhQsJOPfdIDiJ+l2RYq7U8hFU+M/1uw0=
|
||||
github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM=
|
||||
github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o=
|
||||
github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
|
||||
github.com/onsi/ginkgo/v2 v2.17.2/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc=
|
||||
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
|
||||
github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA=
|
||||
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
@@ -1877,6 +1908,18 @@ github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2
|
||||
github.com/onsi/gomega v1.24.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg=
|
||||
github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM=
|
||||
github.com/onsi/gomega v1.24.2/go.mod h1:gs3J10IS7Z7r7eXRoNJIrNqU4ToQukCJhFtKrWgHWnk=
|
||||
github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
|
||||
github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfadcIAw=
|
||||
github.com/onsi/gomega v1.27.3/go.mod h1:5vG284IBtfDAmDyrK+eGyZmUgUlmi+Wngqo557cZ6Gw=
|
||||
github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ=
|
||||
github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
|
||||
github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4=
|
||||
github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ=
|
||||
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
|
||||
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
|
||||
github.com/onsi/gomega v1.33.0/go.mod h1:+925n5YtiFsLzzafLUHzVMBpvvRAzrydIBiSIxjX3wY=
|
||||
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
|
||||
github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo=
|
||||
github.com/open-policy-agent/opa v0.42.2/go.mod h1:MrmoTi/BsKWT58kXlVayBb+rYVeaMwuBm3nYAN3923s=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
@@ -1908,6 +1951,7 @@ github.com/opencontainers/selinux v1.10.1/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuh
|
||||
github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaLpt7tQ7oU=
|
||||
github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
|
||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
|
||||
@@ -2207,8 +2251,10 @@ golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98y
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
|
||||
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@@ -2273,6 +2319,7 @@ golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -2357,8 +2404,10 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@@ -2524,6 +2573,7 @@ golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220405210540-1e041c57c461/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@@ -2556,9 +2606,12 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
@@ -2579,8 +2632,10 @@ golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
||||
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
|
||||
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
|
||||
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@@ -2699,9 +2754,14 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
|
||||
golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4=
|
||||
golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
|
||||
golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
|
||||
golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM=
|
||||
golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8=
|
||||
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
|
||||
golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=
|
||||
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -3066,6 +3126,7 @@ google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw
|
||||
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
|
||||
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
|
||||
3
vendor/github.com/containerd/nri/.codespellrc
generated
vendored
Normal file
3
vendor/github.com/containerd/nri/.codespellrc
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[codespell]
|
||||
skip = .git,*.pdf,*.svg,go.sum,go.mod
|
||||
ignore-words-list = clos
|
||||
3
vendor/github.com/containerd/nri/.golangci.yml
generated
vendored
3
vendor/github.com/containerd/nri/.golangci.yml
generated
vendored
@@ -36,6 +36,9 @@ issues:
|
||||
linters:
|
||||
- govet
|
||||
text: "copylocks: .*protobuf/internal/impl.MessageState.*"
|
||||
# We dot-import ginkgo and gomega in some tests. Silence any related errors.
|
||||
- path: 'pkg/adaptation|pkg/runtime-tools/generate|pkg/net/multiplex'
|
||||
text: "dot-imports:"
|
||||
|
||||
run:
|
||||
timeout: 2m
|
||||
|
||||
14
vendor/github.com/containerd/nri/Makefile
generated
vendored
14
vendor/github.com/containerd/nri/Makefile
generated
vendored
@@ -124,7 +124,7 @@ $(BIN_PATH)/template: $(wildcard plugins/template/*.go)
|
||||
|
||||
test-gopkgs: ginkgo-tests test-ulimits
|
||||
|
||||
SKIPPED_PKGS="ulimit-adjuster"
|
||||
SKIPPED_PKGS="ulimit-adjuster,device-injector"
|
||||
|
||||
ginkgo-tests:
|
||||
$(Q)$(GINKGO) run \
|
||||
@@ -137,12 +137,15 @@ ginkgo-tests:
|
||||
--coverprofile coverprofile \
|
||||
--succinct \
|
||||
--skip-package $(SKIPPED_PKGS) \
|
||||
-r .; \
|
||||
-r && \
|
||||
$(GO_CMD) tool cover -html=$(COVERAGE_PATH)/coverprofile -o $(COVERAGE_PATH)/coverage.html
|
||||
|
||||
test-ulimits:
|
||||
$(Q)cd ./plugins/ulimit-adjuster && $(GO_TEST) -v
|
||||
|
||||
test-device-injector:
|
||||
$(Q)cd ./plugins/device-injector && $(GO_TEST) -v
|
||||
|
||||
codecov: SHELL := $(shell which bash)
|
||||
codecov:
|
||||
bash <(curl -s https://codecov.io/bash) -f $(COVERAGE_PATH)/coverprofile
|
||||
@@ -163,6 +166,13 @@ vet:
|
||||
golangci-lint:
|
||||
$(Q)$(GOLANG_CILINT) run
|
||||
|
||||
validate-repo-no-changes:
|
||||
$(Q)test -z "$$(git status --short | tee /dev/stderr)" || { \
|
||||
echo "Repository has changes."; \
|
||||
echo "Please make sure to commit all changes, including generated files."; \
|
||||
exit 1; \
|
||||
}
|
||||
|
||||
#
|
||||
# proto generation targets
|
||||
#
|
||||
|
||||
3
vendor/github.com/containerd/nri/README.md
generated
vendored
3
vendor/github.com/containerd/nri/README.md
generated
vendored
@@ -297,7 +297,7 @@ apply NRI responses to containers.
|
||||
|
||||
The plugin stub hides many of the low-level details of implementing an NRI
|
||||
plugin. It takes care of connection establishment, plugin registration,
|
||||
configuration, and event subscription. All [sample plugins](pkg/plugins)
|
||||
configuration, and event subscription. All [sample plugins](plugins)
|
||||
are implemented using the stub. Any of these can be used as a tutorial on
|
||||
how the stub library should be used.
|
||||
|
||||
@@ -308,6 +308,7 @@ The following sample plugins exist for NRI:
|
||||
- [logger](plugins/logger)
|
||||
- [differ](plugins/differ)
|
||||
- [device injector](plugins/device-injector)
|
||||
- [network device injector](plugins/network-device-injector)
|
||||
- [OCI hook injector](plugins/hook-injector)
|
||||
- [ulimit adjuster](plugins/ulimit-adjuster)
|
||||
- [NRI v0.1.0 plugin adapter](plugins/v010-adapter)
|
||||
|
||||
81
vendor/github.com/containerd/nri/pkg/adaptation/adaptation.go
generated
vendored
81
vendor/github.com/containerd/nri/pkg/adaptation/adaptation.go
generated
vendored
@@ -65,6 +65,7 @@ type Adaptation struct {
|
||||
serverOpts []ttrpc.ServerOpt
|
||||
listener net.Listener
|
||||
plugins []*plugin
|
||||
syncLock sync.RWMutex
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -135,6 +136,7 @@ func New(name, version string, syncFn SyncFn, updateFn UpdateFn, opts ...Option)
|
||||
pluginPath: DefaultPluginPath,
|
||||
dropinPath: DefaultPluginConfigPath,
|
||||
socketPath: DefaultSocketPath,
|
||||
syncLock: sync.RWMutex{},
|
||||
}
|
||||
|
||||
for _, o := range opts {
|
||||
@@ -336,25 +338,48 @@ func (r *Adaptation) startPlugins() (retErr error) {
|
||||
}()
|
||||
|
||||
for i, name := range names {
|
||||
log.Infof(noCtx, "starting plugin %q...", name)
|
||||
log.Infof(noCtx, "starting pre-installed NRI plugin %q...", name)
|
||||
|
||||
id := ids[i]
|
||||
|
||||
p, err := r.newLaunchedPlugin(r.pluginPath, id, name, configs[i])
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to start NRI plugin %q: %w", name, err)
|
||||
log.Warnf(noCtx, "failed to initialize pre-installed NRI plugin %q: %v", name, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if err := p.start(r.name, r.version); err != nil {
|
||||
return err
|
||||
log.Warnf(noCtx, "failed to start pre-installed NRI plugin %q: %v", name, err)
|
||||
continue
|
||||
}
|
||||
|
||||
plugins = append(plugins, p)
|
||||
}
|
||||
|
||||
// Although the error returned by syncPlugins may not be nil, r.syncFn could still ignores this error and returns a nil error.
|
||||
// We need to make sure that the plugins are successfully synchronized in the `plugins`
|
||||
syncPlugins := func(ctx context.Context, pods []*PodSandbox, containers []*Container) (updates []*ContainerUpdate, err error) {
|
||||
startedPlugins := plugins
|
||||
plugins = make([]*plugin, 0, len(plugins))
|
||||
for _, plugin := range startedPlugins {
|
||||
us, err := plugin.synchronize(ctx, pods, containers)
|
||||
if err != nil {
|
||||
plugin.stop()
|
||||
log.Warnf(noCtx, "failed to synchronize pre-installed NRI plugin %q: %v", plugin.name(), err)
|
||||
continue
|
||||
}
|
||||
|
||||
plugins = append(plugins, plugin)
|
||||
updates = append(updates, us...)
|
||||
log.Infof(noCtx, "pre-installed NRI plugin %q synchronization success", plugin.name())
|
||||
}
|
||||
return updates, nil
|
||||
}
|
||||
if err := r.syncFn(noCtx, syncPlugins); err != nil {
|
||||
return fmt.Errorf("failed to synchronize pre-installed NRI Plugins: %w", err)
|
||||
}
|
||||
|
||||
r.plugins = plugins
|
||||
r.sortPlugins()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -369,12 +394,22 @@ func (r *Adaptation) stopPlugins() {
|
||||
}
|
||||
|
||||
func (r *Adaptation) removeClosedPlugins() {
|
||||
active := []*plugin{}
|
||||
var active, closed []*plugin
|
||||
for _, p := range r.plugins {
|
||||
if !p.isClosed() {
|
||||
if p.isClosed() {
|
||||
closed = append(closed, p)
|
||||
} else {
|
||||
active = append(active, p)
|
||||
}
|
||||
}
|
||||
|
||||
if len(closed) != 0 {
|
||||
go func() {
|
||||
for _, plugin := range closed {
|
||||
plugin.stop()
|
||||
}
|
||||
}()
|
||||
}
|
||||
r.plugins = active
|
||||
}
|
||||
|
||||
@@ -431,6 +466,8 @@ func (r *Adaptation) acceptPluginConnections(l net.Listener) error {
|
||||
continue
|
||||
}
|
||||
|
||||
r.requestPluginSync()
|
||||
|
||||
err = r.syncFn(ctx, p.synchronize)
|
||||
if err != nil {
|
||||
log.Infof(ctx, "failed to synchronize plugin: %v", err)
|
||||
@@ -439,9 +476,10 @@ func (r *Adaptation) acceptPluginConnections(l net.Listener) error {
|
||||
r.plugins = append(r.plugins, p)
|
||||
r.sortPlugins()
|
||||
r.Unlock()
|
||||
log.Infof(ctx, "plugin %q connected and synchronized", p.name())
|
||||
}
|
||||
|
||||
log.Infof(ctx, "plugin %q connected", p.name())
|
||||
r.finishedPluginSync()
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -512,3 +550,30 @@ func (r *Adaptation) sortPlugins() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Adaptation) requestPluginSync() {
|
||||
r.syncLock.Lock()
|
||||
}
|
||||
|
||||
func (r *Adaptation) finishedPluginSync() {
|
||||
r.syncLock.Unlock()
|
||||
}
|
||||
|
||||
type PluginSyncBlock struct {
|
||||
r *Adaptation
|
||||
}
|
||||
|
||||
// BlockPluginSync blocks plugins from being synchronized/fully registered.
|
||||
func (r *Adaptation) BlockPluginSync() *PluginSyncBlock {
|
||||
r.syncLock.RLock()
|
||||
return &PluginSyncBlock{r: r}
|
||||
}
|
||||
|
||||
// Unblock a plugin sync. block put in place by BlockPluginSync. Safe to call
|
||||
// multiple times but only from a single goroutine.
|
||||
func (b *PluginSyncBlock) Unblock() {
|
||||
if b != nil && b.r != nil {
|
||||
b.r.syncLock.RUnlock()
|
||||
b.r = nil
|
||||
}
|
||||
}
|
||||
|
||||
1
vendor/github.com/containerd/nri/pkg/adaptation/api.go
generated
vendored
1
vendor/github.com/containerd/nri/pkg/adaptation/api.go
generated
vendored
@@ -78,6 +78,7 @@ type (
|
||||
LinuxMemory = api.LinuxMemory
|
||||
LinuxDevice = api.LinuxDevice
|
||||
LinuxDeviceCgroup = api.LinuxDeviceCgroup
|
||||
CDIDevice = api.CDIDevice
|
||||
HugepageLimit = api.HugepageLimit
|
||||
Hooks = api.Hooks
|
||||
Hook = api.Hook
|
||||
|
||||
113
vendor/github.com/containerd/nri/pkg/adaptation/plugin.go
generated
vendored
113
vendor/github.com/containerd/nri/pkg/adaptation/plugin.go
generated
vendored
@@ -33,13 +33,15 @@ import (
|
||||
"github.com/containerd/nri/pkg/net"
|
||||
"github.com/containerd/nri/pkg/net/multiplex"
|
||||
"github.com/containerd/ttrpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultPluginRegistrationTimeout is the default timeout for plugin registration.
|
||||
DefaultPluginRegistrationTimeout = 5 * time.Second
|
||||
DefaultPluginRegistrationTimeout = api.DefaultPluginRegistrationTimeout
|
||||
// DefaultPluginRequestTimeout is the default timeout for plugins to handle a request.
|
||||
DefaultPluginRequestTimeout = 2 * time.Second
|
||||
DefaultPluginRequestTimeout = api.DefaultPluginRequestTimeout
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -384,9 +386,11 @@ func (p *plugin) configure(ctx context.Context, name, version, config string) er
|
||||
defer cancel()
|
||||
|
||||
rpl, err := p.stub.Configure(ctx, &ConfigureRequest{
|
||||
Config: config,
|
||||
RuntimeName: name,
|
||||
RuntimeVersion: version,
|
||||
Config: config,
|
||||
RuntimeName: name,
|
||||
RuntimeVersion: version,
|
||||
RegistrationTimeout: getPluginRegistrationTimeout().Milliseconds(),
|
||||
RequestTimeout: getPluginRequestTimeout().Milliseconds(),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to configure plugin: %w", err)
|
||||
@@ -412,18 +416,101 @@ func (p *plugin) synchronize(ctx context.Context, pods []*PodSandbox, containers
|
||||
ctx, cancel := context.WithTimeout(ctx, getPluginRequestTimeout())
|
||||
defer cancel()
|
||||
|
||||
req := &SynchronizeRequest{
|
||||
Pods: pods,
|
||||
Containers: containers,
|
||||
}
|
||||
rpl, err := p.stub.Synchronize(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var (
|
||||
podsToSend = pods
|
||||
ctrsToSend = containers
|
||||
podsPerMsg = len(pods)
|
||||
ctrsPerMsg = len(containers)
|
||||
|
||||
rpl *SynchronizeResponse
|
||||
err error
|
||||
)
|
||||
|
||||
for {
|
||||
req := &SynchronizeRequest{
|
||||
Pods: podsToSend[:podsPerMsg],
|
||||
Containers: ctrsToSend[:ctrsPerMsg],
|
||||
More: len(podsToSend) > podsPerMsg || len(ctrsToSend) > ctrsPerMsg,
|
||||
}
|
||||
|
||||
log.Debugf(ctx, "sending sync message, %d/%d, %d/%d (more: %v)",
|
||||
len(req.Pods), len(podsToSend), len(req.Containers), len(ctrsToSend), req.More)
|
||||
|
||||
rpl, err = p.stub.Synchronize(ctx, req)
|
||||
if err == nil {
|
||||
if !req.More {
|
||||
break
|
||||
}
|
||||
|
||||
if len(rpl.Update) > 0 || rpl.More != req.More {
|
||||
p.close()
|
||||
return nil, fmt.Errorf("plugin does not handle split sync requests")
|
||||
}
|
||||
|
||||
podsToSend = podsToSend[podsPerMsg:]
|
||||
ctrsToSend = ctrsToSend[ctrsPerMsg:]
|
||||
|
||||
if podsPerMsg > len(podsToSend) {
|
||||
podsPerMsg = len(podsToSend)
|
||||
}
|
||||
if ctrsPerMsg > len(ctrsToSend) {
|
||||
ctrsPerMsg = len(ctrsToSend)
|
||||
}
|
||||
} else {
|
||||
podsPerMsg, ctrsPerMsg, err = recalcObjsPerSyncMsg(podsPerMsg, ctrsPerMsg, err)
|
||||
if err != nil {
|
||||
p.close()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugf(ctx, "oversized message, retrying in smaller chunks")
|
||||
}
|
||||
}
|
||||
|
||||
return rpl.Update, nil
|
||||
}
|
||||
|
||||
func recalcObjsPerSyncMsg(pods, ctrs int, err error) (int, int, error) {
|
||||
const (
|
||||
minObjsPerMsg = 8
|
||||
)
|
||||
|
||||
if status.Code(err) != codes.ResourceExhausted {
|
||||
return pods, ctrs, err
|
||||
}
|
||||
|
||||
if pods+ctrs <= minObjsPerMsg {
|
||||
return pods, ctrs, fmt.Errorf("failed to synchronize plugin with split messages")
|
||||
}
|
||||
|
||||
var e *ttrpc.OversizedMessageErr
|
||||
if !errors.As(err, &e) {
|
||||
return pods, ctrs, fmt.Errorf("failed to synchronize plugin with split messages")
|
||||
}
|
||||
|
||||
maxLen := e.MaximumLength()
|
||||
msgLen := e.RejectedLength()
|
||||
|
||||
if msgLen == 0 || maxLen == 0 || msgLen <= maxLen {
|
||||
return pods, ctrs, fmt.Errorf("failed to synchronize plugin with split messages")
|
||||
}
|
||||
|
||||
factor := float64(maxLen) / float64(msgLen)
|
||||
if factor > 0.9 {
|
||||
factor = 0.9
|
||||
}
|
||||
|
||||
pods = int(float64(pods) * factor)
|
||||
ctrs = int(float64(ctrs) * factor)
|
||||
|
||||
if pods+ctrs < minObjsPerMsg {
|
||||
pods = minObjsPerMsg / 2
|
||||
ctrs = minObjsPerMsg / 2
|
||||
}
|
||||
|
||||
return pods, ctrs, nil
|
||||
}
|
||||
|
||||
// Relay CreateContainer request to plugin.
|
||||
func (p *plugin) createContainer(ctx context.Context, req *CreateContainerRequest) (*CreateContainerResponse, error) {
|
||||
if !p.events.IsSet(Event_CREATE_CONTAINER) {
|
||||
@@ -516,7 +603,7 @@ func (p *plugin) StateChange(ctx context.Context, evt *StateChangeEvent) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// isFatalError returns true if the error is fatal and the plugin connection shoudld be closed.
|
||||
// isFatalError returns true if the error is fatal and the plugin connection should be closed.
|
||||
func isFatalError(err error) bool {
|
||||
switch {
|
||||
case errors.Is(err, ttrpc.ErrClosed):
|
||||
|
||||
128
vendor/github.com/containerd/nri/pkg/adaptation/result.go
generated
vendored
128
vendor/github.com/containerd/nri/pkg/adaptation/result.go
generated
vendored
@@ -19,6 +19,8 @@ package adaptation
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/containerd/nri/pkg/api"
|
||||
)
|
||||
|
||||
type result struct {
|
||||
@@ -89,6 +91,7 @@ func collectCreateContainerResult(request *CreateContainerRequest) *result {
|
||||
Env: []*KeyValue{},
|
||||
Hooks: &Hooks{},
|
||||
Rlimits: []*POSIXRlimit{},
|
||||
CDIDevices: []*CDIDevice{},
|
||||
Linux: &LinuxContainerAdjustment{
|
||||
Devices: []*LinuxDevice{},
|
||||
Resources: &LinuxResources{
|
||||
@@ -200,7 +203,7 @@ func (r *result) adjust(rpl *ContainerAdjustment, plugin string) error {
|
||||
if err := r.adjustEnv(rpl.Env, plugin); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := r.adjustHooks(rpl.Hooks, plugin); err != nil {
|
||||
if err := r.adjustHooks(rpl.Hooks); err != nil {
|
||||
return err
|
||||
}
|
||||
if rpl.Linux != nil {
|
||||
@@ -213,10 +216,16 @@ func (r *result) adjust(rpl *ContainerAdjustment, plugin string) error {
|
||||
if err := r.adjustCgroupsPath(rpl.Linux.CgroupsPath, plugin); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := r.adjustOomScoreAdj(rpl.Linux.OomScoreAdj, plugin); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := r.adjustRlimits(rpl.Rlimits, plugin); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := r.adjustCDIDevices(rpl.CDIDevices, plugin); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -322,6 +331,13 @@ func (r *result) adjustMounts(mounts []*Mount, plugin string) error {
|
||||
r.reply.adjust.Mounts = append(r.reply.adjust.Mounts, m)
|
||||
}
|
||||
|
||||
// next, apply deletions with no corresponding additions
|
||||
for _, m := range del {
|
||||
if _, ok := mod[api.ClearRemovalMarker(m.Destination)]; !ok {
|
||||
r.reply.adjust.Mounts = append(r.reply.adjust.Mounts, m)
|
||||
}
|
||||
}
|
||||
|
||||
// finally, apply additions/modifications to plugin container creation request
|
||||
create.Container.Mounts = append(create.Container.Mounts, add...)
|
||||
|
||||
@@ -386,6 +402,36 @@ func (r *result) adjustDevices(devices []*LinuxDevice, plugin string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *result) adjustCDIDevices(devices []*CDIDevice, plugin string) error {
|
||||
if len(devices) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Notes:
|
||||
// CDI devices are opaque references, typically to vendor specific
|
||||
// devices. They get resolved to actual devices and potential related
|
||||
// mounts, environment variables, etc. in the runtime. Unlike with
|
||||
// devices, we only allow CDI device references to be added to a
|
||||
// container, not removed. We pass them unresolved to the runtime and
|
||||
// have them resolved there. Also unlike with devices, we don't include
|
||||
// CDI device references in creation requests. However, since there
|
||||
// is typically a strong ownership and a single related management entity
|
||||
// per vendor/class for these devices we do treat multiple injection of
|
||||
// the same CDI device reference as an error here.
|
||||
|
||||
id := r.request.create.Container.Id
|
||||
|
||||
// apply additions to collected adjustments
|
||||
for _, d := range devices {
|
||||
if err := r.owners.claimCDIDevice(id, d.Name, plugin); err != nil {
|
||||
return err
|
||||
}
|
||||
r.reply.adjust.CDIDevices = append(r.reply.adjust.CDIDevices, d)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *result) adjustEnv(env []*KeyValue, plugin string) error {
|
||||
if len(env) == 0 {
|
||||
return nil
|
||||
@@ -458,7 +504,7 @@ func splitEnvVar(s string) (string, string) {
|
||||
return split[0], split[1]
|
||||
}
|
||||
|
||||
func (r *result) adjustHooks(hooks *Hooks, plugin string) error {
|
||||
func (r *result) adjustHooks(hooks *Hooks) error {
|
||||
if hooks == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -645,7 +691,16 @@ func (r *result) adjustResources(resources *LinuxResources, plugin string) error
|
||||
container.RdtClass = String(v.GetValue())
|
||||
reply.RdtClass = String(v.GetValue())
|
||||
}
|
||||
|
||||
if v := resources.GetPids(); v != nil {
|
||||
if err := r.owners.claimPidsLimit(id, plugin); err != nil {
|
||||
return err
|
||||
}
|
||||
pidv := &api.LinuxPids{
|
||||
Limit: v.GetLimit(),
|
||||
}
|
||||
container.Pids = pidv
|
||||
reply.Pids = pidv
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -666,6 +721,23 @@ func (r *result) adjustCgroupsPath(path, plugin string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *result) adjustOomScoreAdj(OomScoreAdj *OptionalInt, plugin string) error {
|
||||
if OomScoreAdj == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
create, id := r.request.create, r.request.create.Container.Id
|
||||
|
||||
if err := r.owners.claimOomScoreAdj(id, plugin); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
create.Container.Linux.OomScoreAdj = OomScoreAdj
|
||||
r.reply.adjust.Linux.OomScoreAdj = OomScoreAdj
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *result) adjustRlimits(rlimits []*POSIXRlimit, plugin string) error {
|
||||
create, id, adjust := r.request.create, r.request.create.Container.Id, r.reply.adjust
|
||||
for _, l := range rlimits {
|
||||
@@ -820,6 +892,14 @@ func (r *result) updateResources(reply, u *ContainerUpdate, plugin string) error
|
||||
}
|
||||
resources.RdtClass = String(v.GetValue())
|
||||
}
|
||||
if v := resources.GetPids(); v != nil {
|
||||
if err := r.owners.claimPidsLimit(id, plugin); err != nil {
|
||||
return err
|
||||
}
|
||||
resources.Pids = &api.LinuxPids{
|
||||
Limit: v.GetLimit(),
|
||||
}
|
||||
}
|
||||
|
||||
// update request/reply from copy on success
|
||||
reply.Linux.Resources = resources.Copy()
|
||||
@@ -872,6 +952,7 @@ type owners struct {
|
||||
annotations map[string]string
|
||||
mounts map[string]string
|
||||
devices map[string]string
|
||||
cdiDevices map[string]string
|
||||
env map[string]string
|
||||
memLimit string
|
||||
memReservation string
|
||||
@@ -888,11 +969,13 @@ type owners struct {
|
||||
cpuRealtimePeriod string
|
||||
cpusetCpus string
|
||||
cpusetMems string
|
||||
pidsLimit string
|
||||
hugepageLimits map[string]string
|
||||
blockioClass string
|
||||
rdtClass string
|
||||
unified map[string]string
|
||||
cgroupsPath string
|
||||
oomScoreAdj string
|
||||
rlimits map[string]string
|
||||
}
|
||||
|
||||
@@ -917,6 +1000,10 @@ func (ro resultOwners) claimDevice(id, path, plugin string) error {
|
||||
return ro.ownersFor(id).claimDevice(path, plugin)
|
||||
}
|
||||
|
||||
func (ro resultOwners) claimCDIDevice(id, path, plugin string) error {
|
||||
return ro.ownersFor(id).claimCDIDevice(path, plugin)
|
||||
}
|
||||
|
||||
func (ro resultOwners) claimEnv(id, name, plugin string) error {
|
||||
return ro.ownersFor(id).claimEnv(name, plugin)
|
||||
}
|
||||
@@ -981,6 +1068,10 @@ func (ro resultOwners) claimCpusetMems(id, plugin string) error {
|
||||
return ro.ownersFor(id).claimCpusetMems(plugin)
|
||||
}
|
||||
|
||||
func (ro resultOwners) claimPidsLimit(id, plugin string) error {
|
||||
return ro.ownersFor(id).claimPidsLimit(plugin)
|
||||
}
|
||||
|
||||
func (ro resultOwners) claimHugepageLimit(id, size, plugin string) error {
|
||||
return ro.ownersFor(id).claimHugepageLimit(size, plugin)
|
||||
}
|
||||
@@ -1001,6 +1092,10 @@ func (ro resultOwners) claimCgroupsPath(id, plugin string) error {
|
||||
return ro.ownersFor(id).claimCgroupsPath(plugin)
|
||||
}
|
||||
|
||||
func (ro resultOwners) claimOomScoreAdj(id, plugin string) error {
|
||||
return ro.ownersFor(id).claimOomScoreAdj(plugin)
|
||||
}
|
||||
|
||||
func (ro resultOwners) claimRlimits(id, typ, plugin string) error {
|
||||
return ro.ownersFor(id).claimRlimit(typ, plugin)
|
||||
}
|
||||
@@ -1038,6 +1133,17 @@ func (o *owners) claimDevice(path, plugin string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *owners) claimCDIDevice(name, plugin string) error {
|
||||
if o.cdiDevices == nil {
|
||||
o.cdiDevices = make(map[string]string)
|
||||
}
|
||||
if other, taken := o.cdiDevices[name]; taken {
|
||||
return conflict(plugin, other, "CDI device", name)
|
||||
}
|
||||
o.cdiDevices[name] = plugin
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *owners) claimEnv(name, plugin string) error {
|
||||
if o.env == nil {
|
||||
o.env = make(map[string]string)
|
||||
@@ -1169,6 +1275,14 @@ func (o *owners) claimCpusetMems(plugin string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *owners) claimPidsLimit(plugin string) error {
|
||||
if other := o.pidsLimit; other != "" {
|
||||
return conflict(plugin, other, "pids pinning")
|
||||
}
|
||||
o.pidsLimit = plugin
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *owners) claimHugepageLimit(size, plugin string) error {
|
||||
if o.hugepageLimits == nil {
|
||||
o.hugepageLimits = make(map[string]string)
|
||||
@@ -1227,6 +1341,14 @@ func (o *owners) claimCgroupsPath(plugin string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *owners) claimOomScoreAdj(plugin string) error {
|
||||
if other := o.oomScoreAdj; other != "" {
|
||||
return conflict(plugin, other, "oom score adj")
|
||||
}
|
||||
o.oomScoreAdj = plugin
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ro resultOwners) clearAnnotation(id, key string) {
|
||||
ro.ownersFor(id).clearAnnotation(key)
|
||||
}
|
||||
|
||||
24
vendor/github.com/containerd/nri/pkg/api/adjustment.go
generated
vendored
24
vendor/github.com/containerd/nri/pkg/api/adjustment.go
generated
vendored
@@ -129,6 +129,11 @@ func (a *ContainerAdjustment) RemoveDevice(path string) {
|
||||
})
|
||||
}
|
||||
|
||||
// AddCDIDevice records the addition of the given CDI device to a container.
|
||||
func (a *ContainerAdjustment) AddCDIDevice(d *CDIDevice) {
|
||||
a.CDIDevices = append(a.CDIDevices, d) // TODO: should we dup d here ?
|
||||
}
|
||||
|
||||
// SetLinuxMemoryLimit records setting the memory limit for a container.
|
||||
func (a *ContainerAdjustment) SetLinuxMemoryLimit(value int64) {
|
||||
a.initLinuxResourcesMemory()
|
||||
@@ -219,6 +224,12 @@ func (a *ContainerAdjustment) SetLinuxCPUSetMems(value string) {
|
||||
a.Linux.Resources.Cpu.Mems = value
|
||||
}
|
||||
|
||||
// SetLinuxPidLimits records setting the pid max number for a container.
|
||||
func (a *ContainerAdjustment) SetLinuxPidLimits(value int64) {
|
||||
a.initLinuxResourcesPids()
|
||||
a.Linux.Resources.Pids.Limit = value
|
||||
}
|
||||
|
||||
// AddLinuxHugepageLimit records adding a hugepage limit for a container.
|
||||
func (a *ContainerAdjustment) AddLinuxHugepageLimit(pageSize string, value uint64) {
|
||||
a.initLinuxResources()
|
||||
@@ -253,6 +264,12 @@ func (a *ContainerAdjustment) SetLinuxCgroupsPath(value string) {
|
||||
a.Linux.CgroupsPath = value
|
||||
}
|
||||
|
||||
// SetLinuxOomScoreAdj records setting the kernel's Out-Of-Memory (OOM) killer score for a container.
|
||||
func (a *ContainerAdjustment) SetLinuxOomScoreAdj(value *int) {
|
||||
a.initLinux()
|
||||
a.Linux.OomScoreAdj = Int(value) // using Int(value) from ./options.go to optionally allocate a pointer to normalized copy of value
|
||||
}
|
||||
|
||||
//
|
||||
// Initializing a container adjustment and container update.
|
||||
//
|
||||
@@ -302,6 +319,13 @@ func (a *ContainerAdjustment) initLinuxResourcesCPU() {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *ContainerAdjustment) initLinuxResourcesPids() {
|
||||
a.initLinuxResources()
|
||||
if a.Linux.Resources.Pids == nil {
|
||||
a.Linux.Resources.Pids = &LinuxPids{}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *ContainerAdjustment) initLinuxResourcesUnified() {
|
||||
a.initLinuxResources()
|
||||
if a.Linux.Resources.Unified == nil {
|
||||
|
||||
1619
vendor/github.com/containerd/nri/pkg/api/api.pb.go
generated
vendored
1619
vendor/github.com/containerd/nri/pkg/api/api.pb.go
generated
vendored
File diff suppressed because it is too large
Load Diff
24
vendor/github.com/containerd/nri/pkg/api/api.proto
generated
vendored
24
vendor/github.com/containerd/nri/pkg/api/api.proto
generated
vendored
@@ -46,7 +46,7 @@ message UpdateContainersRequest {
|
||||
}
|
||||
|
||||
message UpdateContainersResponse {
|
||||
// Containers that the runtime failed to udpate.
|
||||
// Containers that the runtime failed to update.
|
||||
repeated ContainerUpdate failed = 1;
|
||||
}
|
||||
|
||||
@@ -114,6 +114,10 @@ message ConfigureRequest {
|
||||
string runtime_name = 2;
|
||||
// Version of the runtime NRI is running in.
|
||||
string runtime_version = 3;
|
||||
// Configured registration timeout in milliseconds.
|
||||
int64 registration_timeout = 4;
|
||||
// Configured request processing timeout in milliseconds.
|
||||
int64 request_timeout = 5;
|
||||
}
|
||||
|
||||
message ConfigureResponse {
|
||||
@@ -127,11 +131,15 @@ message SynchronizeRequest {
|
||||
repeated PodSandbox pods = 1;
|
||||
// Containers known to the runtime.
|
||||
repeated Container containers = 2;
|
||||
// Whether there are more pods and containers to follow.
|
||||
bool more = 3;
|
||||
}
|
||||
|
||||
message SynchronizeResponse {
|
||||
// Updates to containers requested by the plugin.
|
||||
repeated ContainerUpdate update = 1;
|
||||
// Whether the client is able to handle more advertised pods and containers.
|
||||
bool more = 2;
|
||||
}
|
||||
|
||||
message CreateContainerRequest {
|
||||
@@ -220,6 +228,7 @@ message PodSandbox {
|
||||
string runtime_handler = 7;
|
||||
LinuxPodSandbox linux = 8;
|
||||
uint32 pid = 9; // for NRI v1 emulation
|
||||
repeated string ips = 10;
|
||||
}
|
||||
|
||||
// PodSandbox linux-specific metadata
|
||||
@@ -319,6 +328,11 @@ message LinuxDeviceCgroup {
|
||||
string access = 5;
|
||||
}
|
||||
|
||||
// A CDI device reference.
|
||||
message CDIDevice {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
// Container (linux) resources.
|
||||
message LinuxResources {
|
||||
LinuxMemory memory = 1;
|
||||
@@ -328,6 +342,7 @@ message LinuxResources {
|
||||
OptionalString rdt_class = 5;
|
||||
map<string, string> unified = 6;
|
||||
repeated LinuxDeviceCgroup devices = 7; // for NRI v1 emulation
|
||||
LinuxPids pids = 8;
|
||||
}
|
||||
|
||||
// Memory-related parts of (linux) resources.
|
||||
@@ -366,6 +381,11 @@ message POSIXRlimit {
|
||||
uint64 soft = 3;
|
||||
}
|
||||
|
||||
// Pids-related parts of (linux) resources.
|
||||
message LinuxPids {
|
||||
int64 limit = 1;
|
||||
}
|
||||
|
||||
// Requested adjustments to a container being created.
|
||||
message ContainerAdjustment {
|
||||
map<string, string> annotations = 2;
|
||||
@@ -374,6 +394,7 @@ message ContainerAdjustment {
|
||||
Hooks hooks = 5;
|
||||
LinuxContainerAdjustment linux = 6;
|
||||
repeated POSIXRlimit rlimits = 7;
|
||||
repeated CDIDevice CDI_devices = 8;
|
||||
}
|
||||
|
||||
// Adjustments to (linux) resources.
|
||||
@@ -381,6 +402,7 @@ message LinuxContainerAdjustment {
|
||||
repeated LinuxDevice devices = 1;
|
||||
LinuxResources resources = 2;
|
||||
string cgroups_path = 3;
|
||||
OptionalInt oom_score_adj = 4;
|
||||
}
|
||||
|
||||
// Requested update to an already created container.
|
||||
|
||||
11
vendor/github.com/containerd/nri/pkg/api/helpers.go
generated
vendored
11
vendor/github.com/containerd/nri/pkg/api/helpers.go
generated
vendored
@@ -57,3 +57,14 @@ func IsMarkedForRemoval(key string) (string, bool) {
|
||||
func MarkForRemoval(key string) string {
|
||||
return "-" + key
|
||||
}
|
||||
|
||||
// ClearRemovalMarker returns a key cleared from any removal marker.
|
||||
func ClearRemovalMarker(key string) string {
|
||||
if key == "" {
|
||||
return ""
|
||||
}
|
||||
if key[0] == '-' {
|
||||
return key[1:]
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
18
vendor/github.com/containerd/nri/pkg/api/resources.go
generated
vendored
18
vendor/github.com/containerd/nri/pkg/api/resources.go
generated
vendored
@@ -22,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
// FromOCILinuxResources returns resources from an OCI runtime Spec.
|
||||
func FromOCILinuxResources(o *rspec.LinuxResources, ann map[string]string) *LinuxResources {
|
||||
func FromOCILinuxResources(o *rspec.LinuxResources, _ map[string]string) *LinuxResources {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -65,6 +65,11 @@ func FromOCILinuxResources(o *rspec.LinuxResources, ann map[string]string) *Linu
|
||||
Access: d.Access,
|
||||
})
|
||||
}
|
||||
if p := o.Pids; p != nil {
|
||||
l.Pids = &LinuxPids{
|
||||
Limit: p.Limit,
|
||||
}
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
@@ -148,7 +153,11 @@ func (r *LinuxResources) ToOCI() *rspec.LinuxResources {
|
||||
Access: d.Access,
|
||||
})
|
||||
}
|
||||
|
||||
if r.Pids != nil {
|
||||
o.Pids = &rspec.LinuxPids{
|
||||
Limit: r.Pids.Limit,
|
||||
}
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
@@ -226,6 +235,11 @@ func (r *LinuxResources) Copy() *LinuxResources {
|
||||
o.Unified[k] = v
|
||||
}
|
||||
}
|
||||
if r.Pids != nil {
|
||||
o.Pids = &LinuxPids{
|
||||
Limit: r.Pids.Limit,
|
||||
}
|
||||
}
|
||||
o.BlockioClass = String(r.BlockioClass)
|
||||
o.RdtClass = String(r.RdtClass)
|
||||
|
||||
|
||||
28
vendor/github.com/containerd/nri/pkg/api/timeouts.go
generated
vendored
Normal file
28
vendor/github.com/containerd/nri/pkg/api/timeouts.go
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultPluginRegistrationTimeout is the default timeout for plugin registration.
|
||||
DefaultPluginRegistrationTimeout = 5 * time.Second
|
||||
// DefaultPluginRequestTimeout is the default timeout for plugins to handle a request.
|
||||
DefaultPluginRequestTimeout = 2 * time.Second
|
||||
)
|
||||
13
vendor/github.com/containerd/nri/pkg/api/update.go
generated
vendored
13
vendor/github.com/containerd/nri/pkg/api/update.go
generated
vendored
@@ -112,6 +112,12 @@ func (u *ContainerUpdate) SetLinuxCPUSetMems(value string) {
|
||||
u.Linux.Resources.Cpu.Mems = value
|
||||
}
|
||||
|
||||
// SetLinuxPidLimits records setting the pid max number for a container.
|
||||
func (u *ContainerUpdate) SetLinuxPidLimits(value int64) {
|
||||
u.initLinuxResourcesPids()
|
||||
u.Linux.Resources.Pids.Limit = value
|
||||
}
|
||||
|
||||
// AddLinuxHugepageLimit records adding a hugepage limit for a container.
|
||||
func (u *ContainerUpdate) AddLinuxHugepageLimit(pageSize string, value uint64) {
|
||||
u.initLinuxResources()
|
||||
@@ -184,3 +190,10 @@ func (u *ContainerUpdate) initLinuxResourcesUnified() {
|
||||
u.Linux.Resources.Unified = make(map[string]string)
|
||||
}
|
||||
}
|
||||
|
||||
func (u *ContainerUpdate) initLinuxResourcesPids() {
|
||||
u.initLinuxResources()
|
||||
if u.Linux.Resources.Pids == nil {
|
||||
u.Linux.Resources.Pids = &LinuxPids{}
|
||||
}
|
||||
}
|
||||
|
||||
70
vendor/github.com/containerd/nri/pkg/net/multiplex/mux.go
generated
vendored
70
vendor/github.com/containerd/nri/pkg/net/multiplex/mux.go
generated
vendored
@@ -139,7 +139,7 @@ const (
|
||||
// length of frame header: 4-byte ConnID, 4-byte payload length
|
||||
headerLen = 8
|
||||
// max. allowed payload size
|
||||
maxPayloadSize = 1 << 24
|
||||
maxPayloadSize = ttrpcMessageHeaderLength + ttrpcMessageLengthMax
|
||||
)
|
||||
|
||||
// conn represents a single multiplexed connection.
|
||||
@@ -234,38 +234,54 @@ func (m *mux) Listen(id ConnID) (net.Listener, error) {
|
||||
}
|
||||
|
||||
func (m *mux) write(id ConnID, buf []byte) (int, error) {
|
||||
var hdr [headerLen]byte
|
||||
|
||||
if len(buf) > maxPayloadSize {
|
||||
return 0, syscall.EMSGSIZE
|
||||
}
|
||||
|
||||
binary.BigEndian.PutUint32(hdr[0:4], uint32(id))
|
||||
binary.BigEndian.PutUint32(hdr[4:8], uint32(len(buf)))
|
||||
var (
|
||||
hdr [headerLen]byte
|
||||
data = buf[:]
|
||||
size = len(data)
|
||||
)
|
||||
|
||||
m.writeLock.Lock()
|
||||
defer m.writeLock.Unlock()
|
||||
|
||||
n, err := m.trunk.Write(hdr[:])
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to write header to trunk: %w", err)
|
||||
if n != 0 {
|
||||
m.setError(err)
|
||||
m.Close()
|
||||
for {
|
||||
if size > maxPayloadSize {
|
||||
size = maxPayloadSize
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
n, err = m.trunk.Write(buf)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to write payload to trunk: %w", err)
|
||||
if n != 0 {
|
||||
m.setError(err)
|
||||
m.Close()
|
||||
binary.BigEndian.PutUint32(hdr[0:4], uint32(id))
|
||||
binary.BigEndian.PutUint32(hdr[4:8], uint32(size))
|
||||
|
||||
n, err := m.trunk.Write(hdr[:])
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to write header to trunk: %w", err)
|
||||
if n != 0 {
|
||||
m.setError(err)
|
||||
m.Close()
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
n, err = m.trunk.Write(data[:size])
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to write payload to trunk: %w", err)
|
||||
if n != 0 {
|
||||
m.setError(err)
|
||||
m.Close()
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
data = data[size:]
|
||||
if size > len(data) {
|
||||
size = len(data)
|
||||
}
|
||||
|
||||
if size == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return n, err
|
||||
return len(buf), nil
|
||||
}
|
||||
|
||||
func (m *mux) reader() {
|
||||
@@ -429,16 +445,16 @@ func (c *conn) RemoteAddr() net.Addr {
|
||||
}
|
||||
|
||||
// SetDeadline is the unimplemented stub for the corresponding net.Conn function.
|
||||
func (c *conn) SetDeadline(t time.Time) error {
|
||||
func (c *conn) SetDeadline(_ time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetReadDeadline is the unimplemented stub for the corresponding net.Conn function.
|
||||
func (c *conn) SetReadDeadline(t time.Time) error {
|
||||
func (c *conn) SetReadDeadline(_ time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetWriteDeadline is the unimplemented stub for the corresponding net.Conn function.
|
||||
func (c *conn) SetWriteDeadline(t time.Time) error {
|
||||
func (c *conn) SetWriteDeadline(_ time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
5
vendor/github.com/containerd/nri/pkg/net/multiplex/ttrpc.go
generated
vendored
5
vendor/github.com/containerd/nri/pkg/net/multiplex/ttrpc.go
generated
vendored
@@ -22,3 +22,8 @@ const (
|
||||
// RuntimeServiceConn is the mux connection ID for NRI runtime services.
|
||||
RuntimeServiceConn
|
||||
)
|
||||
|
||||
const (
|
||||
ttrpcMessageHeaderLength = 10
|
||||
ttrpcMessageLengthMax = 4 << 20
|
||||
)
|
||||
|
||||
42
vendor/github.com/containerd/nri/pkg/runtime-tools/generate/generate.go
generated
vendored
42
vendor/github.com/containerd/nri/pkg/runtime-tools/generate/generate.go
generated
vendored
@@ -40,6 +40,7 @@ type Generator struct {
|
||||
filterAnnotations func(map[string]string) (map[string]string, error)
|
||||
resolveBlockIO func(string) (*rspec.LinuxBlockIO, error)
|
||||
resolveRdt func(string) (*rspec.LinuxIntelRdt, error)
|
||||
injectCDIDevices func(*rspec.Spec, []string) error
|
||||
checkResources func(*rspec.LinuxResources) error
|
||||
}
|
||||
|
||||
@@ -91,6 +92,14 @@ func WithResourceChecker(fn func(*rspec.LinuxResources) error) GeneratorOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithCDIDeviceInjector specifies a runtime-specific function to use for CDI
|
||||
// device resolution and injection into an OCI Spec.
|
||||
func WithCDIDeviceInjector(fn func(*rspec.Spec, []string) error) GeneratorOption {
|
||||
return func(g *Generator) {
|
||||
g.injectCDIDevices = fn
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust adjusts all aspects of the OCI Spec that NRI knows/cares about.
|
||||
func (g *Generator) Adjust(adjust *nri.ContainerAdjustment) error {
|
||||
if adjust == nil {
|
||||
@@ -102,8 +111,12 @@ func (g *Generator) Adjust(adjust *nri.ContainerAdjustment) error {
|
||||
}
|
||||
g.AdjustEnv(adjust.GetEnv())
|
||||
g.AdjustHooks(adjust.GetHooks())
|
||||
if err := g.InjectCDIDevices(adjust.GetCDIDevices()); err != nil {
|
||||
return err
|
||||
}
|
||||
g.AdjustDevices(adjust.GetLinux().GetDevices())
|
||||
g.AdjustCgroupsPath(adjust.GetLinux().GetCgroupsPath())
|
||||
g.AdjustOomScoreAdj(adjust.GetLinux().GetOomScoreAdj())
|
||||
|
||||
resources := adjust.GetLinux().GetResources()
|
||||
if err := g.AdjustResources(resources); err != nil {
|
||||
@@ -252,7 +265,9 @@ func (g *Generator) AdjustResources(r *nri.LinuxResources) error {
|
||||
for k, v := range r.Unified {
|
||||
g.AddLinuxResourcesUnified(k, v)
|
||||
}
|
||||
|
||||
if v := r.GetPids(); v != nil {
|
||||
g.SetLinuxResourcesPidsLimit(v.GetLimit())
|
||||
}
|
||||
if g.checkResources != nil {
|
||||
if err := g.checkResources(g.Config.Linux.Resources); err != nil {
|
||||
return fmt.Errorf("failed to adjust resources in OCI Spec: %w", err)
|
||||
@@ -309,6 +324,14 @@ func (g *Generator) AdjustCgroupsPath(path string) {
|
||||
}
|
||||
}
|
||||
|
||||
// AdjustOomScoreAdj adjusts the kernel's Out-Of-Memory (OOM) killer score for the container.
|
||||
// This may override kubelet's settings for OOM score.
|
||||
func (g *Generator) AdjustOomScoreAdj(score *nri.OptionalInt) {
|
||||
if score != nil {
|
||||
g.SetProcessOOMScoreAdj(int(score.Value))
|
||||
}
|
||||
}
|
||||
|
||||
// AdjustDevices adjusts the (Linux) devices in the OCI Spec.
|
||||
func (g *Generator) AdjustDevices(devices []*nri.LinuxDevice) {
|
||||
for _, d := range devices {
|
||||
@@ -323,6 +346,23 @@ func (g *Generator) AdjustDevices(devices []*nri.LinuxDevice) {
|
||||
}
|
||||
}
|
||||
|
||||
// InjectCDIDevices injects the requested CDI devices into the OCI Spec.
|
||||
// Devices are given by their fully qualified CDI device names. The
|
||||
// actual device injection is done using a runtime-specific CDI
|
||||
// injection function, set using the WithCDIDeviceInjector option.
|
||||
func (g *Generator) InjectCDIDevices(devices []*nri.CDIDevice) error {
|
||||
if len(devices) == 0 || g.injectCDIDevices == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
names := []string{}
|
||||
for _, d := range devices {
|
||||
names = append(names, d.Name)
|
||||
}
|
||||
|
||||
return g.injectCDIDevices(g.Config, names)
|
||||
}
|
||||
|
||||
func (g *Generator) AdjustRlimits(rlimits []*nri.POSIXRlimit) error {
|
||||
for _, l := range rlimits {
|
||||
if l == nil {
|
||||
|
||||
167
vendor/github.com/containerd/nri/pkg/stub/stub.go
generated
vendored
167
vendor/github.com/containerd/nri/pkg/stub/stub.go
generated
vendored
@@ -35,7 +35,7 @@ import (
|
||||
)
|
||||
|
||||
// Plugin can implement a number of interfaces related to Pod and Container
|
||||
// lifecycle events. No any single such inteface is mandatory, therefore the
|
||||
// lifecycle events. No any single such interface is mandatory, therefore the
|
||||
// Plugin interface itself is empty. Plugins are required to implement at
|
||||
// least one of these interfaces and this is verified during stub creation.
|
||||
// Trying to create a stub for a plugin violating this requirement will fail
|
||||
@@ -137,7 +137,9 @@ type PostUpdateContainerInterface interface {
|
||||
|
||||
// Stub is the interface the stub provides for the plugin implementation.
|
||||
type Stub interface {
|
||||
// Run the plugin. Starts the plugin then waits for an error or the plugin to stop
|
||||
// Run starts the plugin then waits for the plugin service to exit, either due to a
|
||||
// critical error or an explicit call to Stop(). Once Run() returns, the plugin can be
|
||||
// restarted by calling Run() or Start() again.
|
||||
Run(context.Context) error
|
||||
// Start the plugin.
|
||||
Start(context.Context) error
|
||||
@@ -148,11 +150,23 @@ type Stub interface {
|
||||
|
||||
// UpdateContainer requests unsolicited updates to containers.
|
||||
UpdateContainers([]*api.ContainerUpdate) ([]*api.ContainerUpdate, error)
|
||||
|
||||
// RegistrationTimeout returns the registration timeout for the stub.
|
||||
// This is the default timeout if the plugin has not been started or
|
||||
// the timeout received in the Configure request otherwise.
|
||||
RegistrationTimeout() time.Duration
|
||||
|
||||
// RequestTimeout returns the request timeout for the stub.
|
||||
// This is the default timeout if the plugin has not been started or
|
||||
// the timeout received in the Configure request otherwise.
|
||||
RequestTimeout() time.Duration
|
||||
}
|
||||
|
||||
const (
|
||||
// Plugin registration timeout.
|
||||
registrationTimeout = 2 * time.Second
|
||||
// DefaultRegistrationTimeout is the default plugin registration timeout.
|
||||
DefaultRegistrationTimeout = api.DefaultPluginRegistrationTimeout
|
||||
// DefaultRequestTimeout is the default plugin request processing timeout.
|
||||
DefaultRequestTimeout = api.DefaultPluginRequestTimeout
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -255,11 +269,14 @@ type stub struct {
|
||||
rpcs *ttrpc.Server
|
||||
rpcc *ttrpc.Client
|
||||
runtime api.RuntimeService
|
||||
closeOnce sync.Once
|
||||
started bool
|
||||
doneC chan struct{}
|
||||
srvErrC chan error
|
||||
cfgErrC chan error
|
||||
syncReq *api.SynchronizeRequest
|
||||
|
||||
registrationTimeout time.Duration
|
||||
requestTimeout time.Duration
|
||||
}
|
||||
|
||||
// Handlers for NRI plugin event and request.
|
||||
@@ -288,7 +305,9 @@ func New(p interface{}, opts ...Option) (Stub, error) {
|
||||
idx: os.Getenv(api.PluginIdxEnvVar),
|
||||
socketPath: api.DefaultSocketPath,
|
||||
dialer: func(p string) (stdnet.Conn, error) { return stdnet.Dial("unix", p) },
|
||||
doneC: make(chan struct{}),
|
||||
|
||||
registrationTimeout: DefaultRegistrationTimeout,
|
||||
requestTimeout: DefaultRequestTimeout,
|
||||
}
|
||||
|
||||
for _, o := range opts {
|
||||
@@ -316,10 +335,10 @@ func (stub *stub) Start(ctx context.Context) (retErr error) {
|
||||
stub.Lock()
|
||||
defer stub.Unlock()
|
||||
|
||||
if stub.started {
|
||||
if stub.isStarted() {
|
||||
return fmt.Errorf("stub already started")
|
||||
}
|
||||
stub.started = true
|
||||
stub.doneC = make(chan struct{})
|
||||
|
||||
err := stub.connect()
|
||||
if err != nil {
|
||||
@@ -378,10 +397,11 @@ func (stub *stub) Start(ctx context.Context) (retErr error) {
|
||||
|
||||
stub.srvErrC = make(chan error, 1)
|
||||
stub.cfgErrC = make(chan error, 1)
|
||||
go func() {
|
||||
stub.srvErrC <- rpcs.Serve(ctx, rpcl)
|
||||
close(stub.doneC)
|
||||
}()
|
||||
|
||||
go func(l stdnet.Listener, doneC chan struct{}, srvErrC chan error) {
|
||||
srvErrC <- rpcs.Serve(ctx, l)
|
||||
close(doneC)
|
||||
}(rpcl, stub.doneC, stub.srvErrC)
|
||||
|
||||
stub.rpcm = rpcm
|
||||
stub.rpcl = rpcl
|
||||
@@ -401,6 +421,7 @@ func (stub *stub) Start(ctx context.Context) (retErr error) {
|
||||
|
||||
log.Infof(ctx, "Started plugin %s...", stub.Name())
|
||||
|
||||
stub.started = true
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -413,24 +434,43 @@ func (stub *stub) Stop() {
|
||||
stub.close()
|
||||
}
|
||||
|
||||
// IsStarted returns true if the plugin has been started either by Start() or by Run().
|
||||
func (stub *stub) IsStarted() bool {
|
||||
stub.Lock()
|
||||
defer stub.Unlock()
|
||||
return stub.isStarted()
|
||||
}
|
||||
|
||||
func (stub *stub) isStarted() bool {
|
||||
return stub.started
|
||||
}
|
||||
|
||||
// reset stub to the status that can initiate a new
|
||||
// NRI connection, the caller must hold lock.
|
||||
func (stub *stub) close() {
|
||||
stub.closeOnce.Do(func() {
|
||||
if stub.rpcl != nil {
|
||||
stub.rpcl.Close()
|
||||
}
|
||||
if stub.rpcs != nil {
|
||||
stub.rpcs.Close()
|
||||
}
|
||||
if stub.rpcc != nil {
|
||||
stub.rpcc.Close()
|
||||
}
|
||||
if stub.rpcm != nil {
|
||||
stub.rpcm.Close()
|
||||
}
|
||||
if stub.srvErrC != nil {
|
||||
<-stub.doneC
|
||||
}
|
||||
})
|
||||
if !stub.isStarted() {
|
||||
return
|
||||
}
|
||||
|
||||
if stub.rpcl != nil {
|
||||
stub.rpcl.Close()
|
||||
}
|
||||
if stub.rpcs != nil {
|
||||
stub.rpcs.Close()
|
||||
}
|
||||
if stub.rpcc != nil {
|
||||
stub.rpcc.Close()
|
||||
}
|
||||
if stub.rpcm != nil {
|
||||
stub.rpcm.Close()
|
||||
}
|
||||
if stub.srvErrC != nil {
|
||||
<-stub.doneC
|
||||
}
|
||||
|
||||
stub.started = false
|
||||
stub.conn = nil
|
||||
stub.syncReq = nil
|
||||
}
|
||||
|
||||
// Run the plugin. Start event processing then wait for an error or getting stopped.
|
||||
@@ -449,14 +489,11 @@ func (stub *stub) Run(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Wait for the plugin to stop.
|
||||
// Wait for the plugin to stop, should be called after Start() or Run().
|
||||
func (stub *stub) Wait() {
|
||||
stub.Lock()
|
||||
if stub.srvErrC == nil {
|
||||
return
|
||||
if stub.IsStarted() {
|
||||
<-stub.doneC
|
||||
}
|
||||
stub.Unlock()
|
||||
<-stub.doneC
|
||||
}
|
||||
|
||||
// Name returns the full indexed name of the plugin.
|
||||
@@ -464,6 +501,14 @@ func (stub *stub) Name() string {
|
||||
return stub.idx + "-" + stub.name
|
||||
}
|
||||
|
||||
func (stub *stub) RegistrationTimeout() time.Duration {
|
||||
return stub.registrationTimeout
|
||||
}
|
||||
|
||||
func (stub *stub) RequestTimeout() time.Duration {
|
||||
return stub.requestTimeout
|
||||
}
|
||||
|
||||
// Connect the plugin to NRI.
|
||||
func (stub *stub) connect() error {
|
||||
if stub.conn != nil {
|
||||
@@ -502,7 +547,7 @@ func (stub *stub) connect() error {
|
||||
func (stub *stub) register(ctx context.Context) error {
|
||||
log.Infof(ctx, "Registering plugin %s...", stub.Name())
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, registrationTimeout)
|
||||
ctx, cancel := context.WithTimeout(ctx, stub.registrationTimeout)
|
||||
defer cancel()
|
||||
|
||||
req := &api.RegisterPluginRequest{
|
||||
@@ -518,7 +563,9 @@ func (stub *stub) register(ctx context.Context) error {
|
||||
|
||||
// Handle a lost connection.
|
||||
func (stub *stub) connClosed() {
|
||||
stub.Lock()
|
||||
stub.close()
|
||||
stub.Unlock()
|
||||
if stub.onClose != nil {
|
||||
stub.onClose()
|
||||
return
|
||||
@@ -558,6 +605,9 @@ func (stub *stub) Configure(ctx context.Context, req *api.ConfigureRequest) (rpl
|
||||
log.Infof(ctx, "Configuring plugin %s for runtime %s/%s...", stub.Name(),
|
||||
req.RuntimeName, req.RuntimeVersion)
|
||||
|
||||
stub.registrationTimeout = time.Duration(req.RegistrationTimeout * int64(time.Millisecond))
|
||||
stub.requestTimeout = time.Duration(req.RequestTimeout * int64(time.Millisecond))
|
||||
|
||||
defer func() {
|
||||
stub.cfgErrC <- retErr
|
||||
}()
|
||||
@@ -596,16 +646,55 @@ func (stub *stub) Configure(ctx context.Context, req *api.ConfigureRequest) (rpl
|
||||
func (stub *stub) Synchronize(ctx context.Context, req *api.SynchronizeRequest) (*api.SynchronizeResponse, error) {
|
||||
handler := stub.handlers.Synchronize
|
||||
if handler == nil {
|
||||
return &api.SynchronizeResponse{}, nil
|
||||
return &api.SynchronizeResponse{More: req.More}, nil
|
||||
}
|
||||
update, err := handler(ctx, req.Pods, req.Containers)
|
||||
|
||||
if req.More {
|
||||
return stub.collectSync(req)
|
||||
}
|
||||
|
||||
return stub.deliverSync(ctx, req)
|
||||
}
|
||||
|
||||
func (stub *stub) collectSync(req *api.SynchronizeRequest) (*api.SynchronizeResponse, error) {
|
||||
stub.Lock()
|
||||
defer stub.Unlock()
|
||||
|
||||
log.Debugf(noCtx, "collecting sync req with %d pods, %d containers...",
|
||||
len(req.Pods), len(req.Containers))
|
||||
|
||||
if stub.syncReq == nil {
|
||||
stub.syncReq = req
|
||||
} else {
|
||||
stub.syncReq.Pods = append(stub.syncReq.Pods, req.Pods...)
|
||||
stub.syncReq.Containers = append(stub.syncReq.Containers, req.Containers...)
|
||||
}
|
||||
|
||||
return &api.SynchronizeResponse{More: req.More}, nil
|
||||
}
|
||||
|
||||
func (stub *stub) deliverSync(ctx context.Context, req *api.SynchronizeRequest) (*api.SynchronizeResponse, error) {
|
||||
stub.Lock()
|
||||
syncReq := stub.syncReq
|
||||
stub.syncReq = nil
|
||||
stub.Unlock()
|
||||
|
||||
if syncReq == nil {
|
||||
syncReq = req
|
||||
} else {
|
||||
syncReq.Pods = append(syncReq.Pods, req.Pods...)
|
||||
syncReq.Containers = append(syncReq.Containers, req.Containers...)
|
||||
}
|
||||
|
||||
update, err := stub.handlers.Synchronize(ctx, syncReq.Pods, syncReq.Containers)
|
||||
return &api.SynchronizeResponse{
|
||||
Update: update,
|
||||
More: false,
|
||||
}, err
|
||||
}
|
||||
|
||||
// Shutdown the plugin.
|
||||
func (stub *stub) Shutdown(ctx context.Context, req *api.ShutdownRequest) (*api.ShutdownResponse, error) {
|
||||
func (stub *stub) Shutdown(ctx context.Context, _ *api.ShutdownRequest) (*api.ShutdownResponse, error) {
|
||||
handler := stub.handlers.Shutdown
|
||||
if handler != nil {
|
||||
handler(ctx)
|
||||
|
||||
2
vendor/github.com/containerd/nri/types/v1/types.go
generated
vendored
2
vendor/github.com/containerd/nri/types/v1/types.go
generated
vendored
@@ -33,7 +33,7 @@ type Plugin struct {
|
||||
//
|
||||
// Normally located at /etc/nri/conf.json
|
||||
type ConfigList struct {
|
||||
// Verion of the list
|
||||
// Version of the list
|
||||
Version string `json:"version"`
|
||||
// Plugins
|
||||
Plugins []*Plugin `json:"plugins"`
|
||||
|
||||
8
vendor/github.com/containerd/ttrpc/channel.go
generated
vendored
8
vendor/github.com/containerd/ttrpc/channel.go
generated
vendored
@@ -143,10 +143,10 @@ func (ch *channel) recv() (messageHeader, []byte, error) {
|
||||
}
|
||||
|
||||
func (ch *channel) send(streamID uint32, t messageType, flags uint8, p []byte) error {
|
||||
// TODO: Error on send rather than on recv
|
||||
//if len(p) > messageLengthMax {
|
||||
// return status.Errorf(codes.InvalidArgument, "refusing to send, message length %v exceed maximum message size of %v", len(p), messageLengthMax)
|
||||
//}
|
||||
if len(p) > messageLengthMax {
|
||||
return OversizedMessageError(len(p))
|
||||
}
|
||||
|
||||
if err := writeMessageHeader(ch.bw, ch.hwbuf[:], messageHeader{Length: uint32(len(p)), StreamID: streamID, Type: t, Flags: flags}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
48
vendor/github.com/containerd/ttrpc/errors.go
generated
vendored
48
vendor/github.com/containerd/ttrpc/errors.go
generated
vendored
@@ -16,7 +16,12 @@
|
||||
|
||||
package ttrpc
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrProtocol is a general error in the handling the protocol.
|
||||
@@ -32,3 +37,44 @@ var (
|
||||
// ErrStreamClosed is when the streaming connection is closed.
|
||||
ErrStreamClosed = errors.New("ttrpc: stream closed")
|
||||
)
|
||||
|
||||
// OversizedMessageErr is used to indicate refusal to send an oversized message.
|
||||
// It wraps a ResourceExhausted grpc Status together with the offending message
|
||||
// length.
|
||||
type OversizedMessageErr struct {
|
||||
messageLength int
|
||||
err error
|
||||
}
|
||||
|
||||
// OversizedMessageError returns an OversizedMessageErr error for the given message
|
||||
// length if it exceeds the allowed maximum. Otherwise a nil error is returned.
|
||||
func OversizedMessageError(messageLength int) error {
|
||||
if messageLength <= messageLengthMax {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &OversizedMessageErr{
|
||||
messageLength: messageLength,
|
||||
err: status.Errorf(codes.ResourceExhausted, "message length %v exceed maximum message size of %v", messageLength, messageLengthMax),
|
||||
}
|
||||
}
|
||||
|
||||
// Error returns the error message for the corresponding grpc Status for the error.
|
||||
func (e *OversizedMessageErr) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
// Unwrap returns the corresponding error with our grpc status code.
|
||||
func (e *OversizedMessageErr) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
// RejectedLength retrieves the rejected message length which triggered the error.
|
||||
func (e *OversizedMessageErr) RejectedLength() int {
|
||||
return e.messageLength
|
||||
}
|
||||
|
||||
// MaximumLength retrieves the maximum allowed message length that triggered the error.
|
||||
func (*OversizedMessageErr) MaximumLength() int {
|
||||
return messageLengthMax
|
||||
}
|
||||
|
||||
28
vendor/github.com/containerd/ttrpc/metadata.go
generated
vendored
28
vendor/github.com/containerd/ttrpc/metadata.go
generated
vendored
@@ -62,6 +62,34 @@ func (m MD) Append(key string, values ...string) {
|
||||
}
|
||||
}
|
||||
|
||||
// Clone returns a copy of MD or nil if it's nil.
|
||||
// It's copied from golang's `http.Header.Clone` implementation:
|
||||
// https://cs.opensource.google/go/go/+/refs/tags/go1.23.4:src/net/http/header.go;l=94
|
||||
func (m MD) Clone() MD {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Find total number of values.
|
||||
nv := 0
|
||||
for _, vv := range m {
|
||||
nv += len(vv)
|
||||
}
|
||||
sv := make([]string, nv) // shared backing array for headers' values
|
||||
m2 := make(MD, len(m))
|
||||
for k, vv := range m {
|
||||
if vv == nil {
|
||||
// Preserve nil values.
|
||||
m2[k] = nil
|
||||
continue
|
||||
}
|
||||
n := copy(sv, vv)
|
||||
m2[k] = sv[:n:n]
|
||||
sv = sv[n:]
|
||||
}
|
||||
return m2
|
||||
}
|
||||
|
||||
func (m MD) setRequest(r *Request) {
|
||||
for k, values := range m {
|
||||
for _, v := range values {
|
||||
|
||||
15
vendor/github.com/containerd/ttrpc/server.go
generated
vendored
15
vendor/github.com/containerd/ttrpc/server.go
generated
vendored
@@ -74,9 +74,18 @@ func (s *Server) RegisterService(name string, desc *ServiceDesc) {
|
||||
}
|
||||
|
||||
func (s *Server) Serve(ctx context.Context, l net.Listener) error {
|
||||
s.addListener(l)
|
||||
s.mu.Lock()
|
||||
s.addListenerLocked(l)
|
||||
defer s.closeListener(l)
|
||||
|
||||
select {
|
||||
case <-s.done:
|
||||
s.mu.Unlock()
|
||||
return ErrServerClosed
|
||||
default:
|
||||
}
|
||||
s.mu.Unlock()
|
||||
|
||||
var (
|
||||
backoff time.Duration
|
||||
handshaker = s.config.handshaker
|
||||
@@ -188,9 +197,7 @@ func (s *Server) Close() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Server) addListener(l net.Listener) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
func (s *Server) addListenerLocked(l net.Listener) {
|
||||
s.listeners[l] = struct{}{}
|
||||
}
|
||||
|
||||
|
||||
68
vendor/github.com/go-logr/logr/README.md
generated
vendored
68
vendor/github.com/go-logr/logr/README.md
generated
vendored
@@ -1,6 +1,7 @@
|
||||
# A minimal logging API for Go
|
||||
|
||||
[](https://pkg.go.dev/github.com/go-logr/logr)
|
||||
[](https://goreportcard.com/report/github.com/go-logr/logr)
|
||||
[](https://securityscorecards.dev/viewer/?platform=github.com&org=go-logr&repo=logr)
|
||||
|
||||
logr offers an(other) opinion on how Go programs and libraries can do logging
|
||||
@@ -91,11 +92,12 @@ logr design but also left out some parts and changed others:
|
||||
| Adding a name to a logger | `WithName` | no API |
|
||||
| Modify verbosity of log entries in a call chain | `V` | no API |
|
||||
| Grouping of key/value pairs | not supported | `WithGroup`, `GroupValue` |
|
||||
| Pass context for extracting additional values | no API | API variants like `InfoCtx` |
|
||||
|
||||
The high-level slog API is explicitly meant to be one of many different APIs
|
||||
that can be layered on top of a shared `slog.Handler`. logr is one such
|
||||
alternative API, with [interoperability](#slog-interoperability) provided by the [`slogr`](slogr)
|
||||
package.
|
||||
alternative API, with [interoperability](#slog-interoperability) provided by
|
||||
some conversion functions.
|
||||
|
||||
### Inspiration
|
||||
|
||||
@@ -145,24 +147,24 @@ There are implementations for the following logging libraries:
|
||||
## slog interoperability
|
||||
|
||||
Interoperability goes both ways, using the `logr.Logger` API with a `slog.Handler`
|
||||
and using the `slog.Logger` API with a `logr.LogSink`. [slogr](./slogr) provides `NewLogr` and
|
||||
`NewSlogHandler` API calls to convert between a `logr.Logger` and a `slog.Handler`.
|
||||
and using the `slog.Logger` API with a `logr.LogSink`. `FromSlogHandler` and
|
||||
`ToSlogHandler` convert between a `logr.Logger` and a `slog.Handler`.
|
||||
As usual, `slog.New` can be used to wrap such a `slog.Handler` in the high-level
|
||||
slog API. `slogr` itself leaves that to the caller.
|
||||
slog API.
|
||||
|
||||
## Using a `logr.Sink` as backend for slog
|
||||
### Using a `logr.LogSink` as backend for slog
|
||||
|
||||
Ideally, a logr sink implementation should support both logr and slog by
|
||||
implementing both the normal logr interface(s) and `slogr.SlogSink`. Because
|
||||
implementing both the normal logr interface(s) and `SlogSink`. Because
|
||||
of a conflict in the parameters of the common `Enabled` method, it is [not
|
||||
possible to implement both slog.Handler and logr.Sink in the same
|
||||
type](https://github.com/golang/go/issues/59110).
|
||||
|
||||
If both are supported, log calls can go from the high-level APIs to the backend
|
||||
without the need to convert parameters. `NewLogr` and `NewSlogHandler` can
|
||||
without the need to convert parameters. `FromSlogHandler` and `ToSlogHandler` can
|
||||
convert back and forth without adding additional wrappers, with one exception:
|
||||
when `Logger.V` was used to adjust the verbosity for a `slog.Handler`, then
|
||||
`NewSlogHandler` has to use a wrapper which adjusts the verbosity for future
|
||||
`ToSlogHandler` has to use a wrapper which adjusts the verbosity for future
|
||||
log calls.
|
||||
|
||||
Such an implementation should also support values that implement specific
|
||||
@@ -187,13 +189,13 @@ Not supporting slog has several drawbacks:
|
||||
These drawbacks are severe enough that applications using a mixture of slog and
|
||||
logr should switch to a different backend.
|
||||
|
||||
## Using a `slog.Handler` as backend for logr
|
||||
### Using a `slog.Handler` as backend for logr
|
||||
|
||||
Using a plain `slog.Handler` without support for logr works better than the
|
||||
other direction:
|
||||
- All logr verbosity levels can be mapped 1:1 to their corresponding slog level
|
||||
by negating them.
|
||||
- Stack unwinding is done by the `slogr.SlogSink` and the resulting program
|
||||
- Stack unwinding is done by the `SlogSink` and the resulting program
|
||||
counter is passed to the `slog.Handler`.
|
||||
- Names added via `Logger.WithName` are gathered and recorded in an additional
|
||||
attribute with `logger` as key and the names separated by slash as value.
|
||||
@@ -205,27 +207,39 @@ ideally support both `logr.Marshaler` and `slog.Valuer`. If compatibility
|
||||
with logr implementations without slog support is not important, then
|
||||
`slog.Valuer` is sufficient.
|
||||
|
||||
## Context support for slog
|
||||
### Context support for slog
|
||||
|
||||
Storing a logger in a `context.Context` is not supported by
|
||||
slog. `logr.NewContext` and `logr.FromContext` can be used with slog like this
|
||||
to fill this gap:
|
||||
slog. `NewContextWithSlogLogger` and `FromContextAsSlogLogger` can be
|
||||
used to fill this gap. They store and retrieve a `slog.Logger` pointer
|
||||
under the same context key that is also used by `NewContext` and
|
||||
`FromContext` for `logr.Logger` value.
|
||||
|
||||
func HandlerFromContext(ctx context.Context) slog.Handler {
|
||||
logger, err := logr.FromContext(ctx)
|
||||
if err == nil {
|
||||
return slogr.NewSlogHandler(logger)
|
||||
}
|
||||
return slog.Default().Handler()
|
||||
}
|
||||
When `NewContextWithSlogLogger` is followed by `FromContext`, the latter will
|
||||
automatically convert the `slog.Logger` to a
|
||||
`logr.Logger`. `FromContextAsSlogLogger` does the same for the other direction.
|
||||
|
||||
func ContextWithHandler(ctx context.Context, handler slog.Handler) context.Context {
|
||||
return logr.NewContext(ctx, slogr.NewLogr(handler))
|
||||
}
|
||||
With this approach, binaries which use either slog or logr are as efficient as
|
||||
possible with no unnecessary allocations. This is also why the API stores a
|
||||
`slog.Logger` pointer: when storing a `slog.Handler`, creating a `slog.Logger`
|
||||
on retrieval would need to allocate one.
|
||||
|
||||
The downside is that storing and retrieving a `slog.Handler` needs more
|
||||
allocations compared to using a `logr.Logger`. Therefore the recommendation is
|
||||
to use the `logr.Logger` API in code which uses contextual logging.
|
||||
The downside is that switching back and forth needs more allocations. Because
|
||||
logr is the API that is already in use by different packages, in particular
|
||||
Kubernetes, the recommendation is to use the `logr.Logger` API in code which
|
||||
uses contextual logging.
|
||||
|
||||
An alternative to adding values to a logger and storing that logger in the
|
||||
context is to store the values in the context and to configure a logging
|
||||
backend to extract those values when emitting log entries. This only works when
|
||||
log calls are passed the context, which is not supported by the logr API.
|
||||
|
||||
With the slog API, it is possible, but not
|
||||
required. https://github.com/veqryn/slog-context is a package for slog which
|
||||
provides additional support code for this approach. It also contains wrappers
|
||||
for the context functions in logr, so developers who prefer to not use the logr
|
||||
APIs directly can use those instead and the resulting code will still be
|
||||
interoperable with logr.
|
||||
|
||||
## FAQ
|
||||
|
||||
|
||||
33
vendor/github.com/go-logr/logr/context.go
generated
vendored
Normal file
33
vendor/github.com/go-logr/logr/context.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright 2023 The logr Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package logr
|
||||
|
||||
// contextKey is how we find Loggers in a context.Context. With Go < 1.21,
|
||||
// the value is always a Logger value. With Go >= 1.21, the value can be a
|
||||
// Logger value or a slog.Logger pointer.
|
||||
type contextKey struct{}
|
||||
|
||||
// notFoundError exists to carry an IsNotFound method.
|
||||
type notFoundError struct{}
|
||||
|
||||
func (notFoundError) Error() string {
|
||||
return "no logr.Logger was present"
|
||||
}
|
||||
|
||||
func (notFoundError) IsNotFound() bool {
|
||||
return true
|
||||
}
|
||||
49
vendor/github.com/go-logr/logr/context_noslog.go
generated
vendored
Normal file
49
vendor/github.com/go-logr/logr/context_noslog.go
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
//go:build !go1.21
|
||||
// +build !go1.21
|
||||
|
||||
/*
|
||||
Copyright 2019 The logr Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package logr
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// FromContext returns a Logger from ctx or an error if no Logger is found.
|
||||
func FromContext(ctx context.Context) (Logger, error) {
|
||||
if v, ok := ctx.Value(contextKey{}).(Logger); ok {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
return Logger{}, notFoundError{}
|
||||
}
|
||||
|
||||
// FromContextOrDiscard returns a Logger from ctx. If no Logger is found, this
|
||||
// returns a Logger that discards all log messages.
|
||||
func FromContextOrDiscard(ctx context.Context) Logger {
|
||||
if v, ok := ctx.Value(contextKey{}).(Logger); ok {
|
||||
return v
|
||||
}
|
||||
|
||||
return Discard()
|
||||
}
|
||||
|
||||
// NewContext returns a new Context, derived from ctx, which carries the
|
||||
// provided Logger.
|
||||
func NewContext(ctx context.Context, logger Logger) context.Context {
|
||||
return context.WithValue(ctx, contextKey{}, logger)
|
||||
}
|
||||
83
vendor/github.com/go-logr/logr/context_slog.go
generated
vendored
Normal file
83
vendor/github.com/go-logr/logr/context_slog.go
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
//go:build go1.21
|
||||
// +build go1.21
|
||||
|
||||
/*
|
||||
Copyright 2019 The logr Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package logr
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
// FromContext returns a Logger from ctx or an error if no Logger is found.
|
||||
func FromContext(ctx context.Context) (Logger, error) {
|
||||
v := ctx.Value(contextKey{})
|
||||
if v == nil {
|
||||
return Logger{}, notFoundError{}
|
||||
}
|
||||
|
||||
switch v := v.(type) {
|
||||
case Logger:
|
||||
return v, nil
|
||||
case *slog.Logger:
|
||||
return FromSlogHandler(v.Handler()), nil
|
||||
default:
|
||||
// Not reached.
|
||||
panic(fmt.Sprintf("unexpected value type for logr context key: %T", v))
|
||||
}
|
||||
}
|
||||
|
||||
// FromContextAsSlogLogger returns a slog.Logger from ctx or nil if no such Logger is found.
|
||||
func FromContextAsSlogLogger(ctx context.Context) *slog.Logger {
|
||||
v := ctx.Value(contextKey{})
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch v := v.(type) {
|
||||
case Logger:
|
||||
return slog.New(ToSlogHandler(v))
|
||||
case *slog.Logger:
|
||||
return v
|
||||
default:
|
||||
// Not reached.
|
||||
panic(fmt.Sprintf("unexpected value type for logr context key: %T", v))
|
||||
}
|
||||
}
|
||||
|
||||
// FromContextOrDiscard returns a Logger from ctx. If no Logger is found, this
|
||||
// returns a Logger that discards all log messages.
|
||||
func FromContextOrDiscard(ctx context.Context) Logger {
|
||||
if logger, err := FromContext(ctx); err == nil {
|
||||
return logger
|
||||
}
|
||||
return Discard()
|
||||
}
|
||||
|
||||
// NewContext returns a new Context, derived from ctx, which carries the
|
||||
// provided Logger.
|
||||
func NewContext(ctx context.Context, logger Logger) context.Context {
|
||||
return context.WithValue(ctx, contextKey{}, logger)
|
||||
}
|
||||
|
||||
// NewContextWithSlogLogger returns a new Context, derived from ctx, which carries the
|
||||
// provided slog.Logger.
|
||||
func NewContextWithSlogLogger(ctx context.Context, logger *slog.Logger) context.Context {
|
||||
return context.WithValue(ctx, contextKey{}, logger)
|
||||
}
|
||||
208
vendor/github.com/go-logr/logr/funcr/funcr.go
generated
vendored
208
vendor/github.com/go-logr/logr/funcr/funcr.go
generated
vendored
@@ -100,6 +100,11 @@ type Options struct {
|
||||
// details, see docs for Go's time.Layout.
|
||||
TimestampFormat string
|
||||
|
||||
// LogInfoLevel tells funcr what key to use to log the info level.
|
||||
// If not specified, the info level will be logged as "level".
|
||||
// If this is set to "", the info level will not be logged at all.
|
||||
LogInfoLevel *string
|
||||
|
||||
// Verbosity tells funcr which V logs to produce. Higher values enable
|
||||
// more logs. Info logs at or below this level will be written, while logs
|
||||
// above this level will be discarded.
|
||||
@@ -213,6 +218,10 @@ func newFormatter(opts Options, outfmt outputFormat) Formatter {
|
||||
if opts.MaxLogDepth == 0 {
|
||||
opts.MaxLogDepth = defaultMaxLogDepth
|
||||
}
|
||||
if opts.LogInfoLevel == nil {
|
||||
opts.LogInfoLevel = new(string)
|
||||
*opts.LogInfoLevel = "level"
|
||||
}
|
||||
f := Formatter{
|
||||
outputFormat: outfmt,
|
||||
prefix: "",
|
||||
@@ -233,6 +242,8 @@ type Formatter struct {
|
||||
valuesStr string
|
||||
depth int
|
||||
opts *Options
|
||||
groupName string // for slog groups
|
||||
groups []groupDef
|
||||
}
|
||||
|
||||
// outputFormat indicates which outputFormat to use.
|
||||
@@ -245,6 +256,13 @@ const (
|
||||
outputJSON
|
||||
)
|
||||
|
||||
// groupDef represents a saved group. The values may be empty, but we don't
|
||||
// know if we need to render the group until the final record is rendered.
|
||||
type groupDef struct {
|
||||
name string
|
||||
values string
|
||||
}
|
||||
|
||||
// PseudoStruct is a list of key-value pairs that gets logged as a struct.
|
||||
type PseudoStruct []any
|
||||
|
||||
@@ -252,63 +270,125 @@ type PseudoStruct []any
|
||||
func (f Formatter) render(builtins, args []any) string {
|
||||
// Empirically bytes.Buffer is faster than strings.Builder for this.
|
||||
buf := bytes.NewBuffer(make([]byte, 0, 1024))
|
||||
|
||||
if f.outputFormat == outputJSON {
|
||||
buf.WriteByte('{')
|
||||
buf.WriteByte('{') // for the whole record
|
||||
}
|
||||
|
||||
// Render builtins
|
||||
vals := builtins
|
||||
if hook := f.opts.RenderBuiltinsHook; hook != nil {
|
||||
vals = hook(f.sanitize(vals))
|
||||
}
|
||||
f.flatten(buf, vals, false, false) // keys are ours, no need to escape
|
||||
f.flatten(buf, vals, false) // keys are ours, no need to escape
|
||||
continuing := len(builtins) > 0
|
||||
if len(f.valuesStr) > 0 {
|
||||
if continuing {
|
||||
if f.outputFormat == outputJSON {
|
||||
buf.WriteByte(',')
|
||||
} else {
|
||||
buf.WriteByte(' ')
|
||||
}
|
||||
|
||||
// Turn the inner-most group into a string
|
||||
argsStr := func() string {
|
||||
buf := bytes.NewBuffer(make([]byte, 0, 1024))
|
||||
|
||||
vals = args
|
||||
if hook := f.opts.RenderArgsHook; hook != nil {
|
||||
vals = hook(f.sanitize(vals))
|
||||
}
|
||||
continuing = true
|
||||
buf.WriteString(f.valuesStr)
|
||||
f.flatten(buf, vals, true) // escape user-provided keys
|
||||
|
||||
return buf.String()
|
||||
}()
|
||||
|
||||
// Render the stack of groups from the inside out.
|
||||
bodyStr := f.renderGroup(f.groupName, f.valuesStr, argsStr)
|
||||
for i := len(f.groups) - 1; i >= 0; i-- {
|
||||
grp := &f.groups[i]
|
||||
if grp.values == "" && bodyStr == "" {
|
||||
// no contents, so we must elide the whole group
|
||||
continue
|
||||
}
|
||||
bodyStr = f.renderGroup(grp.name, grp.values, bodyStr)
|
||||
}
|
||||
vals = args
|
||||
if hook := f.opts.RenderArgsHook; hook != nil {
|
||||
vals = hook(f.sanitize(vals))
|
||||
|
||||
if bodyStr != "" {
|
||||
if continuing {
|
||||
buf.WriteByte(f.comma())
|
||||
}
|
||||
buf.WriteString(bodyStr)
|
||||
}
|
||||
f.flatten(buf, vals, continuing, true) // escape user-provided keys
|
||||
|
||||
if f.outputFormat == outputJSON {
|
||||
buf.WriteByte('}')
|
||||
buf.WriteByte('}') // for the whole record
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// flatten renders a list of key-value pairs into a buffer. If continuing is
|
||||
// true, it assumes that the buffer has previous values and will emit a
|
||||
// separator (which depends on the output format) before the first pair it
|
||||
// writes. If escapeKeys is true, the keys are assumed to have
|
||||
// non-JSON-compatible characters in them and must be evaluated for escapes.
|
||||
// renderGroup returns a string representation of the named group with rendered
|
||||
// values and args. If the name is empty, this will return the values and args,
|
||||
// joined. If the name is not empty, this will return a single key-value pair,
|
||||
// where the value is a grouping of the values and args. If the values and
|
||||
// args are both empty, this will return an empty string, even if the name was
|
||||
// specified.
|
||||
func (f Formatter) renderGroup(name string, values string, args string) string {
|
||||
buf := bytes.NewBuffer(make([]byte, 0, 1024))
|
||||
|
||||
needClosingBrace := false
|
||||
if name != "" && (values != "" || args != "") {
|
||||
buf.WriteString(f.quoted(name, true)) // escape user-provided keys
|
||||
buf.WriteByte(f.colon())
|
||||
buf.WriteByte('{')
|
||||
needClosingBrace = true
|
||||
}
|
||||
|
||||
continuing := false
|
||||
if values != "" {
|
||||
buf.WriteString(values)
|
||||
continuing = true
|
||||
}
|
||||
|
||||
if args != "" {
|
||||
if continuing {
|
||||
buf.WriteByte(f.comma())
|
||||
}
|
||||
buf.WriteString(args)
|
||||
}
|
||||
|
||||
if needClosingBrace {
|
||||
buf.WriteByte('}')
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// flatten renders a list of key-value pairs into a buffer. If escapeKeys is
|
||||
// true, the keys are assumed to have non-JSON-compatible characters in them
|
||||
// and must be evaluated for escapes.
|
||||
//
|
||||
// This function returns a potentially modified version of kvList, which
|
||||
// ensures that there is a value for every key (adding a value if needed) and
|
||||
// that each key is a string (substituting a key if needed).
|
||||
func (f Formatter) flatten(buf *bytes.Buffer, kvList []any, continuing bool, escapeKeys bool) []any {
|
||||
func (f Formatter) flatten(buf *bytes.Buffer, kvList []any, escapeKeys bool) []any {
|
||||
// This logic overlaps with sanitize() but saves one type-cast per key,
|
||||
// which can be measurable.
|
||||
if len(kvList)%2 != 0 {
|
||||
kvList = append(kvList, noValue)
|
||||
}
|
||||
copied := false
|
||||
for i := 0; i < len(kvList); i += 2 {
|
||||
k, ok := kvList[i].(string)
|
||||
if !ok {
|
||||
if !copied {
|
||||
newList := make([]any, len(kvList))
|
||||
copy(newList, kvList)
|
||||
kvList = newList
|
||||
copied = true
|
||||
}
|
||||
k = f.nonStringKey(kvList[i])
|
||||
kvList[i] = k
|
||||
}
|
||||
v := kvList[i+1]
|
||||
|
||||
if i > 0 || continuing {
|
||||
if i > 0 {
|
||||
if f.outputFormat == outputJSON {
|
||||
buf.WriteByte(',')
|
||||
buf.WriteByte(f.comma())
|
||||
} else {
|
||||
// In theory the format could be something we don't understand. In
|
||||
// practice, we control it, so it won't be.
|
||||
@@ -316,24 +396,35 @@ func (f Formatter) flatten(buf *bytes.Buffer, kvList []any, continuing bool, esc
|
||||
}
|
||||
}
|
||||
|
||||
if escapeKeys {
|
||||
buf.WriteString(prettyString(k))
|
||||
} else {
|
||||
// this is faster
|
||||
buf.WriteByte('"')
|
||||
buf.WriteString(k)
|
||||
buf.WriteByte('"')
|
||||
}
|
||||
if f.outputFormat == outputJSON {
|
||||
buf.WriteByte(':')
|
||||
} else {
|
||||
buf.WriteByte('=')
|
||||
}
|
||||
buf.WriteString(f.quoted(k, escapeKeys))
|
||||
buf.WriteByte(f.colon())
|
||||
buf.WriteString(f.pretty(v))
|
||||
}
|
||||
return kvList
|
||||
}
|
||||
|
||||
func (f Formatter) quoted(str string, escape bool) string {
|
||||
if escape {
|
||||
return prettyString(str)
|
||||
}
|
||||
// this is faster
|
||||
return `"` + str + `"`
|
||||
}
|
||||
|
||||
func (f Formatter) comma() byte {
|
||||
if f.outputFormat == outputJSON {
|
||||
return ','
|
||||
}
|
||||
return ' '
|
||||
}
|
||||
|
||||
func (f Formatter) colon() byte {
|
||||
if f.outputFormat == outputJSON {
|
||||
return ':'
|
||||
}
|
||||
return '='
|
||||
}
|
||||
|
||||
func (f Formatter) pretty(value any) string {
|
||||
return f.prettyWithFlags(value, 0, 0)
|
||||
}
|
||||
@@ -407,12 +498,12 @@ func (f Formatter) prettyWithFlags(value any, flags uint32, depth int) string {
|
||||
}
|
||||
for i := 0; i < len(v); i += 2 {
|
||||
if i > 0 {
|
||||
buf.WriteByte(',')
|
||||
buf.WriteByte(f.comma())
|
||||
}
|
||||
k, _ := v[i].(string) // sanitize() above means no need to check success
|
||||
// arbitrary keys might need escaping
|
||||
buf.WriteString(prettyString(k))
|
||||
buf.WriteByte(':')
|
||||
buf.WriteByte(f.colon())
|
||||
buf.WriteString(f.prettyWithFlags(v[i+1], 0, depth+1))
|
||||
}
|
||||
if flags&flagRawStruct == 0 {
|
||||
@@ -481,7 +572,7 @@ func (f Formatter) prettyWithFlags(value any, flags uint32, depth int) string {
|
||||
continue
|
||||
}
|
||||
if printComma {
|
||||
buf.WriteByte(',')
|
||||
buf.WriteByte(f.comma())
|
||||
}
|
||||
printComma = true // if we got here, we are rendering a field
|
||||
if fld.Anonymous && fld.Type.Kind() == reflect.Struct && name == "" {
|
||||
@@ -492,10 +583,8 @@ func (f Formatter) prettyWithFlags(value any, flags uint32, depth int) string {
|
||||
name = fld.Name
|
||||
}
|
||||
// field names can't contain characters which need escaping
|
||||
buf.WriteByte('"')
|
||||
buf.WriteString(name)
|
||||
buf.WriteByte('"')
|
||||
buf.WriteByte(':')
|
||||
buf.WriteString(f.quoted(name, false))
|
||||
buf.WriteByte(f.colon())
|
||||
buf.WriteString(f.prettyWithFlags(v.Field(i).Interface(), 0, depth+1))
|
||||
}
|
||||
if flags&flagRawStruct == 0 {
|
||||
@@ -520,7 +609,7 @@ func (f Formatter) prettyWithFlags(value any, flags uint32, depth int) string {
|
||||
buf.WriteByte('[')
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
if i > 0 {
|
||||
buf.WriteByte(',')
|
||||
buf.WriteByte(f.comma())
|
||||
}
|
||||
e := v.Index(i)
|
||||
buf.WriteString(f.prettyWithFlags(e.Interface(), 0, depth+1))
|
||||
@@ -534,7 +623,7 @@ func (f Formatter) prettyWithFlags(value any, flags uint32, depth int) string {
|
||||
i := 0
|
||||
for it.Next() {
|
||||
if i > 0 {
|
||||
buf.WriteByte(',')
|
||||
buf.WriteByte(f.comma())
|
||||
}
|
||||
// If a map key supports TextMarshaler, use it.
|
||||
keystr := ""
|
||||
@@ -556,7 +645,7 @@ func (f Formatter) prettyWithFlags(value any, flags uint32, depth int) string {
|
||||
}
|
||||
}
|
||||
buf.WriteString(keystr)
|
||||
buf.WriteByte(':')
|
||||
buf.WriteByte(f.colon())
|
||||
buf.WriteString(f.prettyWithFlags(it.Value().Interface(), 0, depth+1))
|
||||
i++
|
||||
}
|
||||
@@ -706,6 +795,24 @@ func (f Formatter) sanitize(kvList []any) []any {
|
||||
return kvList
|
||||
}
|
||||
|
||||
// startGroup opens a new group scope (basically a sub-struct), which locks all
|
||||
// the current saved values and starts them anew. This is needed to satisfy
|
||||
// slog.
|
||||
func (f *Formatter) startGroup(name string) {
|
||||
// Unnamed groups are just inlined.
|
||||
if name == "" {
|
||||
return
|
||||
}
|
||||
|
||||
n := len(f.groups)
|
||||
f.groups = append(f.groups[:n:n], groupDef{f.groupName, f.valuesStr})
|
||||
|
||||
// Start collecting new values.
|
||||
f.groupName = name
|
||||
f.valuesStr = ""
|
||||
f.values = nil
|
||||
}
|
||||
|
||||
// Init configures this Formatter from runtime info, such as the call depth
|
||||
// imposed by logr itself.
|
||||
// Note that this receiver is a pointer, so depth can be saved.
|
||||
@@ -740,7 +847,10 @@ func (f Formatter) FormatInfo(level int, msg string, kvList []any) (prefix, args
|
||||
if policy := f.opts.LogCaller; policy == All || policy == Info {
|
||||
args = append(args, "caller", f.caller())
|
||||
}
|
||||
args = append(args, "level", level, "msg", msg)
|
||||
if key := *f.opts.LogInfoLevel; key != "" {
|
||||
args = append(args, key, level)
|
||||
}
|
||||
args = append(args, "msg", msg)
|
||||
return prefix, f.render(args, kvList)
|
||||
}
|
||||
|
||||
@@ -793,7 +903,7 @@ func (f *Formatter) AddValues(kvList []any) {
|
||||
|
||||
// Pre-render values, so we don't have to do it on each Info/Error call.
|
||||
buf := bytes.NewBuffer(make([]byte, 0, 1024))
|
||||
f.flatten(buf, vals, false, true) // escape user-provided keys
|
||||
f.flatten(buf, vals, true) // escape user-provided keys
|
||||
f.valuesStr = buf.String()
|
||||
}
|
||||
|
||||
|
||||
105
vendor/github.com/go-logr/logr/funcr/slogsink.go
generated
vendored
Normal file
105
vendor/github.com/go-logr/logr/funcr/slogsink.go
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
//go:build go1.21
|
||||
// +build go1.21
|
||||
|
||||
/*
|
||||
Copyright 2023 The logr Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package funcr
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
)
|
||||
|
||||
var _ logr.SlogSink = &fnlogger{}
|
||||
|
||||
const extraSlogSinkDepth = 3 // 2 for slog, 1 for SlogSink
|
||||
|
||||
func (l fnlogger) Handle(_ context.Context, record slog.Record) error {
|
||||
kvList := make([]any, 0, 2*record.NumAttrs())
|
||||
record.Attrs(func(attr slog.Attr) bool {
|
||||
kvList = attrToKVs(attr, kvList)
|
||||
return true
|
||||
})
|
||||
|
||||
if record.Level >= slog.LevelError {
|
||||
l.WithCallDepth(extraSlogSinkDepth).Error(nil, record.Message, kvList...)
|
||||
} else {
|
||||
level := l.levelFromSlog(record.Level)
|
||||
l.WithCallDepth(extraSlogSinkDepth).Info(level, record.Message, kvList...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l fnlogger) WithAttrs(attrs []slog.Attr) logr.SlogSink {
|
||||
kvList := make([]any, 0, 2*len(attrs))
|
||||
for _, attr := range attrs {
|
||||
kvList = attrToKVs(attr, kvList)
|
||||
}
|
||||
l.AddValues(kvList)
|
||||
return &l
|
||||
}
|
||||
|
||||
func (l fnlogger) WithGroup(name string) logr.SlogSink {
|
||||
l.startGroup(name)
|
||||
return &l
|
||||
}
|
||||
|
||||
// attrToKVs appends a slog.Attr to a logr-style kvList. It handle slog Groups
|
||||
// and other details of slog.
|
||||
func attrToKVs(attr slog.Attr, kvList []any) []any {
|
||||
attrVal := attr.Value.Resolve()
|
||||
if attrVal.Kind() == slog.KindGroup {
|
||||
groupVal := attrVal.Group()
|
||||
grpKVs := make([]any, 0, 2*len(groupVal))
|
||||
for _, attr := range groupVal {
|
||||
grpKVs = attrToKVs(attr, grpKVs)
|
||||
}
|
||||
if attr.Key == "" {
|
||||
// slog says we have to inline these
|
||||
kvList = append(kvList, grpKVs...)
|
||||
} else {
|
||||
kvList = append(kvList, attr.Key, PseudoStruct(grpKVs))
|
||||
}
|
||||
} else if attr.Key != "" {
|
||||
kvList = append(kvList, attr.Key, attrVal.Any())
|
||||
}
|
||||
|
||||
return kvList
|
||||
}
|
||||
|
||||
// levelFromSlog adjusts the level by the logger's verbosity and negates it.
|
||||
// It ensures that the result is >= 0. This is necessary because the result is
|
||||
// passed to a LogSink and that API did not historically document whether
|
||||
// levels could be negative or what that meant.
|
||||
//
|
||||
// Some example usage:
|
||||
//
|
||||
// logrV0 := getMyLogger()
|
||||
// logrV2 := logrV0.V(2)
|
||||
// slogV2 := slog.New(logr.ToSlogHandler(logrV2))
|
||||
// slogV2.Debug("msg") // =~ logrV2.V(4) =~ logrV0.V(6)
|
||||
// slogV2.Info("msg") // =~ logrV2.V(0) =~ logrV0.V(2)
|
||||
// slogv2.Warn("msg") // =~ logrV2.V(-4) =~ logrV0.V(0)
|
||||
func (l fnlogger) levelFromSlog(level slog.Level) int {
|
||||
result := -level
|
||||
if result < 0 {
|
||||
result = 0 // because LogSink doesn't expect negative V levels
|
||||
}
|
||||
return int(result)
|
||||
}
|
||||
43
vendor/github.com/go-logr/logr/logr.go
generated
vendored
43
vendor/github.com/go-logr/logr/logr.go
generated
vendored
@@ -207,10 +207,6 @@ limitations under the License.
|
||||
// those.
|
||||
package logr
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// New returns a new Logger instance. This is primarily used by libraries
|
||||
// implementing LogSink, rather than end users. Passing a nil sink will create
|
||||
// a Logger which discards all log lines.
|
||||
@@ -410,45 +406,6 @@ func (l Logger) IsZero() bool {
|
||||
return l.sink == nil
|
||||
}
|
||||
|
||||
// contextKey is how we find Loggers in a context.Context.
|
||||
type contextKey struct{}
|
||||
|
||||
// FromContext returns a Logger from ctx or an error if no Logger is found.
|
||||
func FromContext(ctx context.Context) (Logger, error) {
|
||||
if v, ok := ctx.Value(contextKey{}).(Logger); ok {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
return Logger{}, notFoundError{}
|
||||
}
|
||||
|
||||
// notFoundError exists to carry an IsNotFound method.
|
||||
type notFoundError struct{}
|
||||
|
||||
func (notFoundError) Error() string {
|
||||
return "no logr.Logger was present"
|
||||
}
|
||||
|
||||
func (notFoundError) IsNotFound() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// FromContextOrDiscard returns a Logger from ctx. If no Logger is found, this
|
||||
// returns a Logger that discards all log messages.
|
||||
func FromContextOrDiscard(ctx context.Context) Logger {
|
||||
if v, ok := ctx.Value(contextKey{}).(Logger); ok {
|
||||
return v
|
||||
}
|
||||
|
||||
return Discard()
|
||||
}
|
||||
|
||||
// NewContext returns a new Context, derived from ctx, which carries the
|
||||
// provided Logger.
|
||||
func NewContext(ctx context.Context, logger Logger) context.Context {
|
||||
return context.WithValue(ctx, contextKey{}, logger)
|
||||
}
|
||||
|
||||
// RuntimeInfo holds information that the logr "core" library knows which
|
||||
// LogSinks might want to know.
|
||||
type RuntimeInfo struct {
|
||||
|
||||
192
vendor/github.com/go-logr/logr/sloghandler.go
generated
vendored
Normal file
192
vendor/github.com/go-logr/logr/sloghandler.go
generated
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
//go:build go1.21
|
||||
// +build go1.21
|
||||
|
||||
/*
|
||||
Copyright 2023 The logr Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package logr
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type slogHandler struct {
|
||||
// May be nil, in which case all logs get discarded.
|
||||
sink LogSink
|
||||
// Non-nil if sink is non-nil and implements SlogSink.
|
||||
slogSink SlogSink
|
||||
|
||||
// groupPrefix collects values from WithGroup calls. It gets added as
|
||||
// prefix to value keys when handling a log record.
|
||||
groupPrefix string
|
||||
|
||||
// levelBias can be set when constructing the handler to influence the
|
||||
// slog.Level of log records. A positive levelBias reduces the
|
||||
// slog.Level value. slog has no API to influence this value after the
|
||||
// handler got created, so it can only be set indirectly through
|
||||
// Logger.V.
|
||||
levelBias slog.Level
|
||||
}
|
||||
|
||||
var _ slog.Handler = &slogHandler{}
|
||||
|
||||
// groupSeparator is used to concatenate WithGroup names and attribute keys.
|
||||
const groupSeparator = "."
|
||||
|
||||
// GetLevel is used for black box unit testing.
|
||||
func (l *slogHandler) GetLevel() slog.Level {
|
||||
return l.levelBias
|
||||
}
|
||||
|
||||
func (l *slogHandler) Enabled(_ context.Context, level slog.Level) bool {
|
||||
return l.sink != nil && (level >= slog.LevelError || l.sink.Enabled(l.levelFromSlog(level)))
|
||||
}
|
||||
|
||||
func (l *slogHandler) Handle(ctx context.Context, record slog.Record) error {
|
||||
if l.slogSink != nil {
|
||||
// Only adjust verbosity level of log entries < slog.LevelError.
|
||||
if record.Level < slog.LevelError {
|
||||
record.Level -= l.levelBias
|
||||
}
|
||||
return l.slogSink.Handle(ctx, record)
|
||||
}
|
||||
|
||||
// No need to check for nil sink here because Handle will only be called
|
||||
// when Enabled returned true.
|
||||
|
||||
kvList := make([]any, 0, 2*record.NumAttrs())
|
||||
record.Attrs(func(attr slog.Attr) bool {
|
||||
kvList = attrToKVs(attr, l.groupPrefix, kvList)
|
||||
return true
|
||||
})
|
||||
if record.Level >= slog.LevelError {
|
||||
l.sinkWithCallDepth().Error(nil, record.Message, kvList...)
|
||||
} else {
|
||||
level := l.levelFromSlog(record.Level)
|
||||
l.sinkWithCallDepth().Info(level, record.Message, kvList...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// sinkWithCallDepth adjusts the stack unwinding so that when Error or Info
|
||||
// are called by Handle, code in slog gets skipped.
|
||||
//
|
||||
// This offset currently (Go 1.21.0) works for calls through
|
||||
// slog.New(ToSlogHandler(...)). There's no guarantee that the call
|
||||
// chain won't change. Wrapping the handler will also break unwinding. It's
|
||||
// still better than not adjusting at all....
|
||||
//
|
||||
// This cannot be done when constructing the handler because FromSlogHandler needs
|
||||
// access to the original sink without this adjustment. A second copy would
|
||||
// work, but then WithAttrs would have to be called for both of them.
|
||||
func (l *slogHandler) sinkWithCallDepth() LogSink {
|
||||
if sink, ok := l.sink.(CallDepthLogSink); ok {
|
||||
return sink.WithCallDepth(2)
|
||||
}
|
||||
return l.sink
|
||||
}
|
||||
|
||||
func (l *slogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
|
||||
if l.sink == nil || len(attrs) == 0 {
|
||||
return l
|
||||
}
|
||||
|
||||
clone := *l
|
||||
if l.slogSink != nil {
|
||||
clone.slogSink = l.slogSink.WithAttrs(attrs)
|
||||
clone.sink = clone.slogSink
|
||||
} else {
|
||||
kvList := make([]any, 0, 2*len(attrs))
|
||||
for _, attr := range attrs {
|
||||
kvList = attrToKVs(attr, l.groupPrefix, kvList)
|
||||
}
|
||||
clone.sink = l.sink.WithValues(kvList...)
|
||||
}
|
||||
return &clone
|
||||
}
|
||||
|
||||
func (l *slogHandler) WithGroup(name string) slog.Handler {
|
||||
if l.sink == nil {
|
||||
return l
|
||||
}
|
||||
if name == "" {
|
||||
// slog says to inline empty groups
|
||||
return l
|
||||
}
|
||||
clone := *l
|
||||
if l.slogSink != nil {
|
||||
clone.slogSink = l.slogSink.WithGroup(name)
|
||||
clone.sink = clone.slogSink
|
||||
} else {
|
||||
clone.groupPrefix = addPrefix(clone.groupPrefix, name)
|
||||
}
|
||||
return &clone
|
||||
}
|
||||
|
||||
// attrToKVs appends a slog.Attr to a logr-style kvList. It handle slog Groups
|
||||
// and other details of slog.
|
||||
func attrToKVs(attr slog.Attr, groupPrefix string, kvList []any) []any {
|
||||
attrVal := attr.Value.Resolve()
|
||||
if attrVal.Kind() == slog.KindGroup {
|
||||
groupVal := attrVal.Group()
|
||||
grpKVs := make([]any, 0, 2*len(groupVal))
|
||||
prefix := groupPrefix
|
||||
if attr.Key != "" {
|
||||
prefix = addPrefix(groupPrefix, attr.Key)
|
||||
}
|
||||
for _, attr := range groupVal {
|
||||
grpKVs = attrToKVs(attr, prefix, grpKVs)
|
||||
}
|
||||
kvList = append(kvList, grpKVs...)
|
||||
} else if attr.Key != "" {
|
||||
kvList = append(kvList, addPrefix(groupPrefix, attr.Key), attrVal.Any())
|
||||
}
|
||||
|
||||
return kvList
|
||||
}
|
||||
|
||||
func addPrefix(prefix, name string) string {
|
||||
if prefix == "" {
|
||||
return name
|
||||
}
|
||||
if name == "" {
|
||||
return prefix
|
||||
}
|
||||
return prefix + groupSeparator + name
|
||||
}
|
||||
|
||||
// levelFromSlog adjusts the level by the logger's verbosity and negates it.
|
||||
// It ensures that the result is >= 0. This is necessary because the result is
|
||||
// passed to a LogSink and that API did not historically document whether
|
||||
// levels could be negative or what that meant.
|
||||
//
|
||||
// Some example usage:
|
||||
//
|
||||
// logrV0 := getMyLogger()
|
||||
// logrV2 := logrV0.V(2)
|
||||
// slogV2 := slog.New(logr.ToSlogHandler(logrV2))
|
||||
// slogV2.Debug("msg") // =~ logrV2.V(4) =~ logrV0.V(6)
|
||||
// slogV2.Info("msg") // =~ logrV2.V(0) =~ logrV0.V(2)
|
||||
// slogv2.Warn("msg") // =~ logrV2.V(-4) =~ logrV0.V(0)
|
||||
func (l *slogHandler) levelFromSlog(level slog.Level) int {
|
||||
result := -level
|
||||
result += l.levelBias // in case the original Logger had a V level
|
||||
if result < 0 {
|
||||
result = 0 // because LogSink doesn't expect negative V levels
|
||||
}
|
||||
return int(result)
|
||||
}
|
||||
100
vendor/github.com/go-logr/logr/slogr.go
generated
vendored
Normal file
100
vendor/github.com/go-logr/logr/slogr.go
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
//go:build go1.21
|
||||
// +build go1.21
|
||||
|
||||
/*
|
||||
Copyright 2023 The logr Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package logr
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
// FromSlogHandler returns a Logger which writes to the slog.Handler.
|
||||
//
|
||||
// The logr verbosity level is mapped to slog levels such that V(0) becomes
|
||||
// slog.LevelInfo and V(4) becomes slog.LevelDebug.
|
||||
func FromSlogHandler(handler slog.Handler) Logger {
|
||||
if handler, ok := handler.(*slogHandler); ok {
|
||||
if handler.sink == nil {
|
||||
return Discard()
|
||||
}
|
||||
return New(handler.sink).V(int(handler.levelBias))
|
||||
}
|
||||
return New(&slogSink{handler: handler})
|
||||
}
|
||||
|
||||
// ToSlogHandler returns a slog.Handler which writes to the same sink as the Logger.
|
||||
//
|
||||
// The returned logger writes all records with level >= slog.LevelError as
|
||||
// error log entries with LogSink.Error, regardless of the verbosity level of
|
||||
// the Logger:
|
||||
//
|
||||
// logger := <some Logger with 0 as verbosity level>
|
||||
// slog.New(ToSlogHandler(logger.V(10))).Error(...) -> logSink.Error(...)
|
||||
//
|
||||
// The level of all other records gets reduced by the verbosity
|
||||
// level of the Logger and the result is negated. If it happens
|
||||
// to be negative, then it gets replaced by zero because a LogSink
|
||||
// is not expected to handled negative levels:
|
||||
//
|
||||
// slog.New(ToSlogHandler(logger)).Debug(...) -> logger.GetSink().Info(level=4, ...)
|
||||
// slog.New(ToSlogHandler(logger)).Warning(...) -> logger.GetSink().Info(level=0, ...)
|
||||
// slog.New(ToSlogHandler(logger)).Info(...) -> logger.GetSink().Info(level=0, ...)
|
||||
// slog.New(ToSlogHandler(logger.V(4))).Info(...) -> logger.GetSink().Info(level=4, ...)
|
||||
func ToSlogHandler(logger Logger) slog.Handler {
|
||||
if sink, ok := logger.GetSink().(*slogSink); ok && logger.GetV() == 0 {
|
||||
return sink.handler
|
||||
}
|
||||
|
||||
handler := &slogHandler{sink: logger.GetSink(), levelBias: slog.Level(logger.GetV())}
|
||||
if slogSink, ok := handler.sink.(SlogSink); ok {
|
||||
handler.slogSink = slogSink
|
||||
}
|
||||
return handler
|
||||
}
|
||||
|
||||
// SlogSink is an optional interface that a LogSink can implement to support
|
||||
// logging through the slog.Logger or slog.Handler APIs better. It then should
|
||||
// also support special slog values like slog.Group. When used as a
|
||||
// slog.Handler, the advantages are:
|
||||
//
|
||||
// - stack unwinding gets avoided in favor of logging the pre-recorded PC,
|
||||
// as intended by slog
|
||||
// - proper grouping of key/value pairs via WithGroup
|
||||
// - verbosity levels > slog.LevelInfo can be recorded
|
||||
// - less overhead
|
||||
//
|
||||
// Both APIs (Logger and slog.Logger/Handler) then are supported equally
|
||||
// well. Developers can pick whatever API suits them better and/or mix
|
||||
// packages which use either API in the same binary with a common logging
|
||||
// implementation.
|
||||
//
|
||||
// This interface is necessary because the type implementing the LogSink
|
||||
// interface cannot also implement the slog.Handler interface due to the
|
||||
// different prototype of the common Enabled method.
|
||||
//
|
||||
// An implementation could support both interfaces in two different types, but then
|
||||
// additional interfaces would be needed to convert between those types in FromSlogHandler
|
||||
// and ToSlogHandler.
|
||||
type SlogSink interface {
|
||||
LogSink
|
||||
|
||||
Handle(ctx context.Context, record slog.Record) error
|
||||
WithAttrs(attrs []slog.Attr) SlogSink
|
||||
WithGroup(name string) SlogSink
|
||||
}
|
||||
120
vendor/github.com/go-logr/logr/slogsink.go
generated
vendored
Normal file
120
vendor/github.com/go-logr/logr/slogsink.go
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
//go:build go1.21
|
||||
// +build go1.21
|
||||
|
||||
/*
|
||||
Copyright 2023 The logr Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package logr
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
_ LogSink = &slogSink{}
|
||||
_ CallDepthLogSink = &slogSink{}
|
||||
_ Underlier = &slogSink{}
|
||||
)
|
||||
|
||||
// Underlier is implemented by the LogSink returned by NewFromLogHandler.
|
||||
type Underlier interface {
|
||||
// GetUnderlying returns the Handler used by the LogSink.
|
||||
GetUnderlying() slog.Handler
|
||||
}
|
||||
|
||||
const (
|
||||
// nameKey is used to log the `WithName` values as an additional attribute.
|
||||
nameKey = "logger"
|
||||
|
||||
// errKey is used to log the error parameter of Error as an additional attribute.
|
||||
errKey = "err"
|
||||
)
|
||||
|
||||
type slogSink struct {
|
||||
callDepth int
|
||||
name string
|
||||
handler slog.Handler
|
||||
}
|
||||
|
||||
func (l *slogSink) Init(info RuntimeInfo) {
|
||||
l.callDepth = info.CallDepth
|
||||
}
|
||||
|
||||
func (l *slogSink) GetUnderlying() slog.Handler {
|
||||
return l.handler
|
||||
}
|
||||
|
||||
func (l *slogSink) WithCallDepth(depth int) LogSink {
|
||||
newLogger := *l
|
||||
newLogger.callDepth += depth
|
||||
return &newLogger
|
||||
}
|
||||
|
||||
func (l *slogSink) Enabled(level int) bool {
|
||||
return l.handler.Enabled(context.Background(), slog.Level(-level))
|
||||
}
|
||||
|
||||
func (l *slogSink) Info(level int, msg string, kvList ...interface{}) {
|
||||
l.log(nil, msg, slog.Level(-level), kvList...)
|
||||
}
|
||||
|
||||
func (l *slogSink) Error(err error, msg string, kvList ...interface{}) {
|
||||
l.log(err, msg, slog.LevelError, kvList...)
|
||||
}
|
||||
|
||||
func (l *slogSink) log(err error, msg string, level slog.Level, kvList ...interface{}) {
|
||||
var pcs [1]uintptr
|
||||
// skip runtime.Callers, this function, Info/Error, and all helper functions above that.
|
||||
runtime.Callers(3+l.callDepth, pcs[:])
|
||||
|
||||
record := slog.NewRecord(time.Now(), level, msg, pcs[0])
|
||||
if l.name != "" {
|
||||
record.AddAttrs(slog.String(nameKey, l.name))
|
||||
}
|
||||
if err != nil {
|
||||
record.AddAttrs(slog.Any(errKey, err))
|
||||
}
|
||||
record.Add(kvList...)
|
||||
_ = l.handler.Handle(context.Background(), record)
|
||||
}
|
||||
|
||||
func (l slogSink) WithName(name string) LogSink {
|
||||
if l.name != "" {
|
||||
l.name += "/"
|
||||
}
|
||||
l.name += name
|
||||
return &l
|
||||
}
|
||||
|
||||
func (l slogSink) WithValues(kvList ...interface{}) LogSink {
|
||||
l.handler = l.handler.WithAttrs(kvListToAttrs(kvList...))
|
||||
return &l
|
||||
}
|
||||
|
||||
func kvListToAttrs(kvList ...interface{}) []slog.Attr {
|
||||
// We don't need the record itself, only its Add method.
|
||||
record := slog.NewRecord(time.Time{}, 0, "", 0)
|
||||
record.Add(kvList...)
|
||||
attrs := make([]slog.Attr, 0, record.NumAttrs())
|
||||
record.Attrs(func(attr slog.Attr) bool {
|
||||
attrs = append(attrs, attr)
|
||||
return true
|
||||
})
|
||||
return attrs
|
||||
}
|
||||
8
vendor/modules.txt
vendored
8
vendor/modules.txt
vendored
@@ -158,8 +158,8 @@ github.com/containerd/imgcrypt/images/encryption
|
||||
## explicit; go 1.20
|
||||
github.com/containerd/log
|
||||
github.com/containerd/log/logtest
|
||||
# github.com/containerd/nri v0.6.1
|
||||
## explicit; go 1.19
|
||||
# github.com/containerd/nri v0.8.0
|
||||
## explicit; go 1.21
|
||||
github.com/containerd/nri
|
||||
github.com/containerd/nri/pkg/adaptation
|
||||
github.com/containerd/nri/pkg/api
|
||||
@@ -172,7 +172,7 @@ github.com/containerd/nri/types/v1
|
||||
# github.com/containerd/platforms v0.2.1
|
||||
## explicit; go 1.20
|
||||
github.com/containerd/platforms
|
||||
# github.com/containerd/ttrpc v1.2.5
|
||||
# github.com/containerd/ttrpc v1.2.7
|
||||
## explicit; go 1.19
|
||||
github.com/containerd/ttrpc
|
||||
# github.com/containerd/typeurl v1.0.2
|
||||
@@ -254,7 +254,7 @@ github.com/fsnotify/fsnotify
|
||||
github.com/go-jose/go-jose/v3
|
||||
github.com/go-jose/go-jose/v3/cipher
|
||||
github.com/go-jose/go-jose/v3/json
|
||||
# github.com/go-logr/logr v1.3.0
|
||||
# github.com/go-logr/logr v1.4.2
|
||||
## explicit; go 1.18
|
||||
github.com/go-logr/logr
|
||||
github.com/go-logr/logr/funcr
|
||||
|
||||
Reference in New Issue
Block a user