Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add crds for continuous benchmark tools #1789

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions internal/k8s/benchmark/job/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Copyright (C) 2019-2022 vdaas.org vald team <vald@vdaas.org>
//
// 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
//
// https://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 job provides benchmark job crd information and preriodically update
package job
76 changes: 76 additions & 0 deletions internal/k8s/benchmark/job/job.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// Copyright (C) 2019-2022 vdaas.org vald team <vald@vdaas.org>
//
// 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
//
// https://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 job

import (
"context"

"github.com/vdaas/vald/internal/k8s"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
)

type BenchmarkJobWatcher k8s.ResourceController

type reconciler struct {
mgr manager.Manager
name string
namespace string
onError func(err error)
onReconcile func(jobList map[string][]BenchmarkJobSpec)
lopts []client.ListOption
}

func New(opts ...Option) BenchmarkJobWatcher {
r := new(reconciler)
for _, opt := range append(defaultOpts, opts...) {
// TODO: impl error handling after implement functional option
opt(r)
}
return r
}

func (r *reconciler) AddListOpts(opt client.ListOption) {}

func (r *reconciler) Reconcile(ctx context.Context, req reconcile.Request) (res reconcile.Result, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
named return "res" with type "reconcile.Result" found (nonamedreturns)

return
}

func (r *reconciler) GetName() string {
return r.name
}

func (r *reconciler) NewReconciler(ctx context.Context, mgr manager.Manager) reconcile.Reconciler {
return r
}

func (r *reconciler) For() (client.Object, []builder.ForOption) {
return nil, nil
}

func (r *reconciler) Owns() (client.Object, []builder.OwnsOption) {
return nil, nil
}

func (r *reconciler) Watches() (*source.Kind, handler.EventHandler, []builder.WatchesOption) {
// return &source.Kind{Type: new(corev1.Pod)}, &handler.EnqueueRequestForObject{}
return nil, nil, nil
}
21 changes: 21 additions & 0 deletions internal/k8s/benchmark/job/option.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Copyright (C) 2019-2022 vdaas.org vald team <vald@vdaas.org>
//
// 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
//
// https://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 job

type Option func(*reconciler) error

var defaultOpts = []Option{}
242 changes: 242 additions & 0 deletions internal/k8s/benchmark/job/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
//
// Copyright (C) 2019-2022 vdaas.org vald team <vald@vdaas.org>
//
// 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
//
// https://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 job

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

type BenchmarkJobSpec struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
fieldalignment: struct with 104 pointer bytes could be 56 (govet)

Target *BenchmarkTarget
Dataset *BenchmarkDataset
Replica int
Repetition int
JobType string
Dimension int
Epsilon float32
Radius float32
Iter int
Num int32
MinNum int32
Timeout string
Rules []*BenchmarkJobRule
}

type BenchmarkJobStatus string

const (
BenchmarkJobNotReady = BenchmarkJobStatus("NotReady")
BenchmarkJobAvailable = BenchmarkJobStatus("Available")
BenchmarkJobHealthy = BenchmarkJobStatus("Healthy")
)

type BenchmarkTarget struct {
Host string
Port int
}

type BenchmarkDataset struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
fieldalignment: struct with 48 pointer bytes could be 32 (govet)

Name string
Group string
Indexes int
Range *BenchmarkDatasetRange
}

type BenchmarkDatasetRange struct {
Start int
End int
}

type BenchmarkJobRule struct {
Name string
Type string
}

type BenchmarkJob struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
fieldalignment: struct with 392 pointer bytes could be 384 (govet)

metav1.TypeMeta
metav1.ObjectMeta

Spec BenchmarkJobSpec
Status BenchmarkJobStatus
}

type BenchmarkJobList struct {
metav1.TypeMeta
metav1.ListMeta

Items []BenchmarkJob
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BenchmarkDataset) DeepCopyInto(out *BenchmarkDataset) {
*out = *in
if in.Range != nil {
in, out := &in.Range, &out.Range
*out = new(BenchmarkDatasetRange)
**out = **in
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BenchmarkDataset.
func (in *BenchmarkDataset) DeepCopy() *BenchmarkDataset {
if in == nil {
return nil
}
out := new(BenchmarkDataset)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BenchmarkDatasetRange) DeepCopyInto(out *BenchmarkDatasetRange) {
*out = *in
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BenchmarkDatasetRange.
func (in *BenchmarkDatasetRange) DeepCopy() *BenchmarkDatasetRange {
if in == nil {
return nil
}
out := new(BenchmarkDatasetRange)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BenchmarkJobRule) DeepCopyInto(out *BenchmarkJobRule) {
*out = *in
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BenchmarkJobRule.
func (in *BenchmarkJobRule) DeepCopy() *BenchmarkJobRule {
if in == nil {
return nil
}
out := new(BenchmarkJobRule)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BenchmarkJobSpec) DeepCopyInto(out *BenchmarkJobSpec) {
*out = *in
if in.Target != nil {
in, out := &in.Target, &out.Target
*out = new(BenchmarkTarget)
**out = **in
}
if in.Dataset != nil {
in, out := &in.Dataset, &out.Dataset
*out = new(BenchmarkDataset)
(*in).DeepCopyInto(*out)
}
if in.Rules != nil {
in, out := &in.Rules, &out.Rules
*out = make([]*BenchmarkJobRule, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(BenchmarkJobRule)
**out = **in
}
}
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BenchmarkJobSpec.
func (in *BenchmarkJobSpec) DeepCopy() *BenchmarkJobSpec {
if in == nil {
return nil
}
out := new(BenchmarkJobSpec)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BenchmarkTarget) DeepCopyInto(out *BenchmarkTarget) {
*out = *in
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BenchmarkTarget.
func (in *BenchmarkTarget) DeepCopy() *BenchmarkTarget {
if in == nil {
return nil
}
out := new(BenchmarkTarget)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BenchmarkJob) DeepCopyInto(out *BenchmarkJob) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BenchmarkOperator.
func (in *BenchmarkJob) DeepCopy() *BenchmarkJob {
if in == nil {
return nil
}
out := new(BenchmarkJob)
in.DeepCopyInto(out)
return out
}

// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *BenchmarkJob) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BenchmarkJobList) DeepCopyInto(out *BenchmarkJobList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]BenchmarkJob, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BenchmarkOperatorList.
func (in *BenchmarkJobList) DeepCopy() *BenchmarkJobList {
if in == nil {
return nil
}
out := new(BenchmarkJobList)
in.DeepCopyInto(out)
return out
}

// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *BenchmarkJobList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
18 changes: 18 additions & 0 deletions internal/k8s/benchmark/operator/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Copyright (C) 2019-2022 vdaas.org vald team <vald@vdaas.org>
//
// 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
//
// https://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 operator provides benchmark operator crd information and preriodically update
package operator
Loading