| @@ -5,6 +5,7 @@ go 1.23.0 | |||
| require ( | |||
| github.com/JCCE-nudt/apigw-go-sdk v0.0.0-20230525025609-34159d6f2818 | |||
| github.com/Masterminds/squirrel v1.5.4 | |||
| github.com/aliyun/alibaba-cloud-sdk-go v1.63.107 | |||
| github.com/bwmarrin/snowflake v0.3.0 | |||
| github.com/ghodss/yaml v1.0.0 | |||
| github.com/go-redis/redis/v8 v8.11.5 | |||
| @@ -128,7 +129,7 @@ require ( | |||
| github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect | |||
| github.com/oklog/run v1.1.0 // indirect | |||
| github.com/oklog/ulid v1.3.1 // indirect | |||
| github.com/opentracing/opentracing-go v1.2.0 // indirect | |||
| github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect | |||
| github.com/openzipkin/zipkin-go v0.4.3 // indirect | |||
| github.com/pelletier/go-toml/v2 v2.2.3 // indirect | |||
| github.com/prometheus/client_model v0.6.1 // indirect | |||
| @@ -38,10 +38,12 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym | |||
| github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU= | |||
| github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= | |||
| github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= | |||
| github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= | |||
| github.com/JCCE-nudt/apigw-go-sdk v0.0.0-20230525025609-34159d6f2818 h1:QLulhUyxPDs9FFieVZwmKAnUBLeRDhsVNehotAAL/FE= | |||
| github.com/JCCE-nudt/apigw-go-sdk v0.0.0-20230525025609-34159d6f2818/go.mod h1:j+am5/1URgsvyhOAyURFR9vH3malaW7Tq6d33OyPsnM= | |||
| github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM= | |||
| github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= | |||
| github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= | |||
| github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY= | |||
| github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE= | |||
| github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= | |||
| @@ -55,6 +57,8 @@ github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO | |||
| github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= | |||
| github.com/alicebob/miniredis/v2 v2.33.0 h1:uvTF0EDeu9RLnUEG27Db5I68ESoIxTiXbNUiji6lZrA= | |||
| github.com/alicebob/miniredis/v2 v2.33.0/go.mod h1:MhP4a3EU7aENRi9aO+tHfTBZicLqQevyi/DJpoj6mi0= | |||
| github.com/aliyun/alibaba-cloud-sdk-go v1.63.107 h1:qagvUyrgOnBIlVRQWOyCZGVKUIYbMBdGdJ104vBpRFU= | |||
| github.com/aliyun/alibaba-cloud-sdk-go v1.63.107/go.mod h1:SOSDHfe1kX91v3W5QiBsWSLqeLxImobbMX1mxrFHsVQ= | |||
| github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= | |||
| github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= | |||
| github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= | |||
| @@ -101,6 +105,7 @@ github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03V | |||
| github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= | |||
| github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= | |||
| github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= | |||
| github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= | |||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | |||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | |||
| github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= | |||
| @@ -115,6 +120,7 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m | |||
| github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= | |||
| github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= | |||
| github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= | |||
| github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= | |||
| github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= | |||
| github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= | |||
| github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= | |||
| @@ -194,6 +200,7 @@ github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRx | |||
| github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= | |||
| github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= | |||
| github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= | |||
| github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= | |||
| github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= | |||
| github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= | |||
| github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= | |||
| @@ -202,6 +209,7 @@ github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0kt | |||
| github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= | |||
| github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= | |||
| github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI= | |||
| github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= | |||
| github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= | |||
| github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= | |||
| github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= | |||
| @@ -334,6 +342,7 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1 | |||
| github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= | |||
| github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= | |||
| github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= | |||
| github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= | |||
| github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= | |||
| github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | |||
| github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= | |||
| @@ -395,6 +404,7 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m | |||
| github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= | |||
| github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= | |||
| github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= | |||
| github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= | |||
| github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= | |||
| github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= | |||
| github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= | |||
| @@ -407,8 +417,8 @@ github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA | |||
| github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= | |||
| github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= | |||
| github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= | |||
| github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= | |||
| github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= | |||
| github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b h1:FfH+VrHHk6Lxt9HdVS0PXzSXFyS2NbZKXv33FYPol0A= | |||
| github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b/go.mod h1:AC62GU6hc0BrNm+9RK9VSiwa/EUe1bkIeFORAMcHvJU= | |||
| github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7sjsSdg= | |||
| github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c= | |||
| github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= | |||
| @@ -516,6 +526,10 @@ github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSW | |||
| github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= | |||
| github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= | |||
| github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= | |||
| github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o= | |||
| github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= | |||
| github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg= | |||
| github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= | |||
| github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= | |||
| github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= | |||
| github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= | |||
| @@ -582,6 +596,7 @@ go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQD | |||
| go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= | |||
| go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg= | |||
| go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY= | |||
| go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= | |||
| go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= | |||
| go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= | |||
| go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= | |||
| @@ -603,7 +618,10 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U | |||
| golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | |||
| golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= | |||
| golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= | |||
| golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | |||
| golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | |||
| golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | |||
| golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | |||
| golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | |||
| golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= | |||
| golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= | |||
| @@ -615,6 +633,7 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH | |||
| golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= | |||
| golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= | |||
| golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= | |||
| golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= | |||
| golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= | |||
| golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | |||
| golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= | |||
| @@ -757,8 +776,10 @@ golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxb | |||
| golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | |||
| golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg= | |||
| golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= | |||
| golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | |||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | |||
| golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | |||
| golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | |||
| golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= | |||
| golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= | |||
| golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= | |||
| @@ -807,8 +828,12 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T | |||
| 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= | |||
| golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
| gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= | |||
| gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= | |||
| gonum.org/v1/gonum v0.11.0 h1:f1IJhK4Km5tBJmaiJXtk/PkL4cdVX6J+tGiM187uT5E= | |||
| gonum.org/v1/gonum v0.11.0/go.mod h1:fSG4YDCxxUZQJ7rKsQrj0gMOg00Il0Z96/qMA4bVQhA= | |||
| gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= | |||
| gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= | |||
| google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= | |||
| google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= | |||
| google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= | |||
| @@ -895,6 +920,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks | |||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | |||
| gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | |||
| gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | |||
| gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | |||
| gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= | |||
| gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= | |||
| gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= | |||
| @@ -915,6 +941,7 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | |||
| gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= | |||
| gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= | |||
| gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | |||
| gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | |||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | |||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | |||
| gorm.io/datatypes v1.2.0 h1:5YT+eokWdIxhJgWHdrb2zYUimyk0+TaFth+7a0ybzco= | |||
| @@ -951,6 +978,7 @@ k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJ | |||
| k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= | |||
| nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= | |||
| rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= | |||
| rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= | |||
| rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= | |||
| rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= | |||
| sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE= | |||
| @@ -1,10 +1,11 @@ | |||
| package cloud | |||
| import ( | |||
| "encoding/json" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" | |||
| "io" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" | |||
| @@ -19,7 +20,6 @@ func ContainerLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| result.ParamErrorResult(r, w, err) | |||
| return | |||
| } | |||
| if err = json.Unmarshal(body, &req); err != nil { | |||
| result.ParamErrorResult(r, w, err) | |||
| return | |||
| @@ -26,6 +26,7 @@ import ( | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" | |||
| cloud2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models/cloud" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| "strconv" | |||
| "time" | |||
| @@ -72,6 +73,10 @@ func (l *ContainerCreateLogic) ContainerCreate(req *container.CreateParam) (resp | |||
| if create.Code != http.StatusOK { | |||
| return nil, errors.New(create.Message) | |||
| } | |||
| marshal, err := json.Marshal(create.Data) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| // 构建主任务结构体 | |||
| taskModel := models.Task{ | |||
| Id: utils.GenSnowflakeID(), | |||
| @@ -82,6 +87,7 @@ func (l *ContainerCreateLogic) ContainerCreate(req *container.CreateParam) (resp | |||
| AdapterTypeDict: "0", | |||
| CommitTime: time.Now(), | |||
| } | |||
| // 保存任务数据到数据库 | |||
| tx := l.svcCtx.DbEngin.Create(&taskModel) | |||
| if tx.Error != nil { | |||
| @@ -91,14 +97,15 @@ func (l *ContainerCreateLogic) ContainerCreate(req *container.CreateParam) (resp | |||
| tx.Table("t_cluster").Select("adapter_id").Where("id=?", req.ClusterId).Find(&adapterId) | |||
| // 构建cloud任务结构体 | |||
| cloudTaskModel := cloud2.TaskCloudModel{ | |||
| Id: utils.GenSnowflakeID(), | |||
| TaskId: taskModel.Id, | |||
| Name: req.Name, | |||
| AdapterId: adapterId, | |||
| Status: constants.Saved, | |||
| Namespace: "default", | |||
| UserId: req.UserId, | |||
| ClusterId: req.ClusterId, | |||
| Id: utils.GenSnowflakeID(), | |||
| TaskId: taskModel.Id, | |||
| Name: req.Name, | |||
| AdapterId: adapterId, | |||
| Status: constants.Saved, | |||
| Namespace: "default", | |||
| UserId: req.UserId, | |||
| ClusterId: req.ClusterId, | |||
| BusinessCode: string(marshal), | |||
| ResourceSpec: cloud2.ResourceSpec{ | |||
| CPU: req.Cpu, | |||
| Memory: req.Memory, | |||
| @@ -17,11 +17,13 @@ package cloud | |||
| import ( | |||
| "context" | |||
| "errors" | |||
| "fmt" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/participant/cloud" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" | |||
| container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" | |||
| "net/http" | |||
| "strconv" | |||
| ) | |||
| type ContainerDeleteLogic struct { | |||
| @@ -39,10 +41,8 @@ func NewContainerDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C | |||
| } | |||
| func (l *ContainerDeleteLogic) ContainerDelete(req *container.DeleteParam) (resp interface{}, err error) { | |||
| param := &cloud.DeleteParam{ | |||
| Name: req.Name, | |||
| } | |||
| create, err := l.svcCtx.Cloud.ContainerDelete(req.ClusterId, param) | |||
| create, err := l.svcCtx.Cloud.ContainerDelete(req.ClusterId, req) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| @@ -50,5 +50,11 @@ func (l *ContainerDeleteLogic) ContainerDelete(req *container.DeleteParam) (resp | |||
| return nil, errors.New(create.Message) | |||
| } | |||
| resp = create.Data | |||
| id, err := strconv.ParseInt(req.Id, 10, 64) | |||
| tx := l.svcCtx.DbEngin.Delete(&models.TaskCloud{}, id) | |||
| if tx.Error != nil { | |||
| fmt.Println() | |||
| return nil, tx.Error | |||
| } | |||
| return | |||
| } | |||
| @@ -38,10 +38,7 @@ func NewContainerLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cont | |||
| } | |||
| func (l *ContainerGetLogic) ContainerLog(req *container.LogParam) (resp interface{}, err error) { | |||
| param := &container.LogParam{ | |||
| Name: req.Name, | |||
| } | |||
| get, err := l.svcCtx.Cloud.ContainerLog(req.ClusterId, param) | |||
| get, err := l.svcCtx.Cloud.ContainerLog(req.ClusterId, req) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| @@ -49,5 +46,6 @@ func (l *ContainerGetLogic) ContainerLog(req *container.LogParam) (resp interfac | |||
| return nil, errors.New(get.Message) | |||
| } | |||
| resp = get.Data | |||
| return | |||
| return resp, nil | |||
| } | |||
| @@ -61,13 +61,18 @@ func (c *Cloud) ContainerCreate(platformId string, param *CreateParam) (resp *Re | |||
| return resp, nil | |||
| } | |||
| func (c *Cloud) ContainerDelete(platformId string, param *DeleteParam) (resp *Resp, err error) { | |||
| func (c *Cloud) ContainerDelete(platformId string, param *cloud.DeleteParam) (resp *Resp, err error) { | |||
| marshal, err := json.Marshal(param) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| println(string(marshal)) | |||
| addr, ok := c.GetServerAddrById(platformId) | |||
| if !ok { | |||
| return nil, fmt.Errorf("clusterId not found: %s", platformId) | |||
| } | |||
| respErr := &RespErr{} | |||
| _, err = Request(addr+DeleteContainer, http.MethodDelete, func(req *resty.Request) { | |||
| _, err = Request(addr+DeleteContainer, http.MethodPost, func(req *resty.Request) { | |||
| req.SetQueryParams(map[string]string{ | |||
| "pfId": platformId, | |||
| }).SetBody(param).SetError(&respErr).SetResult(&resp) | |||
| @@ -84,10 +89,9 @@ func (c *Cloud) ContainerGet(platformId string, param *GetParam) (resp *Resp, er | |||
| return nil, fmt.Errorf("clusterId not found: %s", platformId) | |||
| } | |||
| respErr := &RespErr{} | |||
| _, err = Request(addr+GetContainer, http.MethodGet, func(req *resty.Request) { | |||
| _, err = Request(addr+GetContainer, http.MethodPost, func(req *resty.Request) { | |||
| req.SetQueryParams(map[string]string{ | |||
| "pfId": platformId, | |||
| "name": param.Name, | |||
| }).SetBody(param).SetError(&respErr).SetResult(&resp) | |||
| }) | |||
| if err != nil { | |||
| @@ -124,16 +128,21 @@ func (c *Cloud) ContainerLog(platformId string, param *cloud.LogParam) (resp *Re | |||
| if !ok { | |||
| return nil, fmt.Errorf("clusterId not found: %s", platformId) | |||
| } | |||
| bytes, err := json.Marshal(param) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| fmt.Printf(string(bytes)) | |||
| respErr := &RespErr{} | |||
| _, err = Request(addr+LogContainer, http.MethodGet, func(req *resty.Request) { | |||
| asd, err := Request(addr+LogContainer, http.MethodPost, func(req *resty.Request) { | |||
| req.SetQueryParams(map[string]string{ | |||
| "pfId": platformId, | |||
| "name": param.Name, | |||
| }).SetError(&respErr).SetResult(&resp) | |||
| }).SetBody(param).SetError(&respErr).SetResult(&resp) | |||
| }) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| json.Marshal(asd) | |||
| marshal, err := json.Marshal(resp.Data) | |||
| if err != nil { | |||
| return nil, err | |||
| @@ -3,6 +3,7 @@ package cloud | |||
| import ( | |||
| "context" | |||
| "fmt" | |||
| "github.com/aliyun/alibaba-cloud-sdk-go/services/eci" | |||
| "github.com/go-resty/resty/v2" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/participant/cloud" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" | |||
| @@ -11,6 +12,7 @@ import ( | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/restyclient" | |||
| v1 "k8s.io/api/core/v1" | |||
| v2 "k8s.io/apimachinery/pkg/apis/meta/v1" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| ) | |||
| // 定义枚举类型 | |||
| @@ -33,7 +35,8 @@ func NewCloud(host string, id int64, platform string) *ParticipantCloud { | |||
| } | |||
| } | |||
| func (c *ParticipantCloud) GetContainer(ctx context.Context, taskId string, clusterId string) (*collector.Task, error) { | |||
| func (c *ParticipantCloud) GetContainer(ctx context.Context, name string, queryParam string, clusterId string) (collector.Task, error) { | |||
| resp := collector.Task{} | |||
| reqUrl := c.host + cloud.GetContainer | |||
| containerResp := &collector.ContainerDetailResp{} | |||
| httpClient := resty.New().R() | |||
| @@ -44,48 +47,34 @@ func (c *ParticipantCloud) GetContainer(ctx context.Context, taskId string, clus | |||
| }). | |||
| SetQueryParams(map[string]string{ | |||
| "pfId": clusterId, | |||
| "name": taskId, | |||
| }). | |||
| }).SetBody(cloud.GetParam{Name: name}). | |||
| SetResult(&containerResp). | |||
| Get(reqUrl) | |||
| Post(reqUrl) | |||
| if err != nil { | |||
| return nil, err | |||
| return resp, err | |||
| } | |||
| fmt.Println("containerResp:", containerResp.Data) | |||
| var resp collector.Task | |||
| status := getStatusEnum(containerResp.Data) | |||
| resp.Status = status | |||
| // 提取 StartTime(Pod 启动时间) | |||
| startTime := containerResp.Data.Status.StartTime | |||
| if startTime == nil { | |||
| fmt.Println("Pod 尚未启动,无 startTime") | |||
| } else { | |||
| resp.Start = startTime.Time.Format("2006-01-02 15:04:05") | |||
| } | |||
| // 提取 EndTime(容器终止时间,仅当 Pod 已结束时存在) | |||
| // 遍历所有容器状态,查找已终止的容器 | |||
| var endTime *v2.Time | |||
| for _, containerStatus := range containerResp.Data.Status.ContainerStatuses { | |||
| if containerStatus.State.Terminated != nil { | |||
| endTime = &containerStatus.State.Terminated.FinishedAt | |||
| break // 取第一个终止的容器时间(若有多个容器,可根据需求调整) | |||
| } | |||
| } | |||
| if endTime == nil { | |||
| fmt.Println("Pod 尚未终止,无 endTime(可能仍在运行中)") | |||
| if queryParam != "" && queryParam != "null" { | |||
| resp = getEciStatusEnum(containerResp) | |||
| } else { | |||
| resp.End = endTime.Time.Format("2006-01-02 15:04:05") | |||
| resp = getK8sStatusEnum(containerResp) | |||
| } | |||
| return &resp, nil | |||
| return resp, nil | |||
| } | |||
| func getStatusEnum(pod *v1.Pod) string { | |||
| func getK8sStatusEnum(containerDetail *collector.ContainerDetailResp) collector.Task { | |||
| var resp collector.Task | |||
| var pod v1.Pod | |||
| bytes, err := json.Marshal(containerDetail.Data) | |||
| if err != nil { | |||
| return resp | |||
| } | |||
| json.Unmarshal(bytes, &pod) | |||
| // 优先判断Pod的删除状态(是否正在删除) | |||
| if !pod.DeletionTimestamp.IsZero() { | |||
| // 已标记删除但未完全删除 → WaitDelete;已删除(若能查询到则表示未完全删除) | |||
| return constants.WaitDelete | |||
| resp.Status = constants.WaitDelete | |||
| } | |||
| // 根据Pod的Phase(宏观状态)判断 | |||
| @@ -95,10 +84,10 @@ func getStatusEnum(pod *v1.Pod) string { | |||
| for _, cs := range pod.Status.ContainerStatuses { | |||
| if cs.RestartCount > 0 && cs.State.Running == nil { | |||
| // 有重启记录且当前运行中 → 刚重启完,对应WaitRestart | |||
| return constants.WaitRestart | |||
| resp.Status = constants.WaitRestart | |||
| } | |||
| } | |||
| return constants.Running | |||
| resp.Status = constants.Running | |||
| case v1.PodPending: | |||
| // Pending状态:检查容器是否在等待启动 | |||
| @@ -106,27 +95,27 @@ func getStatusEnum(pod *v1.Pod) string { | |||
| if cs.State.Waiting != nil { | |||
| switch cs.State.Waiting.Reason { | |||
| case "ContainerCreating", "PodInitializing": | |||
| return constants.WaitStart // 等待启动 | |||
| resp.Status = constants.WaitStart // 等待启动 | |||
| case "Paused": | |||
| return constants.WaitPause // 等待暂停(罕见,通常对应Pause状态) | |||
| resp.Status = constants.WaitPause // 等待暂停(罕见,通常对应Pause状态) | |||
| default: | |||
| return constants.Waiting // 其他等待状态 | |||
| resp.Status = constants.Waiting // 其他等待状态 | |||
| } | |||
| } | |||
| } | |||
| return constants.Pending | |||
| resp.Status = constants.Pending | |||
| case v1.PodSucceeded: | |||
| // 所有容器成功终止 | |||
| return constants.Succeeded | |||
| resp.Status = constants.Succeeded | |||
| case v1.PodFailed: | |||
| // 至少一个容器失败终止 | |||
| return constants.Failed | |||
| resp.Status = constants.Failed | |||
| case v1.PodUnknown: | |||
| // 未知状态 → 暂归为Waiting | |||
| return constants.Waiting | |||
| resp.Status = constants.Waiting | |||
| } | |||
| // 检查容器状态(补充Phase未覆盖的情况) | |||
| @@ -134,19 +123,76 @@ func getStatusEnum(pod *v1.Pod) string { | |||
| switch { | |||
| case cs.State.Terminated != nil: | |||
| if cs.State.Terminated.Reason == "Completed" { | |||
| return constants.Completed // 容器正常完成 | |||
| resp.Status = constants.Completed // 容器正常完成 | |||
| } | |||
| if cs.State.Terminated.Reason == "Error" { | |||
| return constants.Failed // 错误终止 | |||
| resp.Status = constants.Failed // 错误终止 | |||
| } | |||
| if cs.State.Terminated.Reason == "Cancelled" { | |||
| return constants.Cancelled // 被取消 | |||
| resp.Status = constants.Cancelled // 被取消 | |||
| } | |||
| case cs.State.Waiting != nil && cs.State.Waiting.Reason == "Paused": | |||
| return constants.WaitPause // 容器被暂停 | |||
| resp.Status = constants.WaitPause // 容器被暂停 | |||
| } | |||
| } | |||
| // 提取 StartTime(Pod 启动时间) | |||
| startTime := pod.Status.StartTime | |||
| if startTime == nil { | |||
| fmt.Println("Pod 尚未启动,无 startTime") | |||
| } else { | |||
| resp.Start = startTime.Time.Format("2006-01-02 15:04:05") | |||
| } | |||
| // 提取 EndTime(容器终止时间,仅当 Pod 已结束时存在) | |||
| // 遍历所有容器状态,查找已终止的容器 | |||
| var endTime *v2.Time | |||
| for _, containerStatus := range pod.Status.ContainerStatuses { | |||
| if containerStatus.State.Terminated != nil { | |||
| endTime = &containerStatus.State.Terminated.FinishedAt | |||
| break // 取第一个终止的容器时间(若有多个容器,可根据需求调整) | |||
| } | |||
| } | |||
| // 其他未覆盖状态(如部署中、已保存等) | |||
| return constants.Deploying | |||
| if endTime == nil { | |||
| fmt.Println("Pod 尚未终止,无 endTime(可能仍在运行中)") | |||
| } else { | |||
| resp.End = endTime.Time.Format("2006-01-02 15:04:05") | |||
| } | |||
| return resp | |||
| } | |||
| func getEciStatusEnum(containerDetail *collector.ContainerDetailResp) collector.Task { | |||
| var resp collector.Task | |||
| var eciResp eci.DescribeContainerGroupsResponse | |||
| bytes, err := json.Marshal(containerDetail.Data) | |||
| if err != nil { | |||
| return resp | |||
| } | |||
| json.Unmarshal(bytes, &eciResp) | |||
| if len(eciResp.ContainerGroups) == 0 { | |||
| return resp | |||
| } | |||
| switch eciResp.ContainerGroups[0].Status { | |||
| case "Pending": | |||
| resp.Status = constants.Pending | |||
| case "Creating": | |||
| resp.Status = constants.WaitStart | |||
| case "Running": | |||
| resp.Status = constants.Running | |||
| case "Stopping": | |||
| resp.Status = constants.Stopped | |||
| case "Stopped": | |||
| resp.Status = constants.Stopped | |||
| case "Failed": | |||
| resp.Status = constants.Failed | |||
| case "Deleting": | |||
| resp.Status = constants.Deleted | |||
| case "Succeeded": | |||
| resp.Status = constants.Succeeded | |||
| case "Unknown": | |||
| resp.Status = constants.Failed | |||
| } | |||
| resp.Start = eciResp.ContainerGroups[0].CreationTime | |||
| resp.End = eciResp.ContainerGroups[0].SucceededTime | |||
| return resp | |||
| } | |||
| @@ -2,20 +2,15 @@ package collector | |||
| import ( | |||
| "context" | |||
| v1 "k8s.io/api/core/v1" | |||
| ) | |||
| type CloudCollector interface { | |||
| GetContainer(ctx context.Context, name string, clusterId string) (*Task, error) | |||
| } | |||
| type ContainerInfo struct { | |||
| Pod *v1.Pod | |||
| GetContainer(ctx context.Context, name string, businessCode string, clusterId string) (Task, error) | |||
| } | |||
| type ContainerDetailResp struct { | |||
| Code int `json:"code"` | |||
| Msg string `json:"msg"` | |||
| Data *v1.Pod `json:"data"` | |||
| TraceId string `json:"trace_id"` | |||
| Code int `json:"code"` | |||
| Msg string `json:"msg"` | |||
| Data interface{} `json:"data"` | |||
| TraceId string `json:"trace_id"` | |||
| } | |||
| @@ -89,24 +89,27 @@ func UpdateCloudTaskStatus(svc *svc.ServiceContext) { | |||
| } | |||
| // 4. 从 CLOUD 集群获取最新状态 | |||
| cloudTaskInfo, err := adapter.GetContainer(ctx, cloud.Name, utils.Int64ToString(cloud.ClusterId)) | |||
| cloudTaskInfo, err := adapter.GetContainer(ctx, cloud.Name, cloud.BusinessCode, utils.Int64ToString(cloud.ClusterId)) | |||
| if err != nil { | |||
| logx.Errorf("Failed to get task status from CLOUD executor for job %s: %v", cloud.Name, err) | |||
| continue // 继续处理下一个任务 | |||
| } | |||
| if cloudTaskInfo.Status == "" { | |||
| continue | |||
| } | |||
| // 如果状态没有变化,则跳过 | |||
| if cloud.Status == cloudTaskInfo.Status { | |||
| continue | |||
| } | |||
| // 5. 准备更新 | |||
| startTime := convertUTCTimeToCST(cloudTaskInfo.Start) | |||
| previousStatus := cloud.Status | |||
| cloud.Status = cloudTaskInfo.Status | |||
| cloud.StartTime = cloudTaskInfo.Start | |||
| cloud.StartTime = startTime | |||
| task.Status = cloudTaskInfo.Status | |||
| task.StartTime = cloudTaskInfo.Start | |||
| task.StartTime = startTime | |||
| task.EndTime = cloudTaskInfo.End | |||
| logx.Infof("CLOUD task status change detected for job %s: %s -> %s", cloud.Name, previousStatus, cloud.Status) | |||
| @@ -178,3 +181,44 @@ func handleNoticeChange(svc *svc.ServiceContext, task *types.TaskModel, cloud *m | |||
| } | |||
| } | |||
| } | |||
| func convertUTCTimeToCST(utcTimeStr string) string { | |||
| if utcTimeStr == "" { | |||
| return "" | |||
| } | |||
| // 定义多种可能的时间格式 | |||
| timeFormats := []string{ | |||
| "2006-01-02T15:04:05Z", // ISO 8601 格式 | |||
| "2006-01-02 15:04:05", // 常见格式 | |||
| "2006-01-02T15:04:05", // ISO 无时区 | |||
| "2006-01-02 15:04:05Z", // 带Z的常见格式 | |||
| time.RFC3339, // RFC3339 标准格式 | |||
| "2006-01-02T15:04:05.000Z", // 带毫秒的ISO格式 | |||
| } | |||
| var utcTime time.Time | |||
| var err error | |||
| // 尝试解析多种格式 | |||
| for _, format := range timeFormats { | |||
| utcTime, err = time.Parse(format, utcTimeStr) | |||
| if err == nil { | |||
| break | |||
| } | |||
| } | |||
| // 如果所有格式都失败,记录警告并返回原字符串 | |||
| if err != nil { | |||
| logx.Errorf("Failed to parse time string '%s' with all known formats, returning original string", utcTimeStr) | |||
| return utcTimeStr | |||
| } | |||
| // 创建东八区时区 | |||
| cstZone := time.FixedZone("CST", 8*3600) | |||
| // 将UTC时间转换为东八区时间 | |||
| cstTime := utcTime.In(cstZone) | |||
| // 格式化东八区时间 | |||
| return cstTime.Format("2006-01-02T15:04:05-07:00") | |||
| } | |||
| @@ -9,6 +9,9 @@ type ContainerGetParameter interface { | |||
| type ContainerDeleteParameter interface { | |||
| ContainerDeleteParam() | |||
| } | |||
| type ContainerLogParameter interface { | |||
| ContainerLogParam() | |||
| } | |||
| type CreateParam struct { | |||
| ClusterId string `json:"clusterId,omitempty"` | |||
| ContainerGroupName string `json:"containerGroupName"` | |||
| @@ -47,9 +50,10 @@ func (e EciCreateParam) ContainerCreateParam() { | |||
| // 删除容器参数 | |||
| type DeleteParam struct { | |||
| ClusterId string `json:"clusterId,omitempty"` | |||
| Name string `json:"name,omitempty"` | |||
| ContainerDeleteParameter ContainerDeleteParameter `json:"containerDeleteParameter,omitempty"` | |||
| Id string `json:"id"` | |||
| ClusterId string `json:"clusterId,omitempty"` | |||
| Name string `json:"name,optional"` | |||
| DeleteParameter interface{} `json:"deleteParameter,omitempty"` | |||
| } | |||
| func (k K8sDeleteParam) ContainerDeleteParameter() { | |||
| @@ -86,6 +90,20 @@ type EciGetParam struct { | |||
| ContainerGroupName string `json:"containerGroupName,omitempty"` | |||
| } | |||
| type LogParam struct { | |||
| ClusterId string `json:"clusterId,omitempty"` | |||
| Name string `json:"name,omitempty"` | |||
| ClusterId string `json:"clusterId"` | |||
| Name string `json:"name,omitempty"` | |||
| ContainerLogParameter interface{} `json:"containerLogParameter,omitempty"` | |||
| } | |||
| func (k K8sLogParam) ContainerLogParam() { | |||
| } | |||
| func (e EciLogParam) ContainerLogParam() { | |||
| } | |||
| type K8sLogParam struct { | |||
| } | |||
| type EciLogParam struct { | |||
| ContainerGroupId string `json:"containerGroupId,omitempty"` | |||
| } | |||
| @@ -25,6 +25,7 @@ type TaskCloudModel struct { | |||
| Result string `json:"result" gorm:"comment:运行结果"` | |||
| Namespace string `json:"namespace" gorm:"comment:命名空间"` | |||
| UserId int64 `json:"userId" gorm:"comment:用户id"` | |||
| BusinessCode string `json:"businessCode" gorm:"comment:业务码"` | |||
| ResourceSpec ResourceSpec `json:"resourceSpec" gorm:"serializer:json"` | |||
| base.BaseModel | |||
| } | |||
| @@ -54,6 +54,7 @@ type ( | |||
| Result string `db:"result"` // 运行结果 | |||
| NsID string `db:"ns_id"` | |||
| Replica int32 `db:"replica"` | |||
| BusinessCode string `db:"business_code"` | |||
| } | |||
| ) | |||