From 337ba852d6fba38d3f788836df72ffb4fd37b53d Mon Sep 17 00:00:00 2001 From: vankichi Date: Mon, 15 Apr 2024 14:42:42 +0900 Subject: [PATCH] :recycle: Change vbor chart for apply general job configuration Signed-off-by: vankichi --- .../crds/valdbenchmarkoperatorrelease.yaml | 200 +++++++++++++- .../templates/configmap.yaml | 5 +- charts/vald-benchmark-operator/values.yaml | 246 +++++++++++++++++- internal/config/benchmark.go | 12 +- .../grpc/interceptor/client/metric/metric.go | 4 + .../10-vald-benchmark-operator.yaml | 8 +- k8s/tools/benchmark/operator/configmap.yaml | 86 +++++- .../crds/valdbenchmarkoperatorrelease.yaml | 200 +++++++++++++- pkg/tools/benchmark/operator/config/config.go | 10 +- .../benchmark/operator/service/operator.go | 6 +- .../operator/service/operator_test.go | 106 ++++---- .../benchmark/operator/service/option.go | 21 +- .../benchmark/operator/usecase/benchmarkd.go | 7 +- 13 files changed, 801 insertions(+), 110 deletions(-) diff --git a/charts/vald-benchmark-operator/crds/valdbenchmarkoperatorrelease.yaml b/charts/vald-benchmark-operator/crds/valdbenchmarkoperatorrelease.yaml index 92458c639c5..16a5c912b0a 100644 --- a/charts/vald-benchmark-operator/crds/valdbenchmarkoperatorrelease.yaml +++ b/charts/vald-benchmark-operator/crds/valdbenchmarkoperatorrelease.yaml @@ -86,19 +86,197 @@ spec: type: string tag: type: string - job_image: + job: type: object properties: - pullPolicy: - type: string - enum: - - Always - - Never - - IfNotPresent - repository: - type: string - tag: - type: string + client_config: + type: object + properties: + addrs: + type: array + items: + type: string + backoff: + type: object + properties: + backoff_factor: + type: number + backoff_time_limit: + type: string + enable_error_log: + type: boolean + initial_duration: + type: string + jitter_limit: + type: string + maximum_duration: + type: string + retry_count: + type: integer + call_option: + type: object + x-kubernetes-preserve-unknown-fields: true + circuit_breaker: + type: object + properties: + closed_error_rate: + type: number + closed_refresh_timeout: + type: string + half_open_error_rate: + type: number + min_samples: + type: integer + open_timeout: + type: string + connection_pool: + type: object + properties: + enable_dns_resolver: + type: boolean + enable_rebalance: + type: boolean + old_conn_close_duration: + type: string + rebalance_duration: + type: string + size: + type: integer + dial_option: + type: object + properties: + backoff_base_delay: + type: string + backoff_jitter: + type: number + backoff_max_delay: + type: string + backoff_multiplier: + type: number + enable_backoff: + type: boolean + initial_connection_window_size: + type: integer + initial_window_size: + type: integer + insecure: + type: boolean + interceptors: + type: array + items: + type: string + enum: + - TraceInterceptor + keepalive: + type: object + properties: + permit_without_stream: + type: boolean + time: + type: string + timeout: + type: string + max_msg_size: + type: integer + min_connection_timeout: + type: string + net: + type: object + properties: + dialer: + type: object + properties: + dual_stack_enabled: + type: boolean + keepalive: + type: string + timeout: + type: string + dns: + type: object + properties: + cache_enabled: + type: boolean + cache_expiration: + type: string + refresh_duration: + type: string + socket_option: + type: object + properties: + ip_recover_destination_addr: + type: boolean + ip_transparent: + type: boolean + reuse_addr: + type: boolean + reuse_port: + type: boolean + tcp_cork: + type: boolean + tcp_defer_accept: + type: boolean + tcp_fast_open: + type: boolean + tcp_no_delay: + type: boolean + tcp_quick_ack: + type: boolean + tls: + type: object + properties: + ca: + type: string + cert: + type: string + enabled: + type: boolean + insecure_skip_verify: + type: boolean + key: + type: string + read_buffer_size: + type: integer + timeout: + type: string + write_buffer_size: + type: integer + health_check_duration: + type: string + max_recv_msg_size: + type: integer + max_retry_rpc_buffer_size: + type: integer + max_send_msg_size: + type: integer + tls: + type: object + properties: + ca: + type: string + cert: + type: string + enabled: + type: boolean + insecure_skip_verify: + type: boolean + key: + type: string + wait_for_ready: + type: boolean + image: + type: object + properties: + pullPolicy: + type: string + enum: + - Always + - Never + - IfNotPresent + repository: + type: string + tag: + type: string logging: type: object properties: diff --git a/charts/vald-benchmark-operator/templates/configmap.yaml b/charts/vald-benchmark-operator/templates/configmap.yaml index f2ddf91f859..2a92332b6ba 100644 --- a/charts/vald-benchmark-operator/templates/configmap.yaml +++ b/charts/vald-benchmark-operator/templates/configmap.yaml @@ -38,6 +38,5 @@ data: observability: {{- $observability := dict "Values" .Values.observability}} {{- include "vald.observability" $observability | nindent 6 }} - job_image: - image: "{{ .Values.job_image.repository }}:{{ .Values.job_image.tag }}" - pullPolicy: {{ .Values.job_image.pullPolicy }} + job: + {{- toYaml .Values.job | nindent 6 }} diff --git a/charts/vald-benchmark-operator/values.yaml b/charts/vald-benchmark-operator/values.yaml index 3aebcabc365..59d78fd0f66 100644 --- a/charts/vald-benchmark-operator/values.yaml +++ b/charts/vald-benchmark-operator/values.yaml @@ -37,17 +37,241 @@ image: # @schema {"name": "image.pullPolicy", "type": "string", "enum": ["Always", "Never", "IfNotPresent"]} # image.pullPolicy -- image pull policy pullPolicy: Always -# @schema {"name": "job_image", "type": "object"} -job_image: - # @schema {"name": "job_image.repository", "type": "string"} - # image.repository -- job image repository - repository: vdaas/vald-benchmark-job - # @schema {"name": "job_image.tag", "type": "string"} - # image.tag -- image tag for job docker image - tag: v1.7.12 - # @schema {"name": "job_image.pullPolicy", "type": "string", "enum": ["Always", "Never", "IfNotPresent"]} - # image.pullPolicy -- image pull policy - pullPolicy: Always +# @schema {"name": "job", "type": "object"} +job: + # @schema {"name": "job.image", "type": "object"} + image: + # @schema {"name": "job.image.repository", "type": "string"} + # image.repository -- job image repository + repository: vdaas/vald-benchmark-job + # @schema {"name": "job.image.tag", "type": "string"} + # image.tag -- image tag for job docker image + tag: v1.7.12 + # @schema {"name": "job.image.pullPolicy", "type": "string", "enum": ["Always", "Never", "IfNotPresent"]} + # image.pullPolicy -- image pull policy + pullPolicy: Always + # @schema {"name": "job.client_config", "type": "object"} + # client_config -- gRPC client config for request to the Vald cluster + client_config: + # @schema {"name": "job.client_config.addrs", "type": "array", "items": {"type": "string"}} + # job.client_config.addrs -- gRPC client addresses + addrs: [] + # @schema {"name": "job.client_config.health_check_duration", "type": "string"} + # job.client_config.health_check_duration -- gRPC client health check duration + health_check_duration: "1s" + # @schema {"name": "job.client_config.connection_pool", "type": "object"} + connection_pool: + # @schema {"name": "job.client_config.connection_pool.enable_dns_resolver", "type": "boolean"} + # job.client_config.connection_pool.enable_dns_resolver -- enables gRPC client connection pool dns resolver, when enabled vald uses ip handshake exclude dns discovery which improves network performance + enable_dns_resolver: true + # @schema {"name": "job.client_config.connection_pool.enable_rebalance", "type": "boolean"} + # job.client_config.connection_pool.enable_rebalance -- enables gRPC client connection pool rebalance + enable_rebalance: true + # @schema {"name": "job.client_config.connection_pool.rebalance_duration", "type": "string"} + # job.client_config.connection_pool.rebalance_duration -- gRPC client connection pool rebalance duration + rebalance_duration: 30m + # @schema {"name": "job.client_config.connection_pool.size", "type": "integer"} + # job.client_config.connection_pool.size -- gRPC client connection pool size + size: 3 + # @schema {"name": "job.client_config.connection_pool.old_conn_close_duration", "type": "string"} + # job.client_config.connection_pool.old_conn_close_duration -- makes delay before gRPC client connection closing during connection pool rebalance + old_conn_close_duration: "2m" + # @schema {"name": "job.client_config.backoff", "type": "object", "anchor": "backoff"} + backoff: + # @schema {"name": "job.client_config.backoff.initial_duration", "type": "string"} + # job.client_config.backoff.initial_duration -- gRPC client backoff initial duration + initial_duration: 5ms + # @schema {"name": "job.client_config.backoff.backoff_time_limit", "type": "string"} + # job.client_config.backoff.backoff_time_limit -- gRPC client backoff time limit + backoff_time_limit: 5s + # @schema {"name": "job.client_config.backoff.maximum_duration", "type": "string"} + # job.client_config.backoff.maximum_duration -- gRPC client backoff maximum duration + maximum_duration: 5s + # @schema {"name": "job.client_config.backoff.jitter_limit", "type": "string"} + # job.client_config.backoff.jitter_limit -- gRPC client backoff jitter limit + jitter_limit: 100ms + # @schema {"name": "job.client_config.backoff.backoff_factor", "type": "number"} + # job.client_config.backoff.backoff_factor -- gRPC client backoff factor + backoff_factor: 1.1 + # @schema {"name": "job.client_config.backoff.retry_count", "type": "integer"} + # job.client_config.backoff.retry_count -- gRPC client backoff retry count + retry_count: 100 + # @schema {"name": "job.client_config.backoff.enable_error_log", "type": "boolean"} + # job.client_config.backoff.enable_error_log -- gRPC client backoff log enabled + enable_error_log: true + # @schema {"name": "job.client_config.circuit_breaker", "type": "object"} + circuit_breaker: + # @schema {"name": "job.client_config.circuit_breaker.closed_error_rate", "type": "number"} + # job.client_config.circuit_breaker.closed_error_rate -- gRPC client circuitbreaker closed error rate + closed_error_rate: 0.7 + # @schema {"name": "job.client_config.circuit_breaker.half_open_error_rate", "type": "number"} + # job.client_config.circuit_breaker.half_open_error_rate -- gRPC client circuitbreaker half-open error rate + half_open_error_rate: 0.5 + # @schema {"name": "job.client_config.circuit_breaker.min_samples", "type": "integer"} + # job.client_config.circuit_breaker.min_samples -- gRPC client circuitbreaker minimum sampling count + min_samples: 1000 + # @schema {"name": "job.client_config.circuit_breaker.open_timeout", "type": "string"} + # job.client_config.circuit_breaker.open_timeout -- gRPC client circuitbreaker open timeout + open_timeout: "1s" + # @schema {"name": "job.client_config.circuit_breaker.closed_refresh_timeout", "type": "string"} + # job.client_config.circuit_breaker.closed_refresh_timeout -- gRPC client circuitbreaker closed refresh timeout + closed_refresh_timeout: "10s" + # @schema {"name": "job.client_config.call_option", "type": "object"} + call_option: + # @schema {"name": "job.client_config.wait_for_ready", "type": "boolean"} + # job.client_config.call_option.wait_for_ready -- gRPC client call option wait for ready + wait_for_ready: true + # @schema {"name": "job.client_config.max_retry_rpc_buffer_size", "type": "integer"} + # job.client_config.call_option.max_retry_rpc_buffer_size -- gRPC client call option max retry rpc buffer size + max_retry_rpc_buffer_size: 0 + # @schema {"name": "job.client_config.max_recv_msg_size", "type": "integer"} + # job.client_config.call_option.max_recv_msg_size -- gRPC client call option max receive message size + max_recv_msg_size: 0 + # @schema {"name": "job.client_config.max_send_msg_size", "type": "integer"} + # job.client_config.call_option.max_send_msg_size -- gRPC client call option max send message size + max_send_msg_size: 0 + # @schema {"name": "job.client_config.dial_option", "type": "object"} + dial_option: + # @schema {"name": "job.client_config.dial_option.write_buffer_size", "type": "integer"} + # job.client_config.dial_option.write_buffer_size -- gRPC client dial option write buffer size + write_buffer_size: 0 + # @schema {"name": "job.client_config.dial_option.read_buffer_size", "type": "integer"} + # job.client_config.dial_option.read_buffer_size -- gRPC client dial option read buffer size + read_buffer_size: 0 + # @schema {"name": "job.client_config.dial_option.initial_window_size", "type": "integer"} + # job.client_config.dial_option.initial_window_size -- gRPC client dial option initial window size + initial_window_size: 0 + # @schema {"name": "job.client_config.dial_option.initial_connection_window_size", "type": "integer"} + # job.client_config.dial_option.initial_connection_window_size -- gRPC client dial option initial connection window size + initial_connection_window_size: 0 + # @schema {"name": "job.client_config.dial_option.max_msg_size", "type": "integer"} + # job.client_config.dial_option.max_msg_size -- gRPC client dial option max message size + max_msg_size: 0 + # @schema {"name": "job.client_config.dial_option.backoff_max_delay", "type": "string"} + # job.client_config.dial_option.backoff_max_delay -- gRPC client dial option max backoff delay + backoff_max_delay: "120s" + # @schema {"name": "job.client_config.dial_option.backoff_base_delay", "type": "string"} + # job.client_config.dial_option.backoff_base_delay -- gRPC client dial option base backoff delay + backoff_base_delay: "1s" + # @schema {"name": "job.client_config.dial_option.backoff_multiplier", "type": "number"} + # job.client_config.dial_option.backoff_multiplier -- gRPC client dial option base backoff delay + backoff_multiplier: 1.6 + # @schema {"name": "job.client_config.dial_option.backoff_jitter", "type": "number"} + # job.client_config.dial_option.backoff_jitter -- gRPC client dial option base backoff delay + backoff_jitter: 0.2 + # @schema {"name": "job.client_config.dial_option.min_connection_timeout", "type": "string"} + # job.client_config.dial_option.min_connection_timeout -- gRPC client dial option minimum connection timeout + min_connection_timeout: "20s" + # @schema {"name": "job.client_config.dial_option.enable_backoff", "type": "boolean"} + # job.client_config.dial_option.enable_backoff -- gRPC client dial option backoff enabled + enable_backoff: false + # @schema {"name": "job.client_config.dial_option.insecure", "type": "boolean"} + # job.client_config.dial_option.insecure -- gRPC client dial option insecure enabled + insecure: true + # @schema {"name": "job.client_config.dial_option.timeout", "type": "string"} + # job.client_config.dial_option.timeout -- gRPC client dial option timeout + timeout: "" + # @schema {"name": "job.client_config.dial_option.interceptors", "type": "array", "items": {"type": "string", "enum": ["TraceInterceptor"]}} + # job.client_config.dial_option.interceptors -- gRPC client interceptors + interceptors: [] + # @schema {"name": "job.client_config.dial_option.net", "type": "object", "anchor": "net"} + net: + # @schema {"name": "job.client_config.dial_option.net.dns", "type": "object"} + dns: + # @schema {"name": "job.client_config.dial_option.net.dns.cache_enabled", "type": "boolean"} + # job.client_config.dial_option.net.dns.cache_enabled -- gRPC client TCP DNS cache enabled + cache_enabled: true + # @schema {"name": "job.client_config.dial_option.net.dns.refresh_duration", "type": "string"} + # job.client_config.dial_option.net.dns.refresh_duration -- gRPC client TCP DNS cache refresh duration + refresh_duration: 30m + # @schema {"name": "job.client_config.dial_option.net.dns.cache_expiration", "type": "string"} + # job.client_config.dial_option.net.dns.cache_expiration -- gRPC client TCP DNS cache expiration + cache_expiration: 1h + # @schema {"name": "job.client_config.dial_option.net.dialer", "type": "object"} + dialer: + # @schema {"name": "job.client_config.dial_option.net.dialer.timeout", "type": "string"} + # job.client_config.dial_option.net.dialer.timeout -- gRPC client TCP dialer timeout + timeout: "" + # @schema {"name": "job.client_config.dial_option.net.dialer.keepalive", "type": "string"} + # job.client_config.dial_option.net.dialer.keepalive -- gRPC client TCP dialer keep alive + keepalive: "" + # @schema {"name": "job.client_config.dial_option.net.dialer.dual_stack_enabled", "type": "boolean"} + # job.client_config.dial_option.net.dialer.dual_stack_enabled -- gRPC client TCP dialer dual stack enabled + dual_stack_enabled: true + # @schema {"name": "job.client_config.dial_option.net.tls", "type": "object"} + tls: + # @schema {"name": "job.client_config.dial_option.net.tls.enabled", "type": "boolean"} + # job.client_config.tls.enabled -- TLS enabled + enabled: false + # @schema {"name": "job.client_config.dial_option.net.tls.cert", "type": "string"} + # job.client_config.tls.cert -- TLS cert path + cert: /path/to/cert + # @schema {"name": "job.client_config.dial_option.net.tls.key", "type": "string"} + # job.client_config.tls.key -- TLS key path + key: /path/to/key + # @schema {"name": "job.client_config.dial_option.net.tls.ca", "type": "string"} + # job.client_config.tls.ca -- TLS ca path + ca: /path/to/ca + # @schema {"name": "job.client_config.dial_option.net.tls.insecure_skip_verify", "type": "boolean"} + # job.client_config.tls.insecure_skip_verify -- enable/disable skip SSL certificate verification + insecure_skip_verify: false + # @schema {"name": "job.client_config.dial_option.net.socket_option", "type": "object"} + socket_option: + # @schema {"name": "job.client_config.dial_option.net.socket_option.reuse_port", "type": "boolean"} + # job.client_config.dial_option.net.socket_option.reuse_port -- server listen socket option for reuse_port functionality + reuse_port: true + # @schema {"name": "job.client_config.dial_option.net.socket_option.reuse_addr", "type": "boolean"} + # job.client_config.dial_option.net.socket_option.reuse_addr -- server listen socket option for reuse_addr functionality + reuse_addr: true + # @schema {"name": "job.client_config.dial_option.net.socket_option.tcp_fast_open", "type": "boolean"} + # job.client_config.dial_option.net.socket_option.tcp_fast_open -- server listen socket option for tcp_fast_open functionality + tcp_fast_open: true + # @schema {"name": "job.client_config.dial_option.net.socket_option.tcp_no_delay", "type": "boolean"} + # job.client_config.dial_option.net.socket_option.tcp_no_delay -- server listen socket option for tcp_no_delay functionality + tcp_no_delay: true + # @schema {"name": "job.client_config.dial_option.net.socket_option.tcp_cork", "type": "boolean"} + # job.client_config.dial_option.net.socket_option.tcp_cork -- server listen socket option for tcp_cork functionality + tcp_cork: false + # @schema {"name": "job.client_config.dial_option.net.socket_option.tcp_quick_ack", "type": "boolean"} + # job.client_config.dial_option.net.socket_option.tcp_quick_ack -- server listen socket option for tcp_quick_ack functionality + tcp_quick_ack: true + # @schema {"name": "job.client_config.dial_option.net.socket_option.tcp_defer_accept", "type": "boolean"} + # job.client_config.dial_option.net.socket_option.tcp_defer_accept -- server listen socket option for tcp_defer_accept functionality + tcp_defer_accept: true + # @schema {"name": "job.client_config.dial_option.net.socket_option.ip_transparent", "type": "boolean"} + # job.client_config.dial_option.net.socket_option.ip_transparent -- server listen socket option for ip_transparent functionality + ip_transparent: false + # @schema {"name": "job.client_config.dial_option.net.socket_option.ip_recover_destination_addr", "type": "boolean"} + # job.client_config.dial_option.net.socket_option.ip_recover_destination_addr -- server listen socket option for ip_recover_destination_addr functionality + ip_recover_destination_addr: false + # @schema {"name": "job.client_config.dial_option.keepalive", "type": "object"} + keepalive: + # @schema {"name": "job.client_config.dial_option.keepalive.time", "type": "string"} + # job.client_config.dial_option.keepalive.time -- gRPC client keep alive time + time: "120s" + # @schema {"name": "job.client_config.dial_option.keepalive.timeout", "type": "string"} + # job.client_config.dial_option.keepalive.timeout -- gRPC client keep alive timeout + timeout: "30s" + # @schema {"name": "job.client_config.dial_option.keepalive.permit_without_stream", "type": "boolean"} + # job.client_config.dial_option.keepalive.permit_without_stream -- gRPC client keep alive permit without stream + permit_without_stream: true + # @schema {"name": "job.client_config.tls", "type": "object"} + tls: + # @schema {"name": "job.client_config.tls.enabled", "type": "boolean"} + # job.client_config.tls.enabled -- TLS enabled + enabled: false + # @schema {"name": "job.client_config.tls.cert", "type": "string"} + # job.client_config.tls.cert -- TLS cert path + cert: /path/to/cert + # @schema {"name": "job.client_config.tls.key", "type": "string"} + # job.client_config.tls.key -- TLS key path + key: /path/to/key + # @schema {"name": "job.client_config.tls.ca", "type": "string"} + # job.client_config.tls.ca -- TLS ca path + ca: /path/to/ca + # @schema {"name": "job.client_config.tls.insecure_skip_verify", "type": "boolean"} + # job.client_config.tls.insecure_skip_verify -- enable/disable skip SSL certificate verification + insecure_skip_verify: false # @schema {"name": "rbac", "type": "object"} rbac: # @schema {"name": "rbac.create", "type": "boolean"} diff --git a/internal/config/benchmark.go b/internal/config/benchmark.go index fd45f4f2933..7b8ab66b945 100644 --- a/internal/config/benchmark.go +++ b/internal/config/benchmark.go @@ -234,13 +234,21 @@ func (b *BenchmarkScenario) Bind() *BenchmarkScenario { // BenchmarkJobImageInfo represents the docker image information for benchmark job. type BenchmarkJobImageInfo struct { - Image string `info:"image" json:"image,omitempty" yaml:"image"` + Repository string `info:"repository" json:"repository,omitempty" yaml:"repository"` + Tag string `info:"tag" json:"tag,omitempty" yaml:"tag"` PullPolicy string `info:"pull_policy" json:"pull_policy,omitempty" yaml:"pull_policy"` } // Bind binds the actual data from the BenchmarkJobImageInfo receiver fields. func (b *BenchmarkJobImageInfo) Bind() *BenchmarkJobImageInfo { - b.Image = GetActualValue(b.Image) + b.Repository = GetActualValue(b.Repository) + b.Tag = GetActualValue(b.Tag) b.PullPolicy = GetActualValue(b.PullPolicy) return b } + +// OperatorJobConfig represents the general job configuration for operator. +type OperatorJobConfig struct { + Image *BenchmarkJobImageInfo `info:"image" json:"image,omitempty" yaml:"image"` + *BenchmarkJob +} diff --git a/internal/net/grpc/interceptor/client/metric/metric.go b/internal/net/grpc/interceptor/client/metric/metric.go index 7fe929a875a..6f3116aa60f 100644 --- a/internal/net/grpc/interceptor/client/metric/metric.go +++ b/internal/net/grpc/interceptor/client/metric/metric.go @@ -1,3 +1,4 @@ +// // Copyright (C) 2019-2024 vdaas.org vald team // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,6 +12,9 @@ // 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 metric provides gRPC client interceptors for client metric package metric import ( diff --git a/k8s/metrics/grafana/dashboards/10-vald-benchmark-operator.yaml b/k8s/metrics/grafana/dashboards/10-vald-benchmark-operator.yaml index 9ee9d26a62e..e14dd51bbe8 100644 --- a/k8s/metrics/grafana/dashboards/10-vald-benchmark-operator.yaml +++ b/k8s/metrics/grafana/dashboards/10-vald-benchmark-operator.yaml @@ -864,7 +864,7 @@ data: "calcs": [ "lastNotNull" ], - "fields": "/^image$/", + "fields": "repository", "values": false }, "showPercentChange": false, @@ -880,7 +880,7 @@ data: "uid": "prometheus" }, "editorMode": "code", - "expr": "label_replace(benchmark_operator_info{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"}, \"image\", \"$1\", \"image\", \"(.*):.*\")", + "expr": "benchmark_operator_info{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"}", "format": "table", "instant": true, "interval": "", @@ -944,7 +944,7 @@ data: "calcs": [ "lastNotNull" ], - "fields": "/^image$/", + "fields": "tag", "values": false }, "showPercentChange": false, @@ -960,7 +960,7 @@ data: "uid": "prometheus" }, "editorMode": "code", - "expr": "label_replace(benchmark_operator_info{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"}, \"image\", \"$1\", \"image\", \".*:(.*)\")", + "expr": "benchmark_operator_info{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"}", "format": "table", "instant": true, "interval": "", diff --git a/k8s/tools/benchmark/operator/configmap.yaml b/k8s/tools/benchmark/operator/configmap.yaml index 499c6053a88..6ee6d73dc0b 100644 --- a/k8s/tools/benchmark/operator/configmap.yaml +++ b/k8s/tools/benchmark/operator/configmap.yaml @@ -137,6 +137,86 @@ data: trace: enabled: false sampling_rate: 1 - job_image: - image: "vdaas/vald-benchmark-job:v1.7.12" - pullPolicy: Always + job: + client_config: + addrs: [] + backoff: + backoff_factor: 1.1 + backoff_time_limit: 5s + enable_error_log: true + initial_duration: 5ms + jitter_limit: 100ms + maximum_duration: 5s + retry_count: 100 + call_option: + max_recv_msg_size: 0 + max_retry_rpc_buffer_size: 0 + max_send_msg_size: 0 + wait_for_ready: true + circuit_breaker: + closed_error_rate: 0.7 + closed_refresh_timeout: 10s + half_open_error_rate: 0.5 + min_samples: 1000 + open_timeout: 1s + connection_pool: + enable_dns_resolver: true + enable_rebalance: true + old_conn_close_duration: 2m + rebalance_duration: 30m + size: 3 + dial_option: + backoff_base_delay: 1s + backoff_jitter: 0.2 + backoff_max_delay: 120s + backoff_multiplier: 1.6 + enable_backoff: false + initial_connection_window_size: 0 + initial_window_size: 0 + insecure: true + interceptors: [] + keepalive: + permit_without_stream: true + time: 120s + timeout: 30s + max_msg_size: 0 + min_connection_timeout: 20s + net: + dialer: + dual_stack_enabled: true + keepalive: "" + timeout: "" + dns: + cache_enabled: true + cache_expiration: 1h + refresh_duration: 30m + socket_option: + ip_recover_destination_addr: false + ip_transparent: false + reuse_addr: true + reuse_port: true + tcp_cork: false + tcp_defer_accept: true + tcp_fast_open: true + tcp_no_delay: true + tcp_quick_ack: true + tls: + ca: /path/to/ca + cert: /path/to/cert + enabled: false + insecure_skip_verify: false + key: /path/to/key + read_buffer_size: 0 + timeout: "" + write_buffer_size: 0 + health_check_duration: 1s + tls: + ca: /path/to/ca + cert: /path/to/cert + enabled: false + insecure_skip_verify: false + key: /path/to/key + image: + pullPolicy: Always + repository: vdaas/vald-benchmark-job + tag: v1.7.12 diff --git a/k8s/tools/benchmark/operator/crds/valdbenchmarkoperatorrelease.yaml b/k8s/tools/benchmark/operator/crds/valdbenchmarkoperatorrelease.yaml index 92458c639c5..16a5c912b0a 100644 --- a/k8s/tools/benchmark/operator/crds/valdbenchmarkoperatorrelease.yaml +++ b/k8s/tools/benchmark/operator/crds/valdbenchmarkoperatorrelease.yaml @@ -86,19 +86,197 @@ spec: type: string tag: type: string - job_image: + job: type: object properties: - pullPolicy: - type: string - enum: - - Always - - Never - - IfNotPresent - repository: - type: string - tag: - type: string + client_config: + type: object + properties: + addrs: + type: array + items: + type: string + backoff: + type: object + properties: + backoff_factor: + type: number + backoff_time_limit: + type: string + enable_error_log: + type: boolean + initial_duration: + type: string + jitter_limit: + type: string + maximum_duration: + type: string + retry_count: + type: integer + call_option: + type: object + x-kubernetes-preserve-unknown-fields: true + circuit_breaker: + type: object + properties: + closed_error_rate: + type: number + closed_refresh_timeout: + type: string + half_open_error_rate: + type: number + min_samples: + type: integer + open_timeout: + type: string + connection_pool: + type: object + properties: + enable_dns_resolver: + type: boolean + enable_rebalance: + type: boolean + old_conn_close_duration: + type: string + rebalance_duration: + type: string + size: + type: integer + dial_option: + type: object + properties: + backoff_base_delay: + type: string + backoff_jitter: + type: number + backoff_max_delay: + type: string + backoff_multiplier: + type: number + enable_backoff: + type: boolean + initial_connection_window_size: + type: integer + initial_window_size: + type: integer + insecure: + type: boolean + interceptors: + type: array + items: + type: string + enum: + - TraceInterceptor + keepalive: + type: object + properties: + permit_without_stream: + type: boolean + time: + type: string + timeout: + type: string + max_msg_size: + type: integer + min_connection_timeout: + type: string + net: + type: object + properties: + dialer: + type: object + properties: + dual_stack_enabled: + type: boolean + keepalive: + type: string + timeout: + type: string + dns: + type: object + properties: + cache_enabled: + type: boolean + cache_expiration: + type: string + refresh_duration: + type: string + socket_option: + type: object + properties: + ip_recover_destination_addr: + type: boolean + ip_transparent: + type: boolean + reuse_addr: + type: boolean + reuse_port: + type: boolean + tcp_cork: + type: boolean + tcp_defer_accept: + type: boolean + tcp_fast_open: + type: boolean + tcp_no_delay: + type: boolean + tcp_quick_ack: + type: boolean + tls: + type: object + properties: + ca: + type: string + cert: + type: string + enabled: + type: boolean + insecure_skip_verify: + type: boolean + key: + type: string + read_buffer_size: + type: integer + timeout: + type: string + write_buffer_size: + type: integer + health_check_duration: + type: string + max_recv_msg_size: + type: integer + max_retry_rpc_buffer_size: + type: integer + max_send_msg_size: + type: integer + tls: + type: object + properties: + ca: + type: string + cert: + type: string + enabled: + type: boolean + insecure_skip_verify: + type: boolean + key: + type: string + wait_for_ready: + type: boolean + image: + type: object + properties: + pullPolicy: + type: string + enum: + - Always + - Never + - IfNotPresent + repository: + type: string + tag: + type: string logging: type: object properties: diff --git a/pkg/tools/benchmark/operator/config/config.go b/pkg/tools/benchmark/operator/config/config.go index f2c8f76b629..29c2ad522e0 100644 --- a/pkg/tools/benchmark/operator/config/config.go +++ b/pkg/tools/benchmark/operator/config/config.go @@ -35,8 +35,8 @@ type Config struct { // Observability represent observability configurations Observability *config.Observability `json:"observability" yaml:"observability"` - // JobImage represents the location of Docker image for benchmark job and its ImagePullPolicy - JobImage *config.BenchmarkJobImageInfo `json:"job_image" yaml:"job_image"` + // Job represents the default benchmark job configuration and job images + Job *config.OperatorJobConfig `json:"job" yaml:"job"` } // NewConfig represents the set config from the given setting file path. @@ -58,10 +58,10 @@ func NewConfig(path string) (cfg *Config, err error) { cfg.Observability = cfg.Observability.Bind() } - if cfg.JobImage != nil { - cfg.JobImage = cfg.JobImage.Bind() + if cfg.Job != nil { + cfg.Job.Image = cfg.Job.Image.Bind() } else { - cfg.JobImage = new(config.BenchmarkJobImageInfo) + cfg.Job = new(config.OperatorJobConfig) } return cfg, nil } diff --git a/pkg/tools/benchmark/operator/service/operator.go b/pkg/tools/benchmark/operator/service/operator.go index cadfa672cc8..1d1e9accd24 100644 --- a/pkg/tools/benchmark/operator/service/operator.go +++ b/pkg/tools/benchmark/operator/service/operator.go @@ -31,6 +31,7 @@ import ( benchjob "github.com/vdaas/vald/internal/k8s/vald/benchmark/job" benchscenario "github.com/vdaas/vald/internal/k8s/vald/benchmark/scenario" "github.com/vdaas/vald/internal/log" + "github.com/vdaas/vald/internal/strings" "github.com/vdaas/vald/internal/sync/errgroup" ) @@ -57,7 +58,8 @@ const ( type operator struct { jobNamespace string - jobImage string + jobImageRepository string + jobImageTag string jobImagePullPolicy string configMapName string scenarios *atomic.Pointer[map[string]*scenario] @@ -474,7 +476,7 @@ func (o *operator) createJob(ctx context.Context, bjr v1.ValdBenchmarkJob) error } job, err := benchjob.NewBenchmarkJob( benchjob.WithContainerName(bjr.GetName()), - benchjob.WithContainerImage(o.jobImage), + benchjob.WithContainerImage(strings.Join([]string{o.jobImageRepository, o.jobImageTag}, ":")), benchjob.WithImagePullPolicy(benchjob.ImagePullPolicy(o.jobImagePullPolicy)), benchjob.WithOperatorConfigMap(o.configMapName), ) diff --git a/pkg/tools/benchmark/operator/service/operator_test.go b/pkg/tools/benchmark/operator/service/operator_test.go index da896c6b3e2..0510f078a28 100644 --- a/pkg/tools/benchmark/operator/service/operator_test.go +++ b/pkg/tools/benchmark/operator/service/operator_test.go @@ -520,7 +520,8 @@ func Test_operator_jobReconcile(t *testing.T) { } type fields struct { jobNamespace string - jobImage string + jobImageRepository string + jobImageTag string jobImagePullPolicy string scenarios *atomic.Pointer[map[string]*scenario] benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] @@ -556,7 +557,7 @@ func Test_operator_jobReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: &atomic.Pointer[map[string]*scenario]{}, benchjobs: &atomic.Pointer[map[string]*v1.ValdBenchmarkJob]{}, @@ -597,7 +598,7 @@ func Test_operator_jobReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: &atomic.Pointer[map[string]*scenario]{}, jobs: func() *atomic.Pointer[map[string]string] { @@ -694,7 +695,7 @@ func Test_operator_jobReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: &atomic.Pointer[map[string]*scenario]{}, jobs: func() *atomic.Pointer[map[string]string] { @@ -784,7 +785,7 @@ func Test_operator_jobReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: &atomic.Pointer[map[string]*scenario]{}, benchjobs: &atomic.Pointer[map[string]*v1.ValdBenchmarkJob]{}, @@ -823,7 +824,8 @@ func Test_operator_jobReconcile(t *testing.T) { } o := &operator{ jobNamespace: test.fields.jobNamespace, - jobImage: test.fields.jobImage, + jobImageRepository: test.fields.jobImageRepository, + jobImageTag: test.fields.jobImageTag, jobImagePullPolicy: test.fields.jobImagePullPolicy, benchjobs: test.fields.benchjobs, jobs: test.fields.jobs, @@ -847,7 +849,8 @@ func Test_operator_benchJobReconcile(t *testing.T) { } type fields struct { jobNamespace string - jobImage string + jobImageRepository string + jobImageTag string jobImagePullPolicy string scenarios *atomic.Pointer[map[string]*scenario] benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] @@ -887,7 +890,7 @@ func Test_operator_benchJobReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: &atomic.Pointer[map[string]*scenario]{}, benchjobs: &atomic.Pointer[map[string]*v1.ValdBenchmarkJob]{}, @@ -951,7 +954,7 @@ func Test_operator_benchJobReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: func() *atomic.Pointer[map[string]*scenario] { ap := atomic.Pointer[map[string]*scenario]{} @@ -1142,7 +1145,7 @@ func Test_operator_benchJobReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: func() *atomic.Pointer[map[string]*scenario] { ap := atomic.Pointer[map[string]*scenario]{} @@ -1376,7 +1379,7 @@ func Test_operator_benchJobReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: func() *atomic.Pointer[map[string]*scenario] { ap := atomic.Pointer[map[string]*scenario]{} @@ -1610,7 +1613,7 @@ func Test_operator_benchJobReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: func() *atomic.Pointer[map[string]*scenario] { ap := atomic.Pointer[map[string]*scenario]{} @@ -1852,7 +1855,8 @@ func Test_operator_benchJobReconcile(t *testing.T) { } o := &operator{ jobNamespace: test.fields.jobNamespace, - jobImage: test.fields.jobImage, + jobImageRepository: test.fields.jobImageRepository, + jobImageTag: test.fields.jobImageTag, jobImagePullPolicy: test.fields.jobImagePullPolicy, scenarios: test.fields.scenarios, benchjobs: test.fields.benchjobs, @@ -1878,7 +1882,8 @@ func Test_operator_benchScenarioReconcile(t *testing.T) { } type fields struct { jobNamespace string - jobImage string + jobImageRepository string + jobImageTag string jobImagePullPolicy string scenarios *atomic.Pointer[map[string]*scenario] benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] @@ -1935,7 +1940,7 @@ func Test_operator_benchScenarioReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: &atomic.Pointer[map[string]*scenario]{}, benchjobs: &atomic.Pointer[map[string]*v1.ValdBenchmarkJob]{}, @@ -2010,7 +2015,7 @@ func Test_operator_benchScenarioReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: &atomic.Pointer[map[string]*scenario]{}, benchjobs: &atomic.Pointer[map[string]*v1.ValdBenchmarkJob]{}, @@ -2146,7 +2151,7 @@ func Test_operator_benchScenarioReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: func() *atomic.Pointer[map[string]*scenario] { ap := atomic.Pointer[map[string]*scenario]{} @@ -2338,7 +2343,7 @@ func Test_operator_benchScenarioReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: func() *atomic.Pointer[map[string]*scenario] { ap := atomic.Pointer[map[string]*scenario]{} @@ -2530,7 +2535,7 @@ func Test_operator_benchScenarioReconcile(t *testing.T) { }, fields: fields{ jobNamespace: "default", - jobImage: "vdaas/vald-benchmark-job", + jobImageRepository: "vdaas/vald-benchmark-job", jobImagePullPolicy: "Always", scenarios: func() *atomic.Pointer[map[string]*scenario] { ap := atomic.Pointer[map[string]*scenario]{} @@ -2686,7 +2691,8 @@ func Test_operator_benchScenarioReconcile(t *testing.T) { } o := &operator{ jobNamespace: test.fields.jobNamespace, - jobImage: test.fields.jobImage, + jobImageRepository: test.fields.jobImageRepository, + jobImageTag: test.fields.jobImageTag, jobImagePullPolicy: test.fields.jobImagePullPolicy, scenarios: test.fields.scenarios, benchjobs: test.fields.benchjobs, @@ -3150,7 +3156,7 @@ func Test_operator_checkAtomics(t *testing.T) { // // want: func() Operator { // // o := &operator{ // // jobNamespace: "default", -// // jobImage: "vdaas/vald-benchmark-job", +// // jobImageRepository: "vdaas/vald-benchmark-job", // // jobImagePullPolicy: "Always", // // rcd: 10 * time.Second, // // } @@ -3255,7 +3261,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -3285,7 +3291,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -3324,7 +3330,7 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImage: test.fields.jobImage, +// jobImageRepository: test.fields.jobImage, // jobImagePullPolicy: test.fields.jobImagePullPolicy, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, @@ -3390,7 +3396,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -3420,7 +3426,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -3459,7 +3465,7 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImage: test.fields.jobImage, +// jobImageRepository: test.fields.jobImage, // jobImagePullPolicy: test.fields.jobImagePullPolicy, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, @@ -3513,7 +3519,7 @@ func Test_operator_checkAtomics(t *testing.T) { // // name: "test_case_1", // // fields: fields{ // // jobNamespace: "default", -// // jobImage: "vdaas/vald-benchmark-job", +// // jobImageRepository: "vdaas/vald-benchmark-job", // // jobImagePullPolicy: "Always", // // // scenarios:nil, // // // benchjobs:nil, @@ -3541,7 +3547,7 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_2", // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -3580,7 +3586,7 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImage: test.fields.jobImage, +// jobImageRepository: test.fields.jobImage, // jobImagePullPolicy: test.fields.jobImagePullPolicy, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, @@ -3645,7 +3651,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -3677,7 +3683,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -3716,7 +3722,7 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImage: test.fields.jobImage, +// jobImageRepository: test.fields.jobImage, // jobImagePullPolicy: test.fields.jobImagePullPolicy, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, @@ -3781,7 +3787,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -3813,7 +3819,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -3852,7 +3858,7 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImage: test.fields.jobImage, +// jobImageRepository: test.fields.jobImage, // jobImagePullPolicy: test.fields.jobImagePullPolicy, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, @@ -3919,7 +3925,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -3950,7 +3956,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -3989,7 +3995,7 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImage: test.fields.jobImage, +// jobImageRepository: test.fields.jobImage, // jobImagePullPolicy: test.fields.jobImagePullPolicy, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, @@ -4052,7 +4058,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -4083,7 +4089,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -4122,7 +4128,7 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImage: test.fields.jobImage, +// jobImageRepository: test.fields.jobImage, // jobImagePullPolicy: test.fields.jobImagePullPolicy, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, @@ -4189,7 +4195,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -4220,7 +4226,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -4259,7 +4265,7 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImage: test.fields.jobImage, +// jobImageRepository: test.fields.jobImage, // jobImagePullPolicy: test.fields.jobImagePullPolicy, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, @@ -4326,7 +4332,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -4357,7 +4363,7 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // fields: fields { // jobNamespace:"", -// jobImage:"", +// jobImageRepository:"", // jobImagePullPolicy:"", // scenarios:nil, // benchjobs:nil, @@ -4396,7 +4402,7 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImage: test.fields.jobImage, +// jobImageRepository: test.fields.jobImage, // jobImagePullPolicy: test.fields.jobImagePullPolicy, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, @@ -4458,7 +4464,7 @@ func Test_operator_checkAtomics(t *testing.T) { // // }, // // fields: fields{ // // jobNamespace: "", -// // jobImage: "", +// // jobImageRepository: "", // // jobImagePullPolicy: "", // // scenarios: nil, // // benchjobs: nil, @@ -4496,7 +4502,7 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImage: test.fields.jobImage, +// jobImageRepository: test.fields.jobImage, // jobImagePullPolicy: test.fields.jobImagePullPolicy, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, diff --git a/pkg/tools/benchmark/operator/service/option.go b/pkg/tools/benchmark/operator/service/option.go index 9cf06552ca4..f4645917614 100644 --- a/pkg/tools/benchmark/operator/service/option.go +++ b/pkg/tools/benchmark/operator/service/option.go @@ -28,7 +28,8 @@ import ( type Option func(o *operator) error var defaultOpts = []Option{ - WithJobImage("vdaas/vald-benchmark-job"), + WithJobImageRepository("vdaas/vald-benchmark-job"), + WithJobImageTag("latest"), WithJobImagePullPolicy("Always"), WithReconcileCheckDuration("10s"), WithJobNamespace("default"), @@ -68,11 +69,21 @@ func WithJobNamespace(ns string) Option { } } -// WithJobImage sets the benchmark job docker image info. -func WithJobImage(image string) Option { +// WithJobImageRepository sets the benchmark job docker image info. +func WithJobImageRepository(repo string) Option { return func(o *operator) error { - if image != "" { - o.jobImage = image + if repo != "" { + o.jobImageRepository = repo + } + return nil + } +} + +// WithJobImageTag sets the benchmark job docker image tag. +func WithJobImageTag(tag string) Option { + return func(o *operator) error { + if tag != "" { + o.jobImageTag = tag } return nil } diff --git a/pkg/tools/benchmark/operator/usecase/benchmarkd.go b/pkg/tools/benchmark/operator/usecase/benchmarkd.go index 5f4343f615d..59bb0b077bc 100644 --- a/pkg/tools/benchmark/operator/usecase/benchmarkd.go +++ b/pkg/tools/benchmark/operator/usecase/benchmarkd.go @@ -63,8 +63,9 @@ func New(cfg *config.Config) (r runner.Runner, err error) { operator, err := service.New( service.WithErrGroup(eg), service.WithJobNamespace(JOB_NAMESPACE), - service.WithJobImage(cfg.JobImage.Image), - service.WithJobImagePullPolicy(cfg.JobImage.PullPolicy), + service.WithJobImageRepository(cfg.Job.Image.Repository), + service.WithJobImageTag(cfg.Job.Image.Tag), + service.WithJobImagePullPolicy(cfg.Job.Image.PullPolicy), ) if err != nil { return nil, err @@ -98,7 +99,7 @@ func New(cfg *config.Config) (r runner.Runner, err error) { obs, err = observability.NewWithConfig( cfg.Observability, benchmarkmetrics.New(operator), - infometrics.New("benchmark_operator_info", "Benchmark Operator info", *cfg.JobImage), + infometrics.New("benchmark_operator_info", "Benchmark Operator info", *cfg.Job.Image), backoffmetrics.New(), ) if err != nil {