Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDILab开源决策智能平台
DI-orchestrator
提交
88e32380
D
DI-orchestrator
项目概览
OpenDILab开源决策智能平台
/
DI-orchestrator
上一次同步 2 年多
通知
1
Star
78
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DI-orchestrator
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
88e32380
编写于
1月 07, 2022
作者:
L
liqingping
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
style: lint error
上级
5d44d1e8
变更
11
展开全部
显示空白变更内容
内联
并排
Showing
11 changed file
with
400 addition
and
407 deletion
+400
-407
cmd/operator/operator.go
cmd/operator/operator.go
+2
-2
e2e/e2e_suite_test.go
e2e/e2e_suite_test.go
+84
-84
e2e/e2e_test.go
e2e/e2e_test.go
+295
-295
pkg/common/config.go
pkg/common/config.go
+1
-2
pkg/common/gpuallocator/gpu_allocator.go
pkg/common/gpuallocator/gpu_allocator.go
+1
-1
pkg/common/gpuallocator/gpu_allocator_test.go
pkg/common/gpuallocator/gpu_allocator_test.go
+1
-1
pkg/controllers/suite_test.go
pkg/controllers/suite_test.go
+5
-6
pkg/handler/context.go
pkg/handler/context.go
+1
-1
pkg/handler/status.go
pkg/handler/status.go
+8
-8
pkg/server/http/dijob.go
pkg/server/http/dijob.go
+0
-4
pkg/server/http/server.go
pkg/server/http/server.go
+2
-3
未找到文件。
cmd/operator/operator.go
浏览文件 @
88e32380
...
@@ -101,8 +101,8 @@ func runCommand(cmd *cobra.Command, options *CreateOptions) error {
...
@@ -101,8 +101,8 @@ func runCommand(cmd *cobra.Command, options *CreateOptions) error {
return
err
return
err
}
}
ctx
:=
handler
.
NewContext
(
con
fig
,
ctx
:=
handler
.
NewContext
(
con
text
.
Background
()
,
con
text
.
Background
()
,
con
fig
,
mgr
.
GetClient
(),
mgr
.
GetClient
(),
mgr
.
GetEventRecorderFor
(
"di-operator"
),
mgr
.
GetEventRecorderFor
(
"di-operator"
),
ctrl
.
Log
.
WithName
(
"di-operator"
))
ctrl
.
Log
.
WithName
(
"di-operator"
))
...
...
e2e/e2e_suite_test.go
浏览文件 @
88e32380
package
e2e
package
e2e
import
(
//
import (
"context"
//
"context"
"flag"
//
"flag"
"os"
//
"os"
"path/filepath"
//
"path/filepath"
"testing"
//
"testing"
.
"github.com/onsi/ginkgo"
//
. "github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
//
. "github.com/onsi/gomega"
"k8s.io/client-go/kubernetes"
//
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
//
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/clientcmd"
//
"k8s.io/client-go/tools/clientcmd"
"sigs.k8s.io/controller-runtime/pkg/client"
//
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
//
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
div1alpha2
"opendilab.org/di-orchestrator/pkg/api/v1alpha2"
//
div1alpha2 "opendilab.org/di-orchestrator/pkg/api/v1alpha2"
)
//
)
func
TestE2E
(
t
*
testing
.
T
)
{
//
func TestE2E(t *testing.T) {
RegisterFailHandler
(
Fail
)
//
RegisterFailHandler(Fail)
RunSpecsWithDefaultAndCustomReporters
(
t
,
//
RunSpecsWithDefaultAndCustomReporters(t,
"E2E Suite"
,
//
"E2E Suite",
[]
Reporter
{
printer
.
NewlineReporter
{}})
//
[]Reporter{printer.NewlineReporter{}})
}
//
}
var
(
//
var (
k8sClient
client
.
Client
//
k8sClient client.Client
clientset
*
kubernetes
.
Clientset
//
clientset *kubernetes.Clientset
kubeconfig
string
//
kubeconfig string
exampleJobsDir
string
//
exampleJobsDir string
sharedVolumesDir
string
//
sharedVolumesDir string
)
//
)
func
init
()
{
//
func init() {
testing
.
Init
()
//
testing.Init()
if
flag
.
Lookup
(
"kubeconfig"
)
==
nil
{
//
if flag.Lookup("kubeconfig") == nil {
flag
.
StringVar
(
&
kubeconfig
,
"kubeconfig"
,
""
,
"kubeconfig file path"
)
//
flag.StringVar(&kubeconfig, "kubeconfig", "", "kubeconfig file path")
}
//
}
flag
.
StringVar
(
&
sharedVolumesDir
,
"shared-volumes-dir"
,
"/data/nfs/ding/"
,
"dir to shared volumes"
)
//
flag.StringVar(&sharedVolumesDir, "shared-volumes-dir", "/data/nfs/ding/", "dir to shared volumes")
flag
.
StringVar
(
&
exampleJobsDir
,
"example-jobs-dir"
,
"./config"
,
"dir to the example jobs"
)
//
flag.StringVar(&exampleJobsDir, "example-jobs-dir", "./config", "dir to the example jobs")
flag
.
Parse
()
//
flag.Parse()
kubeconfig
=
flag
.
Lookup
(
"kubeconfig"
)
.
Value
.
String
()
//
kubeconfig = flag.Lookup("kubeconfig").Value.String()
if
kubeconfig
==
""
{
//
if kubeconfig == "" {
kubeconfig
=
os
.
Getenv
(
"KUBECONFIG"
)
//
kubeconfig = os.Getenv("KUBECONFIG")
if
kubeconfig
==
""
{
//
if kubeconfig == "" {
kubeconfig
=
filepath
.
Join
(
homeDir
(),
".kube"
,
"config"
)
//
kubeconfig = filepath.Join(homeDir(), ".kube", "config")
}
//
}
}
//
}
}
//
}
func
homeDir
()
string
{
//
func homeDir() string {
if
h
:=
os
.
Getenv
(
"HOME"
);
h
!=
""
{
//
if h := os.Getenv("HOME"); h != "" {
return
h
//
return h
}
//
}
return
os
.
Getenv
(
"USERPROFILE"
)
// windows
//
return os.Getenv("USERPROFILE") // windows
}
//
}
var
_
=
BeforeSuite
(
func
()
{
//
var _ = BeforeSuite(func() {
// uses the current context in kubeconfig
//
// uses the current context in kubeconfig
cfg
,
err
:=
clientcmd
.
BuildConfigFromFlags
(
""
,
kubeconfig
)
//
cfg, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
//
Expect(err).NotTo(HaveOccurred())
err
=
div1alpha2
.
AddToScheme
(
scheme
.
Scheme
)
//
err = div1alpha2.AddToScheme(scheme.Scheme)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
//
Expect(err).NotTo(HaveOccurred())
//+kubebuilder:scaffold:scheme
//
//+kubebuilder:scaffold:scheme
k8sClient
,
err
=
client
.
New
(
cfg
,
client
.
Options
{
Scheme
:
scheme
.
Scheme
})
//
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
//
Expect(err).NotTo(HaveOccurred())
Expect
(
k8sClient
)
.
NotTo
(
BeNil
())
//
Expect(k8sClient).NotTo(BeNil())
clientset
,
err
=
kubernetes
.
NewForConfig
(
cfg
)
//
clientset, err = kubernetes.NewForConfig(cfg)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
//
Expect(err).NotTo(HaveOccurred())
k8sClient
.
DeleteAllOf
(
context
.
Background
(),
&
div1alpha2
.
DIJob
{},
//
k8sClient.DeleteAllOf(context.Background(), &div1alpha2.DIJob{},
client
.
InNamespace
(
namespace
),
client
.
MatchingLabels
{
"stability-test"
:
"dijobs"
})
//
client.InNamespace(namespace), client.MatchingLabels{"stability-test": "dijobs"})
})
//
})
var
_
=
AfterSuite
(
func
()
{
//
var _ = AfterSuite(func() {
})
//
})
e2e/e2e_test.go
浏览文件 @
88e32380
此差异已折叠。
点击以展开。
pkg/common/config.go
浏览文件 @
88e32380
...
@@ -41,7 +41,6 @@ func GetDIServerURL() string {
...
@@ -41,7 +41,6 @@ func GetDIServerURL() string {
url
:=
os
.
Getenv
(
ENVServerURL
)
url
:=
os
.
Getenv
(
ENVServerURL
)
if
url
==
""
{
if
url
==
""
{
return
"di-server.di-system:8080"
return
"di-server.di-system:8080"
}
else
{
return
url
}
}
return
url
}
}
pkg/common/gpuallocator/gpu_allocator.go
浏览文件 @
88e32380
package
gpu
_
allocator
package
gpuallocator
import
(
import
(
"fmt"
"fmt"
...
...
pkg/common/gpuallocator/gpu_allocator_test.go
浏览文件 @
88e32380
package
gpu
_
allocator
package
gpuallocator
import
(
import
(
"testing"
"testing"
...
...
pkg/controllers/suite_test.go
浏览文件 @
88e32380
...
@@ -21,7 +21,6 @@ import (
...
@@ -21,7 +21,6 @@ import (
"fmt"
"fmt"
"path/filepath"
"path/filepath"
"testing"
"testing"
"time"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/config"
...
@@ -43,9 +42,9 @@ import (
...
@@ -43,9 +42,9 @@ import (
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
const
(
const
(
timeout
=
5
*
time
.
Second
//
timeout = 5 * time.Second
interval
=
250
*
time
.
Millisecond
//
interval = 250 * time.Millisecond
duration
=
200
*
time
.
Millisecond
//
duration = 200 * time.Millisecond
)
)
// var cfg *rest.Config
// var cfg *rest.Config
...
@@ -91,8 +90,8 @@ var _ = BeforeSuite(func() {
...
@@ -91,8 +90,8 @@ var _ = BeforeSuite(func() {
})
})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
ctx
:=
handler
.
NewContext
(
c
fg
,
ctx
:=
handler
.
NewContext
(
c
ontext
.
Background
()
,
c
ontext
.
Background
()
,
c
fg
,
k8sManager
.
GetClient
(),
k8sManager
.
GetClient
(),
k8sManager
.
GetEventRecorderFor
(
"di-operator"
),
k8sManager
.
GetEventRecorderFor
(
"di-operator"
),
ctrl
.
Log
.
WithName
(
"di-operator"
))
ctrl
.
Log
.
WithName
(
"di-operator"
))
...
...
pkg/handler/context.go
浏览文件 @
88e32380
...
@@ -17,7 +17,7 @@ type Context struct {
...
@@ -17,7 +17,7 @@ type Context struct {
Recorder
record
.
EventRecorder
Recorder
record
.
EventRecorder
}
}
func
NewContext
(
c
onfig
*
rest
.
Config
,
ctx
context
.
Context
,
client
client
.
Client
,
recorder
record
.
EventRecorder
,
logger
logr
.
Logger
)
*
Context
{
func
NewContext
(
c
tx
context
.
Context
,
config
*
rest
.
Config
,
client
client
.
Client
,
recorder
record
.
EventRecorder
,
logger
logr
.
Logger
)
*
Context
{
return
&
Context
{
return
&
Context
{
config
:
config
,
config
:
config
,
ctx
:
ctx
,
ctx
:
ctx
,
...
...
pkg/handler/status.go
浏览文件 @
88e32380
...
@@ -182,27 +182,27 @@ func (c *Context) UpdateDIJobStatusInCluster(job *div1alpha2.DIJob) error {
...
@@ -182,27 +182,27 @@ func (c *Context) UpdateDIJobStatusInCluster(job *div1alpha2.DIJob) error {
return
err
return
err
}
}
func
(
r
*
Context
)
UpdateJobStatus
(
func
(
c
*
Context
)
UpdateJobStatus
(
job
*
div1alpha2
.
DIJob
,
phase
div1alpha2
.
Phase
,
reason
string
,
msg
string
)
{
job
*
div1alpha2
.
DIJob
,
phase
div1alpha2
.
Phase
,
reason
string
,
msg
string
)
{
updateDIJobConditions
(
job
,
phase
,
reason
,
msg
)
updateDIJobConditions
(
job
,
phase
,
reason
,
msg
)
switch
phase
{
switch
phase
{
case
div1alpha2
.
JobPending
,
div1alpha2
.
JobStarting
:
case
div1alpha2
.
JobPending
,
div1alpha2
.
JobStarting
:
r
.
Recorder
.
Eventf
(
job
,
corev1
.
EventTypeNormal
,
reason
,
msg
)
c
.
Recorder
.
Eventf
(
job
,
corev1
.
EventTypeNormal
,
reason
,
msg
)
case
div1alpha2
.
JobRunning
:
case
div1alpha2
.
JobRunning
:
if
job
.
Status
.
Phase
!=
div1alpha2
.
JobRunning
{
if
job
.
Status
.
Phase
!=
div1alpha2
.
JobRunning
{
r
.
Recorder
.
Eventf
(
job
,
corev1
.
EventTypeNormal
,
reason
,
msg
)
c
.
Recorder
.
Eventf
(
job
,
corev1
.
EventTypeNormal
,
reason
,
msg
)
}
}
case
div1alpha2
.
JobRestarting
:
case
div1alpha2
.
JobRestarting
:
job
.
Status
.
Generation
+=
1
job
.
Status
.
Generation
++
r
.
Recorder
.
Eventf
(
job
,
corev1
.
EventTypeWarning
,
reason
,
msg
)
c
.
Recorder
.
Eventf
(
job
,
corev1
.
EventTypeWarning
,
reason
,
msg
)
case
div1alpha2
.
JobFailed
:
case
div1alpha2
.
JobFailed
:
job
.
Status
.
ReadyReplicas
=
0
job
.
Status
.
ReadyReplicas
=
0
r
.
Recorder
.
Eventf
(
job
,
corev1
.
EventTypeWarning
,
reason
,
msg
)
c
.
Recorder
.
Eventf
(
job
,
corev1
.
EventTypeWarning
,
reason
,
msg
)
case
div1alpha2
.
JobSucceeded
:
case
div1alpha2
.
JobSucceeded
:
job
.
Status
.
ReadyReplicas
=
0
job
.
Status
.
ReadyReplicas
=
0
r
.
Recorder
.
Eventf
(
job
,
corev1
.
EventTypeNormal
,
reason
,
msg
)
c
.
Recorder
.
Eventf
(
job
,
corev1
.
EventTypeNormal
,
reason
,
msg
)
default
:
default
:
r
.
Recorder
.
Eventf
(
job
,
corev1
.
EventTypeNormal
,
reason
,
msg
)
c
.
Recorder
.
Eventf
(
job
,
corev1
.
EventTypeNormal
,
reason
,
msg
)
}
}
job
.
Status
.
Phase
=
phase
job
.
Status
.
Phase
=
phase
}
}
...
...
pkg/server/http/dijob.go
浏览文件 @
88e32380
...
@@ -68,10 +68,6 @@ func (s *DIServer) needMultiDDPLearnerPod(resource commontypes.ResourceQuantity)
...
@@ -68,10 +68,6 @@ func (s *DIServer) needMultiDDPLearnerPod(resource commontypes.ResourceQuantity)
return
false
,
nil
return
false
,
nil
}
}
func
needAggregator
(
resource
commontypes
.
ResourceQuantity
)
bool
{
return
resource
.
GPU
.
Value
()
>
1
}
func
(
s
*
DIServer
)
updateDIJobStatusInCluster
(
job
*
div1alpha2
.
DIJob
)
error
{
func
(
s
*
DIServer
)
updateDIJobStatusInCluster
(
job
*
div1alpha2
.
DIJob
)
error
{
var
err
error
var
err
error
for
i
:=
0
;
i
<
statusUpdateRetries
;
i
++
{
for
i
:=
0
;
i
<
statusUpdateRetries
;
i
++
{
...
...
pkg/server/http/server.go
浏览文件 @
88e32380
...
@@ -28,7 +28,6 @@ import (
...
@@ -28,7 +28,6 @@ import (
var
(
var
(
apiVersion
=
"v1alpha2"
apiVersion
=
"v1alpha2"
replicasAPI
=
"/replicas"
replicasAPI
=
"/replicas"
replicasFailedAPI
=
"/replicas/failed"
)
)
func
withAPIVersion
(
api
string
)
string
{
func
withAPIVersion
(
api
string
)
string
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录