-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify clickhouse statistic related func for theia-manager (#132)
1. Define REST request and return payload struct for related API endpoints and add code generation under pkg/apis/stats a. REST endpoint apis/stats.theia.antrea.io/v1alpha1/clickhouse 2. Adapt CLI to use Theia Manager 3. Modify e2e test
- Loading branch information
1 parent
5a15bb8
commit b6c1c1f
Showing
29 changed files
with
1,505 additions
and
692 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
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
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
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
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
27 changes: 10 additions & 17 deletions
27
pkg/util/policyrecommendation/utils.go → pkg/apis/stats/install/install.go
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 |
---|---|---|
@@ -1,35 +1,28 @@ | ||
// Copyright 2022 Antrea Authors. | ||
// Copyright 2022 Antrea 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 | ||
// 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 policyrecommendation | ||
package install | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
|
||
"github.com/google/uuid" | ||
"antrea.io/theia/pkg/apis/stats/v1alpha1" | ||
) | ||
|
||
func ParseRecommendationName(npName string) error { | ||
if !strings.HasPrefix(npName, "pr-") { | ||
return fmt.Errorf("input name %s is not a valid policy recommendation job name", npName) | ||
|
||
} | ||
id := npName[3:] | ||
_, err := uuid.Parse(id) | ||
if err != nil { | ||
return fmt.Errorf("input name %s does not contain a valid UUID, parsing error: %v", npName, err) | ||
} | ||
return nil | ||
// Install registers the API group and adds types to a scheme | ||
func Install(scheme *runtime.Scheme) { | ||
utilruntime.Must(v1alpha1.AddToScheme(scheme)) | ||
utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion)) | ||
} |
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,20 @@ | ||
// Copyright 2022 Antrea 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. | ||
|
||
// +k8s:openapi-gen=true | ||
// +k8s:deepcopy-gen=package | ||
// +k8s:defaulter-gen=TypeMeta | ||
// +groupName=intelligence.theia.antrea.io | ||
|
||
package v1alpha1 |
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,58 @@ | ||
// Copyright 2022 Antrea 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" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
const GroupName = "stats.theia.antrea.io" | ||
|
||
var ( | ||
SchemeGroupVersion = schema.GroupVersion{ | ||
Group: GroupName, | ||
Version: "v1alpha1"} | ||
|
||
StatusResource = schema.GroupVersionResource{ | ||
Group: SchemeGroupVersion.Group, | ||
Version: SchemeGroupVersion.Version, | ||
Resource: "clickhouse"} | ||
) | ||
|
||
var ( | ||
SchemeBuilder runtime.SchemeBuilder | ||
localSchemeBuilder = &SchemeBuilder | ||
AddToScheme = localSchemeBuilder.AddToScheme | ||
) | ||
|
||
func init() { | ||
localSchemeBuilder.Register(addKnownTypes) | ||
} | ||
|
||
func Resource(resource string) schema.GroupResource { | ||
return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
} | ||
|
||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes( | ||
SchemeGroupVersion, | ||
&ClickHouseStats{}, | ||
) | ||
|
||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
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,64 @@ | ||
// Copyright 2022 Antrea 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" | ||
) | ||
|
||
// +genclient | ||
// +genclient:nonNamespaced | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
type ClickHouseStats struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
DiskInfos []DiskInfo `json:"diskInfos,omitempty"` | ||
TableInfos []TableInfo `json:"tableInfos,omitempty"` | ||
InsertRates []InsertRate `json:"insertRates,omitempty"` | ||
StackTraces []StackTrace `json:"stackTraces,omitempty"` | ||
ErrorMsg []string `json:"errorMsg,omitempty"` | ||
} | ||
|
||
type DiskInfo struct { | ||
Shard string `json:"shard,omitempty"` | ||
Database string `json:"name,omitempty"` | ||
Path string `json:"path,omitempty"` | ||
FreeSpace string `json:"freeSpace,omitempty"` | ||
TotalSpace string `json:"totalSpace,omitempty"` | ||
UsedPercentage string `json:"usedPercentage,omitempty"` | ||
} | ||
|
||
type TableInfo struct { | ||
Shard string `json:"shard,omitempty"` | ||
Database string `json:"database,omitempty"` | ||
TableName string `json:"tableName,omitempty"` | ||
TotalRows string `json:"totalRows,omitempty"` | ||
TotalBytes string `json:"totalBytes,omitempty"` | ||
TotalCols string `json:"totalCols,omitempty"` | ||
} | ||
|
||
type InsertRate struct { | ||
Shard string `json:"shard,omitempty"` | ||
RowsPerSec string `json:"rowsPerSec,omitempty"` | ||
BytesPerSec string `json:"bytesPerSec,omitempty"` | ||
} | ||
|
||
type StackTrace struct { | ||
Shard string `json:"shard,omitempty"` | ||
TraceFunctions string `json:"traceFunctions,omitempty"` | ||
Count string `json:"count,omitempty"` | ||
} |
Oops, something went wrong.