-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add crds for continuous benchmark tools (#1789)
* ✨ add crds for continuous benchmark operator Signed-off-by: vankichi <kyukawa315@gmail.com> * ✨ add benchmark operator/job scheme Signed-off-by: vankichi <kyukawa315@gmail.com> * ✨ rename package names and add doc.go Signed-off-by: vankichi <kyukawa315@gmail.com> * ✨ create runtime object Signed-off-by: vankichi <kyukawa315@gmail.com> * Apply suggestions from code review Co-authored-by: Yusuke Kato <kpango@vdaas.org> * ♻️ apply feedback Signed-off-by: vankichi <kyukawa315@gmail.com> Signed-off-by: vankichi <kyukawa315@gmail.com> Co-authored-by: Yusuke Kato <kpango@vdaas.org>
- Loading branch information
Showing
17 changed files
with
1,608 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
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 { | ||
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 { | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.