utils change

This commit is contained in:
zhouqunjie 2023-11-08 15:37:26 +08:00
parent f74106c47d
commit afbfade87d
57 changed files with 643 additions and 64 deletions

19
go.mod
View File

@ -3,22 +3,28 @@ module gitlink.org.cn/jcce-pcm/pcm-slurm
go 1.19
require (
github.com/bwmarrin/snowflake v0.3.0
github.com/go-resty/resty/v2 v2.7.0
github.com/jinzhu/copier v0.3.5
github.com/nacos-group/nacos-sdk-go/v2 v2.2.3
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.17.0
github.com/prometheus/common v0.44.0
github.com/robfig/cron/v3 v3.0.1
github.com/zeromicro/go-zero v1.6.0
gitlink.org.cn/jcce-pcm/pcm-coordinator v0.1.9
gitlink.org.cn/jcce-pcm/utils v0.0.2
gitlink.org.cn/jcce-pcm/pcm-coordinator v0.1.11
golang.org/x/crypto v0.14.0
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
sigs.k8s.io/yaml v1.3.0
)
require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bwmarrin/snowflake v0.3.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
@ -33,7 +39,6 @@ require (
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/mock v1.6.0 // indirect
@ -43,7 +48,6 @@ require (
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
github.com/jinzhu/copier v0.3.5 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
@ -57,10 +61,8 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nacos-group/nacos-sdk-go/v2 v2.2.3 // indirect
github.com/openzipkin/zipkin-go v0.4.2 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
@ -98,12 +100,9 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/gorm v1.25.3 // indirect
k8s.io/api v0.28.3 // indirect
k8s.io/apimachinery v0.28.3 // indirect
k8s.io/client-go v0.28.3 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

6
go.sum
View File

@ -162,10 +162,8 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t
github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE=
github.com/zeromicro/go-zero v1.6.0 h1:UwSOR1lGZ2g7L0S07PM8RoneAcubtd5x//EfbuNucQ0=
github.com/zeromicro/go-zero v1.6.0/go.mod h1:E9GCFPb0SwsTKFBcFr9UynGvXiDMmfc6fI5F15vqvAQ=
gitlink.org.cn/jcce-pcm/pcm-coordinator v0.1.9 h1:BMlZgSUnbYKcVIKEX4hBXb8rjnNfElQxBXZsCcF3ABU=
gitlink.org.cn/jcce-pcm/pcm-coordinator v0.1.9/go.mod h1:5KV9tMTNyHhh5nPT4mCA/Zt6VUL21hFrhPovs1hDmRs=
gitlink.org.cn/jcce-pcm/utils v0.0.2 h1:Stif8W9C9TOCS2hw4g+OlOywDrsVYNrkiyKfBrWkT0w=
gitlink.org.cn/jcce-pcm/utils v0.0.2/go.mod h1:u8PTlBpzUyOlbQJgfSiutq91q/JtrJIQiPNDe4S/pGs=
gitlink.org.cn/jcce-pcm/pcm-coordinator v0.1.11 h1:sYjPHjgDfwy6gdDlYCbM/6vfW9VWuRpXDxH0qoqvdos=
gitlink.org.cn/jcce-pcm/pcm-coordinator v0.1.11/go.mod h1:5KV9tMTNyHhh5nPT4mCA/Zt6VUL21hFrhPovs1hDmRs=
go.etcd.io/etcd/api/v3 v3.5.10 h1:szRajuUUbLyppkhs9K6BRtjY37l66XQQmw7oZRANE4k=
go.etcd.io/etcd/api/v3 v3.5.10/go.mod h1:TidfmT4Uycad3NM/o25fG3J07odo4GBB9hoxaodFCtI=
go.etcd.io/etcd/client/pkg/v3 v3.5.10 h1:kfYIdQftBnbAq8pUWFXfpuuxFSKzlmM5cSn76JByiT0=

View File

@ -3,7 +3,7 @@ package logic
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"
)

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,8 +2,8 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
gossh "golang.org/x/crypto/ssh"
"strings"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -2,7 +2,7 @@ package logic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"

View File

@ -3,8 +3,8 @@ package cron
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/participantservice"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils"
)
func ReportHeartbeat(participantRpc participantservice.ParticipantService) {

View File

@ -3,10 +3,9 @@ package cron
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/constants"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/pcmCore"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/logic"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"
)
@ -37,7 +36,7 @@ func SyncTask(svc *svc.ServiceContext) {
if len(infoList.HpcInfoList) != 0 {
for index := range infoList.HpcInfoList {
if infoList.HpcInfoList[index].Status == constants.Saved {
if infoList.HpcInfoList[index].Status == "Saved" {
subReq := slurm.SubmitJobReq{
Script: infoList.HpcInfoList[index].CmdScript,
Job: &slurm.JobProperties{
@ -55,10 +54,10 @@ func SyncTask(svc *svc.ServiceContext) {
jobResult, err := submitJobLogic.SubmitJob(&subReq)
if len(jobResult.Errors) == 0 {
infoList.HpcInfoList[index].Status = "Pending"
infoList.HpcInfoList[index].Status = svc.Config.SlurmStatus["PENDING"]
infoList.HpcInfoList[index].JobId = jobResult.JobSubmitUserMsg
} else {
infoList.HpcInfoList[index].Status = "Failed"
infoList.HpcInfoList[index].Status = svc.Config.SlurmStatus["FAILED"]
infoList.HpcInfoList[index].Result = jobResult.JobSubmitUserMsg
}
// 同步信息到core端

View File

@ -7,9 +7,9 @@ import (
v1 "github.com/prometheus/client_golang/api/prometheus/v1"
proModel "github.com/prometheus/common/model"
model "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/participantservice"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/logic"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"time"
)

View File

@ -0,0 +1,103 @@
package utils
import (
"encoding/json"
"fmt"
"github.com/robfig/cron/v3"
"io"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"mime/multipart"
"sigs.k8s.io/yaml"
"strconv"
"strings"
)
// Convert 通过JSON赋值
func Convert(source interface{}, target interface{}) {
jsonByte, _ := json.Marshal(source)
json.Unmarshal(jsonByte, &target)
}
// Int64ToString int64转string
func Int64ToString(value int64) string {
return strconv.FormatInt(value, 10)
}
// EntryIdToString EntryID转string
func EntryIdToString(id cron.EntryID) string {
return strconv.Itoa(int(id))
}
func StringToInt(value string) int {
intValue, _ := strconv.Atoi(value)
return intValue
}
func StringToInt64(value string) int64 {
intValue, _ := strconv.ParseInt(value, 10, 64)
return intValue
}
func StringToFloat64(value string) float64 {
floatValue, _ := strconv.ParseFloat(value, 64)
return floatValue
}
func RunTimeToSeconds(runTime string) int {
time := strings.Split(runTime, ":")
day, _ := strconv.Atoi(time[0])
hour, _ := strconv.Atoi(time[1])
seconds, _ := strconv.Atoi(time[2])
return day*3600 + hour*60 + seconds
}
func Yaml2struct(fileHeader *multipart.FileHeader, req interface{}) error {
file, err := fileHeader.Open()
if err != nil {
return err
}
fileByte, err := io.ReadAll(file)
if err != nil {
return err
}
err = yaml.Unmarshal(fileByte, &req)
if err != nil {
return err
}
return nil
}
func K8sUnstructured(dataString string, target interface{}) {
unstructuredList := unstructured.UnstructuredList{}
json.Unmarshal([]byte(dataString), &unstructuredList)
runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredList.UnstructuredContent(), target)
}
// removeDuplication_map 去重数组
func RemoveDuplication_map(arr []string) []string {
set := make(map[string]struct{}, len(arr))
j := 0
for _, v := range arr {
_, ok := set[v]
if ok {
continue
}
set[v] = struct{}{}
arr[j] = v
j++
}
return arr[:j]
}
func ConvertStructToMap(in interface{}) map[string]string {
out := make(map[string]string)
b, _ := json.Marshal(&in)
var m map[string]interface{}
_ = json.Unmarshal(b, &m)
for k, v := range m {
out[k] = fmt.Sprintf("%v", v)
}
return out
}

View File

@ -0,0 +1,50 @@
package utils
import (
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"strconv"
"time"
)
var Converters = []copier.TypeConverter{
{
SrcType: time.Time{},
DstType: copier.String,
Fn: func(src interface{}) (interface{}, error) {
s, ok := src.(time.Time)
if !ok {
return nil, errors.New("src type not matching")
}
return s.Format(time.RFC3339), nil
},
},
{
SrcType: copier.String,
DstType: copier.Int,
Fn: func(src interface{}) (interface{}, error) {
s, ok := src.(string)
if !ok {
return nil, errors.New("src type not matching")
}
return strconv.Atoi(s)
},
},
{
SrcType: copier.String,
DstType: copier.Bool,
Fn: func(src interface{}) (interface{}, error) {
s, ok := src.(string)
if !ok {
return nil, errors.New("src type not matching")
}
return strconv.ParseBool(s)
},
},
}

View File

@ -0,0 +1,11 @@
package utils
import (
"fmt"
"strconv"
)
func FloatConv(num float64) float64 {
num, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", num), 64)
return num
}

View File

@ -0,0 +1,30 @@
package fileutils
import (
"os"
"path/filepath"
)
// DirSize 获取整体文件夹大小
func GetDirSize(path string) (int64, error) {
var size int64
err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
if !info.IsDir() {
size += info.Size()
}
return err
})
return size, err
}
// PathExists 判断文件夹是否存在
func PathExists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}

View File

@ -0,0 +1,205 @@
package httputils
import (
"bytes"
"crypto/tls"
"encoding/json"
"github.com/go-resty/resty/v2"
"io"
"io/ioutil"
"log"
"net/http"
"reflect"
"strconv"
"time"
)
const (
GET = "GET"
PUT = "PUT"
POST = "POST"
DELETE = "DELETE"
)
const (
ContentType = "Content-Type"
ApplicationJson = "application/json"
ApplicationFromUrlencoded = "application/x-www-from-urlencoded"
)
var httpClient *resty.Client = nil
var httpsClient *resty.Client = nil
func NewHttpsClient() *resty.Client {
if httpsClient != nil {
return httpsClient
}
c := resty.New()
c.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
c.SetTimeout(5 * time.Second)
c.SetRetryCount(3)
//debug := nacos.GetConfig("httpclient.debug")
debug := "true"
if len(debug) > 0 && debug == "ON" {
c.SetDebug(true)
}
httpsClient = c
return c
}
func GetHttpRequest() *resty.Request {
client := resty.New()
request := client.R()
return request
}
func HttpClient(method string, url string, payload io.Reader, token string) ([]byte, error) {
request, err := http.NewRequest(method, url, payload)
request.Header.Add("Content-Type", "application/json")
request.Header.Add("User-Agent", "API Explorer")
request.Header.Add("x-auth-token", token)
client := &http.Client{}
res, err := client.Do(request)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}
return body, err
}
func HttpGet(method string, url string) ([]byte, error) {
request, err := http.NewRequest(method, url, nil)
client := &http.Client{}
res, err := client.Do(request)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}
return body, err
}
// 发送POST请求
// url:请求地址data:POST请求提交的数据,contentType:请求体格式application/json
// content:请求放回的内容
func HttpPost(url string, data interface{}) (content string, err error) {
jsonStr, _ := json.Marshal(data)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
req.Header.Add("content-type", "application/json")
if err != nil {
return
}
defer req.Body.Close()
client := &http.Client{Timeout: 5 * time.Second}
resp, err := client.Do(req)
if err != nil {
return
}
defer resp.Body.Close()
result, _ := ioutil.ReadAll(resp.Body)
content = string(result)
return
}
func HttpClientStatusCode(method string, url string, payload io.Reader, token string) (int, error) {
request, err := http.NewRequest(method, url, payload)
request.Header.Add("Content-Type", "application/json")
request.Header.Add("User-Agent", "API Explorer")
request.Header.Add("x-auth-token", token)
client := &http.Client{}
res, err := client.Do(request)
if err != nil {
log.Fatal(err)
}
return res.StatusCode, err
}
func HttpClientWithQueries[T any](method string, url string, payload io.Reader, token string, param T) ([]byte, error) {
request, err := http.NewRequest(method, url, payload)
request.Header.Add("Content-Type", "application/json")
request.Header.Add("User-Agent", "API Explorer")
request.Header.Add("x-auth-token", token)
convertStructToQueryUrl(request, param)
client := &http.Client{}
res, err := client.Do(request)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}
return body, err
}
func convertStructToQueryUrl[T any](request *http.Request, param T) {
query := request.URL.Query()
values := reflect.ValueOf(param)
types := values.Type()
for i := 0; i < values.NumField(); i++ {
if !values.Field(i).IsZero() {
if values.Field(i).CanInt() {
query.Add(types.Field(i).Name, strconv.FormatInt(values.Field(i).Int(), 10))
} else if values.Field(i).Kind() == reflect.Bool {
query.Add(types.Field(i).Name, strconv.FormatBool(values.Field(i).Bool()))
} else {
query.Add(types.Field(i).Name, values.Field(i).String())
}
}
}
request.URL.RawQuery = query.Encode()
}
func HttpClientWithBodyAndCode(method string, url string, payload io.Reader, token string) (int, []byte, error) {
request, err := http.NewRequest(method, url, payload)
request.Header.Add("Content-Type", "application/json")
request.Header.Add("User-Agent", "API Explorer")
request.Header.Add("x-auth-token", token)
client := &http.Client{}
res, err := client.Do(request)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
return res.StatusCode, body, err
}
func HttpClientWithScreen(method string, url string, payload io.Reader) (int, []byte, error) {
request, err := http.NewRequest(method, url, payload)
client := &http.Client{}
res, err := client.Do(request)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
return res.StatusCode, body, err
}

View File

@ -0,0 +1,80 @@
package utils
import (
"bufio"
"fmt"
"io"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/restmapper"
"os"
"sigs.k8s.io/yaml"
"strings"
)
type PConfig struct {
ParticipantId int64
}
// GetGVR 获取GVR
func GetGVR(clientSet *kubernetes.Clientset, gvk schema.GroupVersionKind) (schema.GroupVersionResource, error) {
gr, err := restmapper.GetAPIGroupResources(clientSet)
if err != nil {
return schema.GroupVersionResource{}, err
}
mapper := restmapper.NewDiscoveryRESTMapper(gr)
mapping, err := mapper.RESTMapping(gvk.GroupKind(), gvk.Version)
if err != nil {
return schema.GroupVersionResource{}, err
}
return mapping.Resource, nil
}
// UpdateParticipantId 更新本地配置文件ParticipantId
func UpdateParticipantId(filePath string, value string) error {
file, err := os.OpenFile(filePath, os.O_RDWR, 0)
if err != nil {
return err
}
reader := bufio.NewReader(file)
pos := int64(0)
for {
//读取每一行内容
line, err := reader.ReadString('\n')
if err != nil && err != io.EOF {
fmt.Println("Read file error!", err)
return err
}
//根据关键词覆盖当前行
if strings.Contains(line, "ParticipantId") {
bytes := []byte("ParticipantId: " + value)
file.WriteAt(bytes, pos)
}
//每一行读取完后记录位置
pos += int64(len(line))
//读到末尾
if err != nil && err == io.EOF {
fmt.Println("File read ok!")
break
}
}
return nil
}
// GetParticipantId 获取本地配置文件中的ParticipantId
func GetParticipantId(filePath string) (int64, error) {
pConfig := PConfig{}
file, err := os.OpenFile(filePath, os.O_RDONLY, 0)
if err != nil {
return 0, err
}
bytes, err := io.ReadAll(file)
if err != nil {
return 0, err
}
yaml.Unmarshal(bytes, &pConfig)
return pConfig.ParticipantId, nil
}

View File

@ -0,0 +1,24 @@
package utils
import (
"github.com/bwmarrin/snowflake"
"github.com/nacos-group/nacos-sdk-go/v2/common/logger"
)
var node *snowflake.Node
func InitSnowflake(machineID int64) (err error) {
node, err = snowflake.NewNode(machineID)
if err != nil {
logger.Errorf("snowflake Init error : s%", err)
return
}
return
}
// GenSnowflakeID 生成雪花算法id
// machineId 工作id
func GenSnowflakeID() int64 {
return node.Generate().Int64()
}

View File

@ -0,0 +1,17 @@
package utils
import (
"math/rand"
"strings"
)
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
func RandomString(n int) string {
sb := strings.Builder{}
sb.Grow(n)
for i := 0; i < n; i++ {
sb.WriteByte(charset[rand.Intn(len(charset))])
}
return sb.String()
}

View File

@ -0,0 +1,63 @@
package timeutils
import (
"time"
)
var timeTemplates = []string{
"2006-01-02 15:04:05", //常规类型
"2006/01/02 15:04:05",
"2006-01-02",
"2006/01/02",
"15:04:05",
}
func GetTimeDurationString(startTime string, endTime string) string {
end, _ := time.Parse("2006-01-02 15:04:05", endTime)
start, _ := time.Parse("2006-01-02 15:04:05", startTime)
difference := end.Sub(start)
return difference.Truncate(time.Second).String()
}
func DurationToDateTime(timeData uint64) time.Time {
timeString := time.Unix(int64(timeData), 0).Format("2006-01-02 15:04:05")
return TimeStringToGoTime(timeString)
}
// TimeStringToGoTime 时间格式字符串转换
func TimeStringToGoTime(tm string) time.Time {
for i := range timeTemplates {
t, err := time.ParseInLocation(timeTemplates[i], tm, time.Local)
if nil == err && !t.IsZero() {
return t
}
}
return time.Time{}
}
func TimeStringRemoveZone(tm string) string {
timeZone, _ := time.Parse("2006-01-02 15:04:05 -0700 MST", tm)
return timeZone.Format("2006-01-02 15:04:05")
}
func TimeRemoveZone(tm time.Time) time.Time {
parse, err := time.Parse("2006-01-02 15:04:05", tm.Format("2006-01-02 15:04:05"))
if err != nil {
return time.Time{}
}
return parse
}
func StringToUnixTime(str string) int64 {
dt, err := time.ParseInLocation("2006-01-02 15:04:05", str, time.Local)
if err != nil {
return 0
}
return dt.Unix()
}
func UnixTimeToString(ut int64) string {
t := time.Unix(ut, 0)
return t.Format("2006-01-02 15:04:05")
}

View File

@ -7,11 +7,11 @@ import (
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/service"
"github.com/zeromicro/go-zero/zrpc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/participantservice"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/pcmCore"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/config"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/cron"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/server"
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"