Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDILab开源决策智能平台
DI-orchestrator
提交
51ca9ef7
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,体验更适合开发者的 AI 搜索 >>
提交
51ca9ef7
编写于
11月 29, 2021
作者:
L
liqingping
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: rename options to createOptions
上级
366d7878
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
18 addition
and
118 deletion
+18
-118
cmd/operator/operator.go
cmd/operator/operator.go
+6
-6
cmd/server/server.go
cmd/server/server.go
+6
-6
cmd/webhook/main.go
cmd/webhook/main.go
+0
-100
cmd/webhook/webhook.go
cmd/webhook/webhook.go
+6
-6
未找到文件。
cmd/operator/operator.go
浏览文件 @
51ca9ef7
...
...
@@ -31,21 +31,21 @@ import (
"opendilab.org/di-orchestrator/pkg/controllers"
)
type
Operator
Options
struct
{
type
Create
Options
struct
{
MetricAddress
string
ProbeAddress
string
EnableLeaderElection
bool
}
func
New
OperatorOptions
()
*
Operator
Options
{
return
&
Operator
Options
{
func
New
CreateOptions
()
*
Create
Options
{
return
&
Create
Options
{
MetricAddress
:
":8443"
,
ProbeAddress
:
":8080"
,
EnableLeaderElection
:
false
,
}
}
func
(
o
*
Operator
Options
)
AddFlags
(
cmd
*
cobra
.
Command
)
{
func
(
o
*
Create
Options
)
AddFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringVar
(
&
o
.
MetricAddress
,
"metric-addr"
,
o
.
MetricAddress
,
"The address the metric endpoint binds to."
)
cmd
.
Flags
()
.
StringVar
(
&
o
.
ProbeAddress
,
"probe-addr"
,
o
.
ProbeAddress
,
"The address the probe endpoint binds to."
)
cmd
.
Flags
()
.
BoolVar
(
&
o
.
EnableLeaderElection
,
"leader-elect"
,
o
.
EnableLeaderElection
,
...
...
@@ -54,7 +54,7 @@ func (o *OperatorOptions) AddFlags(cmd *cobra.Command) {
}
func
NewCmdOperator
()
*
cobra
.
Command
{
o
:=
New
Operator
Options
()
o
:=
New
Create
Options
()
var
operatorCmd
=
&
cobra
.
Command
{
Use
:
"operator"
,
Short
:
"Command to run di-operator "
,
...
...
@@ -85,7 +85,7 @@ func init() {
//+kubebuilder:scaffold:scheme
}
func
runCommand
(
cmd
*
cobra
.
Command
,
options
*
Operator
Options
)
error
{
func
runCommand
(
cmd
*
cobra
.
Command
,
options
*
Create
Options
)
error
{
ctrl
.
SetLogger
(
cmdcommon
.
Logger
)
mgr
,
err
:=
ctrl
.
NewManager
(
ctrl
.
GetConfigOrDie
(),
ctrl
.
Options
{
...
...
cmd/server/server.go
浏览文件 @
51ca9ef7
...
...
@@ -36,7 +36,7 @@ var (
DefaultAGConfigName
=
"aggregator-config"
)
type
Server
Options
struct
{
type
Create
Options
struct
{
*
cmdcommon
.
GenericFlags
ServerBindAddress
string
...
...
@@ -46,8 +46,8 @@ type ServerOptions struct {
AGCconfigName
string
}
func
New
ServerOptions
()
*
Server
Options
{
return
&
Server
Options
{
func
New
CreateOptions
()
*
Create
Options
{
return
&
Create
Options
{
GenericFlags
:
cmdcommon
.
NewGenericFlags
(),
ServerBindAddress
:
":8080"
,
GPUAllocPolicy
:
gpualloc
.
SimpleGPUAllocPolicy
,
...
...
@@ -56,7 +56,7 @@ func NewServerOptions() *ServerOptions {
}
}
func
(
o
*
Server
Options
)
AddFlags
(
cmd
*
cobra
.
Command
)
{
func
(
o
*
Create
Options
)
AddFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringVarP
(
&
o
.
ServerBindAddress
,
"server-bind-address"
,
"b"
,
o
.
ServerBindAddress
,
"The address for server to bind to."
)
cmd
.
Flags
()
.
StringVarP
(
&
o
.
GPUAllocPolicy
,
"gpu-alloc-policy"
,
"p"
,
o
.
GPUAllocPolicy
,
...
...
@@ -70,7 +70,7 @@ func (o *ServerOptions) AddFlags(cmd *cobra.Command) {
// serverCmd represents the server command
func
NewCmdServer
()
*
cobra
.
Command
{
o
:=
New
Server
Options
()
o
:=
New
Create
Options
()
var
serverCmd
=
&
cobra
.
Command
{
Use
:
"server"
,
Short
:
"Command to run di-server "
,
...
...
@@ -89,7 +89,7 @@ Examples:
return
serverCmd
}
func
runCommand
(
cmd
*
cobra
.
Command
,
options
*
Server
Options
)
error
{
func
runCommand
(
cmd
*
cobra
.
Command
,
options
*
Create
Options
)
error
{
cfg
,
err
:=
ctrl
.
GetConfig
()
if
err
!=
nil
{
return
err
...
...
cmd/webhook/main.go
已删除
100644 → 0
浏览文件 @
366d7878
/*
Copyright 2021 The OpenDILab 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
webhook
// import (
// "flag"
// "os"
// // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// // to ensure that exec-entrypoint and run can make use of them.
// _ "k8s.io/client-go/plugin/pkg/client/auth"
// "k8s.io/apimachinery/pkg/runtime"
// utilruntime "k8s.io/apimachinery/pkg/util/runtime"
// clientgoscheme "k8s.io/client-go/kubernetes/scheme"
// ctrl "sigs.k8s.io/controller-runtime"
// "sigs.k8s.io/controller-runtime/pkg/healthz"
// "sigs.k8s.io/controller-runtime/pkg/log/zap"
// div1alpha1 "opendilab.org/di-orchestrator/pkg/api/v1alpha1"
// //+kubebuilder:scaffold:imports
// )
// var (
// scheme = runtime.NewScheme()
// setupLog = ctrl.Log.WithName("setup")
// )
// func init() {
// utilruntime.Must(clientgoscheme.AddToScheme(scheme))
// utilruntime.Must(div1alpha1.AddToScheme(scheme))
// //+kubebuilder:scaffold:scheme
// }
// func main() {
// var metricsAddr, probeAddr string
// var enableLeaderElection bool
// flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
// flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
// flag.BoolVar(&enableLeaderElection, "leader-elect", false,
// "Enable leader election for controller manager. "+
// "Enabling this will ensure there is only one active controller manager.")
// opts := zap.Options{
// Development: true,
// }
// opts.BindFlags(flag.CommandLine)
// flag.Parse()
// ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
// mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
// Scheme: scheme,
// MetricsBindAddress: metricsAddr,
// Port: 9443,
// HealthProbeBindAddress: probeAddr,
// LeaderElection: enableLeaderElection,
// LeaderElectionID: "67841a5d.opendilab.org",
// })
// if err != nil {
// setupLog.Error(err, "unable to start manager")
// os.Exit(1)
// }
// if err = (&div1alpha1.DIJob{}).SetupWebhookWithManager(mgr); err != nil {
// setupLog.Error(err, "unable to create webhook", "webhook", "DIJob")
// os.Exit(1)
// }
// //+kubebuilder:scaffold:builder
// if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
// setupLog.Error(err, "unable to set up health check")
// os.Exit(1)
// }
// if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
// setupLog.Error(err, "unable to set up ready check")
// os.Exit(1)
// }
// setupLog.Info("starting manager")
// if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
// setupLog.Error(err, "problem running manager")
// os.Exit(1)
// }
// }
cmd/webhook/webhook.go
浏览文件 @
51ca9ef7
...
...
@@ -28,15 +28,15 @@ import (
div1alpha1
"opendilab.org/di-orchestrator/pkg/api/v1alpha1"
)
type
Webhook
Options
struct
{
type
Create
Options
struct
{
MetricAddress
string
ProbeAddress
string
EnableLeaderElection
bool
Port
int
}
func
New
WebhookOptions
()
*
Webhook
Options
{
return
&
Webhook
Options
{
func
New
CreateOptions
()
*
Create
Options
{
return
&
Create
Options
{
MetricAddress
:
":8443"
,
ProbeAddress
:
":8080"
,
EnableLeaderElection
:
false
,
...
...
@@ -44,7 +44,7 @@ func NewWebhookOptions() *WebhookOptions {
}
}
func
(
o
*
Webhook
Options
)
AddFlags
(
cmd
*
cobra
.
Command
)
{
func
(
o
*
Create
Options
)
AddFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringVar
(
&
o
.
MetricAddress
,
"metric-addr"
,
o
.
MetricAddress
,
"The address the metric endpoint binds to."
)
cmd
.
Flags
()
.
StringVar
(
&
o
.
ProbeAddress
,
"probe-addr"
,
o
.
ProbeAddress
,
"The address the probe endpoint binds to."
)
cmd
.
Flags
()
.
BoolVar
(
&
o
.
EnableLeaderElection
,
"leader-elect"
,
o
.
EnableLeaderElection
,
...
...
@@ -54,7 +54,7 @@ func (o *WebhookOptions) AddFlags(cmd *cobra.Command) {
}
func
NewCmdWebhook
()
*
cobra
.
Command
{
o
:=
New
Webhook
Options
()
o
:=
New
Create
Options
()
var
webhookCmd
=
&
cobra
.
Command
{
Use
:
"webhook"
,
Short
:
"Command to run di-webhook "
,
...
...
@@ -85,7 +85,7 @@ func init() {
//+kubebuilder:scaffold:scheme
}
func
runCommand
(
cmd
*
cobra
.
Command
,
options
*
Webhook
Options
)
error
{
func
runCommand
(
cmd
*
cobra
.
Command
,
options
*
Create
Options
)
error
{
ctrl
.
SetLogger
(
cmdcommon
.
Logger
)
mgr
,
err
:=
ctrl
.
NewManager
(
ctrl
.
GetConfigOrDie
(),
ctrl
.
Options
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录