Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

WIP: Refactor framework #12

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
61b7fd3
chore(module): update go module
mlycore Mar 21, 2022
4e8f67b
wip: working on apply and remove
mlycore Mar 21, 2022
b1679ed
chore(module): update go module
mlycore Mar 21, 2022
a186c87
wip: working on apply and remove
mlycore Mar 21, 2022
5b6c383
fix conflicts
mlycore Mar 21, 2022
aecca7d
wip: add tc and bpf load utils
mlycore Mar 21, 2022
7a4f0d4
fix: package dependencies
mlycore Mar 22, 2022
03e0dbd
fix: import C for cgo
mlycore Mar 22, 2022
1e17a13
fix: import C for cgo
mlycore Mar 22, 2022
fe6f1e3
Merge branch 'refactor-framework' of https://github.com/database-mesh…
mlycore Mar 22, 2022
bd2a88a
fix: typo
mlycore Mar 22, 2022
039abf9
fix: remove unused packages
mlycore Mar 22, 2022
4940aa9
fix: add cri to manager
mlycore Mar 22, 2022
0798da9
fix: cri
mlycore Mar 22, 2022
011c6be
fix: fix error handle
mlycore Mar 22, 2022
d50dbb4
fix: add error handle in main
mlycore Mar 22, 2022
162625a
feat: add error log
mlycore Mar 22, 2022
c3dcc6d
feat: add error log
mlycore Mar 22, 2022
c8e0b61
refactor: rename sqltrafficqos to trafficqos
mlycore Mar 25, 2022
3fd2469
chore: add linux makefile
mlycore Mar 25, 2022
feefd44
feat(virtualdatabase): add bandwidth
mlycore Mar 28, 2022
bd9fbfd
feat(traffocqosmapping): add trafficqosmapping definition and manifests
mlycore Mar 28, 2022
ac4c12a
feat(crd): update generated deep copy of crds
mlycore Mar 28, 2022
70b06c7
chore(clang): remove c files
mlycore Mar 28, 2022
3e744b8
refactor(trafficqosmapping): update trafficqos related references
mlycore Mar 28, 2022
7e1d2bb
fix: remove reconcile in TrafficQoSMapping
mlycore Mar 28, 2022
dd1fcdb
chore(crd): fix object type in trafficqosmapping
mlycore Mar 28, 2022
04313b9
fix(tc): add invalid argument to tc addclass
mlycore Mar 28, 2022
9e1a5c8
fix(tc): using minor of current classes for new class
mlycore Mar 28, 2022
27d94d3
fix(tc): using next classid
mlycore Mar 28, 2022
d2c9cec
chore(crd): remove required flag for trafficqos ceil
mlycore Mar 28, 2022
a8ea40f
wip: add controllers
mlycore Mar 28, 2022
1497bce
chore(crd): remove comments in trafficqosmapping
mlycore Apr 1, 2022
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
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ LDFLAGS := "-s -w -X 'github.com/database-mesh/waterline/pkg/vesrion.GitCommit=`
build:
mkdir -p bin
go build -ldflags=${LDFLAGS} -o bin/waterline cmd/waterline/main.go
linux:
mkdir -p bin
GOOS=linux GOARCH=amd64 go build -ldflags=${LDFLAGS} -o bin/waterline cmd/waterline/main.go


Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ type TrafficQoSGroup struct {
Ceil string `json:"ceil",omitempty`
}

// SQLTrafficQoSSpec defines the desired state of SQLTrafficQoS
type SQLTrafficQoSSpec struct {
// TrafficQoSSpec defines the desired state of TrafficQoS
type TrafficQoSSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of SQLTrafficQoS. Edit sqltrafficqos_types.go to remove/update
// Foo is an example field of TrafficQoS. Edit trafficqos_types.go to remove/update
NetworkDevice string `json:"networkDevice"`
QoSClass QoSClassType `json:"qosClass,omitempty"`
Strategy TrafficQoSStrategy `json:"strategy",omitempty`
Groups []TrafficQoSGroup `json:"groups"`
}

// SQLTrafficQoSStatus defines the observed state of SQLTrafficQoS
type SQLTrafficQoSStatus struct {
// TrafficQoSStatus defines the observed state of TrafficQoS
type TrafficQoSStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

Expand All @@ -64,24 +64,24 @@ type SQLTrafficQoSStatus struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// SQLTrafficQoS is the Schema for the sqltrafficqos API
type SQLTrafficQoS struct {
// TrafficQoS is the Schema for the trafficqos API
type TrafficQoS struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec SQLTrafficQoSSpec `json:"spec,omitempty"`
Status SQLTrafficQoSStatus `json:"status,omitempty"`
Spec TrafficQoSSpec `json:"spec,omitempty"`
Status TrafficQoSStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// SQLTrafficQoSList contains a list of SQLTrafficQoS
type SQLTrafficQoSList struct {
// TrafficQoSList contains a list of TrafficQoS
type TrafficQoSList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []SQLTrafficQoS `json:"items"`
Items []TrafficQoS `json:"items"`
}

func init() {
SchemeBuilder.Register(&SQLTrafficQoS{}, &SQLTrafficQoSList{})
SchemeBuilder.Register(&TrafficQoS{}, &TrafficQoSList{})
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,52 @@ import (
)

// log is for logging in this package.
var sqltrafficqoslog = logf.Log.WithName("sqltrafficqos-resource")
var trafficqoslog = logf.Log.WithName("trafficqos-resource")

func (r *SQLTrafficQoS) SetupWebhookWithManager(mgr ctrl.Manager) error {
func (r *TrafficQoS) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Complete()
}

// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!

//+kubebuilder:webhook:path=/mutate-database-mesh-io-database-mesh-io-v1alpha1-sqltrafficqos,mutating=true,failurePolicy=fail,sideEffects=None,groups=database-mesh.io.database-mesh.io,resources=sqltrafficqos,verbs=create;update,versions=v1alpha1,name=msqltrafficqos.kb.io,admissionReviewVersions=v1
//+kubebuilder:webhook:path=/mutate-database-mesh-io-database-mesh-io-v1alpha1-trafficqos,mutating=true,failurePolicy=fail,sideEffects=None,groups=database-mesh.io.database-mesh.io,resources=trafficqos,verbs=create;update,versions=v1alpha1,name=mtrafficqos.kb.io,admissionReviewVersions=v1

var _ webhook.Defaulter = &SQLTrafficQoS{}
var _ webhook.Defaulter = &TrafficQoS{}

// Default implements webhook.Defaulter so a webhook will be registered for the type
func (r *SQLTrafficQoS) Default() {
sqltrafficqoslog.Info("default", "name", r.Name)
func (r *TrafficQoS) Default() {
trafficqoslog.Info("default", "name", r.Name)

// TODO(user): fill in your defaulting logic.
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
//+kubebuilder:webhook:path=/validate-database-mesh-io-database-mesh-io-v1alpha1-sqltrafficqos,mutating=false,failurePolicy=fail,sideEffects=None,groups=database-mesh.io.database-mesh.io,resources=sqltrafficqos,verbs=create;update,versions=v1alpha1,name=vsqltrafficqos.kb.io,admissionReviewVersions=v1
//+kubebuilder:webhook:path=/validate-database-mesh-io-database-mesh-io-v1alpha1-trafficqos,mutating=false,failurePolicy=fail,sideEffects=None,groups=database-mesh.io.database-mesh.io,resources=trafficqos,verbs=create;update,versions=v1alpha1,name=vtrafficqos.kb.io,admissionReviewVersions=v1

var _ webhook.Validator = &SQLTrafficQoS{}
var _ webhook.Validator = &TrafficQoS{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *SQLTrafficQoS) ValidateCreate() error {
sqltrafficqoslog.Info("validate create", "name", r.Name)
func (r *TrafficQoS) ValidateCreate() error {
trafficqoslog.Info("validate create", "name", r.Name)

// TODO(user): fill in your validation logic upon object creation.

return nil
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *SQLTrafficQoS) ValidateUpdate(old runtime.Object) error {
sqltrafficqoslog.Info("validate update", "name", r.Name)
func (r *TrafficQoS) ValidateUpdate(old runtime.Object) error {
trafficqoslog.Info("validate update", "name", r.Name)

// TODO(user): fill in your validation logic upon object update.
return nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *SQLTrafficQoS) ValidateDelete() error {
sqltrafficqoslog.Info("validate delete", "name", r.Name)
func (r *TrafficQoS) ValidateDelete() error {
trafficqoslog.Info("validate delete", "name", r.Name)

// TODO(user): fill in your validation logic upon object deletion.
return nil
Expand Down
74 changes: 74 additions & 0 deletions api/v1alpha1/trafficqosmapping_webhook.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright 2022 Database Mesh 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 v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

// log is for logging in this package.
var trafficqosmappinglog = logf.Log.WithName("trafficqosmapping-resource")

func (r *TrafficQoSMapping) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Complete()
}

// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!

//+kubebuilder:webhook:path=/mutate-database-mesh-io-database-mesh-io-v1alpha1-TrafficQoSMapping,mutating=true,failurePolicy=fail,sideEffects=None,groups=database-mesh.io.database-mesh.io,resources=trafficqosmapping,verbs=create;update,versions=v1alpha1,name=mtrafficqosmapping.kb.io,admissionReviewVersions=v1

var _ webhook.Defaulter = &TrafficQoSMapping{}

// Default implements webhook.Defaulter so a webhook will be registered for the type
func (r *TrafficQoSMapping) Default() {
trafficqosmappinglog.Info("default", "name", r.Name)

// TODO(user): fill in your defaulting logic.
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
//+kubebuilder:webhook:path=/validate-database-mesh-io-database-mesh-io-v1alpha1-TrafficQoSMapping,mutating=false,failurePolicy=fail,sideEffects=None,groups=database-mesh.io.database-mesh.io,resources=trafficqosmapping,verbs=create;update,versions=v1alpha1,name=vtrafficqosmapping.kb.io,admissionReviewVersions=v1

var _ webhook.Validator = &TrafficQoSMapping{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *TrafficQoSMapping) ValidateCreate() error {
trafficqosmappinglog.Info("validate create", "name", r.Name)

// TODO(user): fill in your validation logic upon object creation.

return nil
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *TrafficQoSMapping) ValidateUpdate(old runtime.Object) error {
trafficqosmappinglog.Info("validate update", "name", r.Name)

// TODO(user): fill in your validation logic upon object update.
return nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *TrafficQoSMapping) ValidateDelete() error {
trafficqosmappinglog.Info("validate delete", "name", r.Name)

// TODO(user): fill in your validation logic upon object deletion.
return nil
}
66 changes: 66 additions & 0 deletions api/v1alpha1/trafficqosmappping_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2022 Database Mesh 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 v1alpha1

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

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// TrafficQoSMappingSpec defines the desired state of TrafficQoSMapping
type TrafficQoSMappingSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of TrafficQoSMapping. Edit trafficqos_types.go to remove/update
References map[string]string `json:"references`

//
// 1:1 <- virtualdatabase namespace / name
}

// TrafficQoSMappingStatus defines the observed state of TrafficQoSMapping
type TrafficQoSMappingStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

//TODO: add ObservedGeneration
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// TrafficQoSMapping is the Schema for the trafficqos API
type TrafficQoSMapping struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec TrafficQoSMappingSpec `json:"spec,omitempty"`
}

//+kubebuilder:object:root=true

// TrafficQoSMappingList contains a list of TrafficQoSMapping
type TrafficQoSMappingList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []TrafficQoSMapping `json:"items"`
}

func init() {
SchemeBuilder.Register(&TrafficQoSMapping{}, &TrafficQoSMappingList{})
}
8 changes: 4 additions & 4 deletions api/v1alpha1/virtualdatabase_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ type VirtualDatabaseSpec struct {
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of VirtualDatabase. Edit virtualdatabase_types.go to remove/update
Selector map[string]string `json:"selector"`
Selector map[string]string `json:"selector"` // TODO: Is it needed ? Or is it applied with Endpoints ?
Server VirtualDatabaseServer `json:"server"`
QoS string `json:"qos"`
Bandwidth string `json:"bandwidth`
Bandwidth string `json:"bandwidth"`
}

// VirtualDatabaseStatus defines the observed state of VirtualDatabase
type VirtualDatabaseStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
PodList []string `json:"podList"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
ClassInfo string `json:"classInfo"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

type Pod string
Expand Down
Loading