提交 88e32380 编写于 作者: L liqingping

style: lint error

上级 5d44d1e8
...@@ -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(config, ctx := handler.NewContext(context.Background(),
context.Background(), config,
mgr.GetClient(), mgr.GetClient(),
mgr.GetEventRecorderFor("di-operator"), mgr.GetEventRecorderFor("di-operator"),
ctrl.Log.WithName("di-operator")) ctrl.Log.WithName("di-operator"))
......
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() {
}) // })
此差异已折叠。
...@@ -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
} }
package gpu_allocator package gpuallocator
import ( import (
"fmt" "fmt"
......
package gpu_allocator package gpuallocator
import ( import (
"testing" "testing"
......
...@@ -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(cfg, ctx := handler.NewContext(context.Background(),
context.Background(), cfg,
k8sManager.GetClient(), k8sManager.GetClient(),
k8sManager.GetEventRecorderFor("di-operator"), k8sManager.GetEventRecorderFor("di-operator"),
ctrl.Log.WithName("di-operator")) ctrl.Log.WithName("di-operator"))
......
...@@ -17,7 +17,7 @@ type Context struct { ...@@ -17,7 +17,7 @@ type Context struct {
Recorder record.EventRecorder Recorder record.EventRecorder
} }
func NewContext(config *rest.Config, ctx context.Context, client client.Client, recorder record.EventRecorder, logger logr.Logger) *Context { func NewContext(ctx 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,
......
...@@ -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
} }
......
...@@ -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++ {
......
...@@ -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.
先完成此消息的编辑!
想要评论请 注册