Skip to content

Commit

Permalink
Merge pull request #555 from nikola-jokic/nikola-jokic/metrics
Browse files Browse the repository at this point in the history
[kwok] Provide generic functions that enable it to simulate data for any indicator (Node)
  • Loading branch information
k8s-ci-robot authored Jun 14, 2023
2 parents b4b7fa6 + a7fa8aa commit e619889
Show file tree
Hide file tree
Showing 44 changed files with 2,341 additions and 57 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ jobs:
run: |
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_extra
- name: Test Metrics
shell: bash
run: |
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_metric
- name: Test Benchmark
if: ${{ matrix.os == 'ubuntu-latest' && matrix.kwokctl-runtime != 'kind' && matrix.kwokctl-runtime != 'kind-podman' }}
shell: bash
Expand Down
12 changes: 8 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ require (
github.com/creack/pty v1.1.18
github.com/emicklei/go-restful/v3 v3.10.2
github.com/fsnotify/fsnotify v1.6.0
github.com/google/cel-go v0.15.2
github.com/google/go-cmp v0.5.9
github.com/itchyny/gojq v0.12.12
github.com/nxadm/tail v1.4.8
github.com/prometheus/client_golang v1.15.0
github.com/prometheus/client_model v0.3.0
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/wzshiming/cmux v0.3.2
github.com/wzshiming/cron v0.2.1
github.com/wzshiming/ctc v1.2.3
github.com/wzshiming/easycel v0.4.0
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
golang.org/x/sync v0.2.0
golang.org/x/sys v0.8.0
Expand All @@ -38,6 +41,7 @@ require (
)

require (
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containernetworking/cni v1.1.2 // indirect
Expand Down Expand Up @@ -72,22 +76,22 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/wzshiming/llrb v0.2.1 // indirect
github.com/wzshiming/trie v0.1.1 // indirect
github.com/wzshiming/winseq v0.0.0-20200112104235-db357dc107ae // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.2.0 // indirect
golang.org/x/tools v0.7.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
google.golang.org/grpc v1.51.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
Expand Down
60 changes: 14 additions & 46 deletions go.sum

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions pkg/apis/internalversion/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,25 @@ func ConvertToInternalAttach(in *v1alpha1.Attach) (*Attach, error) {
}
return &out, nil
}

// ConvertToV1Alpha1Metric converts an internal version Metric to a v1alpha1.Metric.
func ConvertToV1Alpha1Metric(in *Metric) (*v1alpha1.Metric, error) {
var out v1alpha1.Metric
out.APIVersion = v1alpha1.GroupVersion.String()
out.Kind = v1alpha1.MetricKind
err := Convert_internalversion_Metric_To_v1alpha1_Metric(in, &out, nil)
if err != nil {
return nil, err
}
return &out, nil
}

// ConvertToInternalMetric converts a v1alpha1.Metric to an internal version.
func ConvertToInternalMetric(in *v1alpha1.Metric) (*Metric, error) {
var out Metric
err := Convert_v1alpha1_Metric_To_internalversion_Metric(in, &out, nil)
if err != nil {
return nil, err
}
return &out, nil
}
73 changes: 73 additions & 0 deletions pkg/apis/internalversion/metric_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
Copyright 2023 The Kubernetes 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 internalversion

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

// Metric provides metrics configuration.
type Metric struct {
// Standard list metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
metav1.ObjectMeta
// Spec holds spec for metrics.
Spec MetricSpec
}

// MetricSpec holds spec for metrics.
type MetricSpec struct {
// Path is a restful service path.
Path string
// Metrics is a list of metric configurations.
Metrics []MetricConfig
}

// MetricConfig provides metric configuration to a single metric
type MetricConfig struct {
// Name is the fully-qualified name of the metric.
Name string
// Help provides information about this metric.
Help string
// Kind is kind of metric (ex. counter, gauge, histogram).
Kind string
// Labels are metric labels.
Labels []MetricLabel
// Value is a CEL expression.
Value string
// Buckets is a list of buckets for a histogram metric.
Buckets []MetricBucket
}

// MetricLabel holds label name and the value of the label.
type MetricLabel struct {
// Name is a label name.
Name string
// Value is a CEL expression.
Value string
}

// MetricBucket is a single bucket for a metric.
type MetricBucket struct {
// Le is less-than or equal.
Le float64
// Value is a CEL expression.
Value string
// Hidden is means that this bucket not shown in the metric.
// but value will be calculated and cumulative into the next bucket.
Hidden bool
}
175 changes: 175 additions & 0 deletions pkg/apis/internalversion/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e619889

Please sign in to comment.