Skip to content

Commit

Permalink
rebase code.
Browse files Browse the repository at this point in the history
Signed-off-by: morvencao <[email protected]>
  • Loading branch information
morvencao committed Feb 17, 2025
1 parent fc1e5ca commit 6fbeb6b
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cmd/maestro/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func main() {
// if the log level is 1, it will log everything including debug logs;
// if the log level is 2 or higher, it will log everything including klog verbose logs.
zc.Level = zap.NewAtomicLevelAt(zapcore.Level(0 - logLevel))
// Disable stacktrace for production environment
// Disable stacktrace to reduce logs size
zc.DisableStacktrace = true
zapLog, err := zc.Build()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ require (
k8s.io/klog/v2 v2.130.1
open-cluster-management.io/api v0.15.1-0.20241210025410-0ba6809d0ae2
open-cluster-management.io/ocm v0.15.1-0.20250108154653-2397c4e91119
open-cluster-management.io/sdk-go v0.15.1-0.20250212140629-c9cbca9e52cb
open-cluster-management.io/sdk-go v0.15.1-0.20250217031345-04acb74ee5ae
sigs.k8s.io/yaml v1.4.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,8 @@ open-cluster-management.io/api v0.15.1-0.20241210025410-0ba6809d0ae2 h1:zkp3VJnv
open-cluster-management.io/api v0.15.1-0.20241210025410-0ba6809d0ae2/go.mod h1:9erZEWEn4bEqh0nIX2wA7f/s3KCuFycQdBrPrRzi0QM=
open-cluster-management.io/ocm v0.15.1-0.20250108154653-2397c4e91119 h1:Ftx7vxDumTB9d4+ZdcqYwQavTOVzgF5h6vAXJ/gh0IE=
open-cluster-management.io/ocm v0.15.1-0.20250108154653-2397c4e91119/go.mod h1:T9pfSm3EYHnysEP9JYfCojV2pI44IYMz3zaZNylulz8=
open-cluster-management.io/sdk-go v0.15.1-0.20250212140629-c9cbca9e52cb h1:w8ZV4DTTyIeRPR9OIgdNGLtC4YGmfSaq9lZeiJd7qZI=
open-cluster-management.io/sdk-go v0.15.1-0.20250212140629-c9cbca9e52cb/go.mod h1:fi5WBsbC5K3txKb8eRLuP0Sim/Oqz/PHX18skAEyjiA=
open-cluster-management.io/sdk-go v0.15.1-0.20250217031345-04acb74ee5ae h1:jxNiZbTXMFbdLUIFiowpSCSegXPWfGML0jlaEBCnq5o=
open-cluster-management.io/sdk-go v0.15.1-0.20250217031345-04acb74ee5ae/go.mod h1:fi5WBsbC5K3txKb8eRLuP0Sim/Oqz/PHX18skAEyjiA=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 h1:2770sDpzrjjsAtVhSeUFseziht227YAWYHLGNM8QPwY=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
sigs.k8s.io/controller-runtime v0.19.3 h1:XO2GvC9OPftRst6xWCpTgBZO04S2cbp0Qqkj8bX1sPw=
Expand Down
2 changes: 1 addition & 1 deletion templates/agent-template-aro-hcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ parameters:
- name: KLOG_V
displayName: KLOG V Level
description: Log verbosity level
value: "3"
value: "4"

objects:
- apiVersion: apiextensions.k8s.io/v1
Expand Down
14 changes: 11 additions & 3 deletions templates/agent-template-rosa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ labels:
template: maestro-agent
parameters:

- name: ENVIRONMENT
displayName: Environment
description: Which maestro environment to use for this deployment
value: production

- name: AGENT_NAMESPACE
description: namespace of maestro agent

Expand All @@ -33,14 +38,14 @@ parameters:
displayName: Image tag
value: latest

- name: MQTT_HOST
description: Hostname for the mqtt broker

- name: KLOG_V
displayName: KLOG V Level
description: Log verbosity level
value: "4"

- name: MQTT_HOST
description: Hostname for the mqtt broker.

objects:
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -273,6 +278,9 @@ objects:
- name: maestro-agent
image: ${IMAGE_REGISTRY}/${IMAGE_REPOSITORY}:${IMAGE_TAG}
imagePullPolicy: IfNotPresent
env:
- name: "MAESTRO_ENV"
value: "${ENVIRONMENT}"
command:
- /usr/local/bin/maestro
- agent
Expand Down
2 changes: 1 addition & 1 deletion templates/agent-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ parameters:
- name: KLOG_V
displayName: KLOG V Level
description: Log verbosity level
value: "3"
value: "4"

- name: MESSAGE_DRIVER_TYPE
displayName: Message Driver Type
Expand Down
14 changes: 14 additions & 0 deletions templates/agent-tls-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ labels:
template: maestro-agent
parameters:

- name: ENVIRONMENT
displayName: Environment
description: Which maestro environment to use for this deployment
value: production

- name: AGENT_NAMESPACE
description: namespace of maestro agent

Expand All @@ -33,6 +38,11 @@ parameters:
displayName: Image tag
value: latest

- name: KLOG_V
displayName: KLOG V Level
description: Log verbosity level
value: "4"

- name: MESSAGE_DRIVER_TYPE
displayName: Message Driver Type
description: Message driver type, mqtt or grpc.
Expand Down Expand Up @@ -290,6 +300,9 @@ objects:
- name: maestro-agent
image: ${IMAGE_REGISTRY}/${IMAGE_REPOSITORY}:${IMAGE_TAG}
imagePullPolicy: IfNotPresent
env:
- name: "MAESTRO_ENV"
value: "${ENVIRONMENT}"
command:
- /usr/local/bin/maestro
- agent
Expand All @@ -298,6 +311,7 @@ objects:
- --workload-source-config=/secrets/${MESSAGE_DRIVER_TYPE}/config.yaml
- --cloudevents-client-id=${CONSUMER_NAME}-work-agent
- --appliedmanifestwork-eviction-grace-period=30s
- -v=${KLOG_V}
volumeMounts:
- name: ${MESSAGE_DRIVER_TYPE}
mountPath: /secrets/${MESSAGE_DRIVER_TYPE}
Expand Down
2 changes: 1 addition & 1 deletion templates/service-template-aro-hcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ parameters:
- name: KLOG_V
displayName: KLOG V Level
description: Log verbosity level
value: "3"
value: "4"

- name: MEMORY_REQUEST
description: Memory request for the API pods.
Expand Down
4 changes: 2 additions & 2 deletions templates/service-template-rosa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ parameters:

- name: ENVIRONMENT
displayName: Environment
description: Which Account Manager environment to use for this deployment
description: Which maestro environment to use for this deployment
value: production

- name: IMAGE_REGISTRY
Expand Down Expand Up @@ -213,7 +213,7 @@ objects:
mountPath: /secrets/mqtt-creds
readOnly: true
env:
- name: "AMS_ENV"
- name: "MAESTRO_ENV"
value: "${ENVIRONMENT}"
- name: POD_NAME
valueFrom:
Expand Down
4 changes: 2 additions & 2 deletions templates/service-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ parameters:
- name: KLOG_V
displayName: KLOG V Level
description: Log verbosity level
value: "3"
value: "4"

- name: MEMORY_REQUEST
description: Memory request for the API pods.
Expand Down Expand Up @@ -415,7 +415,7 @@ objects:
app: maestro
port: api
annotations:
description: Exposes and load balances the account manager pods
description: Exposes and load balances the maestro pods
service.alpha.openshift.io/serving-cert-secret-name: maestro-tls
spec:
selector:
Expand Down
8 changes: 4 additions & 4 deletions templates/service-tls-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ parameters:

- name: ENVIRONMENT
displayName: Environment
description: Which Account Manager environment to use for this deployment
description: Which maestro environment to use for this deployment
value: production

- name: IMAGE_REGISTRY
Expand All @@ -34,7 +34,7 @@ parameters:
- name: KLOG_V
displayName: KLOG V Level
description: Log verbosity level
value: "10"
value: "4"

- name: MEMORY_REQUEST
description: Memory request for the API pods.
Expand Down Expand Up @@ -366,7 +366,7 @@ objects:
- name: maestro-grpc-cert
mountPath: /secrets/maestro-grpc-cert
env:
- name: "AMS_ENV"
- name: "MAESTRO_ENV"
value: "${ENVIRONMENT}"
- name: POD_NAME
valueFrom:
Expand Down Expand Up @@ -460,7 +460,7 @@ objects:
app: maestro
port: api
annotations:
description: Exposes and load balances the account manager pods
description: Exposes and load balances the maestro pods
service.alpha.openshift.io/serving-cert-secret-name: maestro-tls
spec:
selector:
Expand Down
21 changes: 21 additions & 0 deletions test/integration/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,30 @@ func TestResourcePost(t *testing.T) {
families := getServerMetrics(t, "http://localhost:8080/metrics")
labels := []*prommodel.LabelPair{
{Name: strPtr("source"), Value: strPtr("maestro")},
{Name: strPtr("original_source"), Value: strPtr("none")},
{Name: strPtr("cluster"), Value: strPtr(clusterName)},
{Name: strPtr("type"), Value: strPtr("io.open-cluster-management.works.v1alpha1.manifestbundles")},
{Name: strPtr("subresource"), Value: strPtr(string(types.SubResourceSpec))},
{Name: strPtr("action"), Value: strPtr("create_request")},
}
checkServerCounterMetric(t, families, "cloudevents_sent_total", labels, 1.0)
labels = []*prommodel.LabelPair{
{Name: strPtr("source"), Value: strPtr("maestro")},
{Name: strPtr("cluster"), Value: strPtr(clusterName)},
{Name: strPtr("type"), Value: strPtr("io.open-cluster-management.works.v1alpha1.manifestbundles")},
{Name: strPtr("subresource"), Value: strPtr(string(types.SubResourceSpec))},
{Name: strPtr("action"), Value: strPtr("create_request")},
}
checkServerCounterMetric(t, families, "cloudevents_received_total", labels, 1.0)
labels = []*prommodel.LabelPair{
{Name: strPtr("source"), Value: strPtr(clusterName)},
{Name: strPtr("original_source"), Value: strPtr("maestro")},
{Name: strPtr("cluster"), Value: strPtr(clusterName)},
{Name: strPtr("type"), Value: strPtr("io.open-cluster-management.works.v1alpha1.manifestbundles")},
{Name: strPtr("subresource"), Value: strPtr(string(types.SubResourceStatus))},
{Name: strPtr("action"), Value: strPtr("update_request")},
}
checkServerCounterMetric(t, families, "cloudevents_sent_total", labels, 1.0)
labels = []*prommodel.LabelPair{
{Name: strPtr("source"), Value: strPtr(clusterName)},
{Name: strPtr("cluster"), Value: strPtr(clusterName)},
Expand Down Expand Up @@ -824,6 +842,7 @@ func TestResourceFromGRPC(t *testing.T) {
if h.Broker != "grpc" {
labels = []*prommodel.LabelPair{
{Name: strPtr("source"), Value: strPtr("maestro")},
{Name: strPtr("original_source"), Value: strPtr("none")},
{Name: strPtr("cluster"), Value: strPtr(clusterName)},
{Name: strPtr("type"), Value: strPtr("io.open-cluster-management.works.v1alpha1.manifestbundles")},
{Name: strPtr("subresource"), Value: strPtr(string(types.SubResourceSpec))},
Expand All @@ -832,6 +851,7 @@ func TestResourceFromGRPC(t *testing.T) {
checkServerCounterMetric(t, families, "cloudevents_sent_total", labels, 2.0)
labels = []*prommodel.LabelPair{
{Name: strPtr("source"), Value: strPtr("maestro")},
{Name: strPtr("original_source"), Value: strPtr("none")},
{Name: strPtr("cluster"), Value: strPtr(clusterName)},
{Name: strPtr("type"), Value: strPtr("io.open-cluster-management.works.v1alpha1.manifestbundles")},
{Name: strPtr("subresource"), Value: strPtr(string(types.SubResourceSpec))},
Expand All @@ -840,6 +860,7 @@ func TestResourceFromGRPC(t *testing.T) {
checkServerCounterMetric(t, families, "cloudevents_sent_total", labels, 2.0)
labels = []*prommodel.LabelPair{
{Name: strPtr("source"), Value: strPtr("maestro")},
{Name: strPtr("original_source"), Value: strPtr("none")},
{Name: strPtr("cluster"), Value: strPtr(clusterName)},
{Name: strPtr("type"), Value: strPtr("io.open-cluster-management.works.v1alpha1.manifestbundles")},
{Name: strPtr("subresource"), Value: strPtr(string(types.SubResourceSpec))},
Expand Down
2 changes: 2 additions & 0 deletions test/integration/status_dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func TestStatusDispatcher(t *testing.T) {
families := getServerMetrics(t, "http://localhost:8080/metrics")
labels := []*prommodel.LabelPair{
{Name: strPtr("source"), Value: strPtr("maestro")},
{Name: strPtr("original_source"), Value: strPtr("none")},
{Name: strPtr("cluster"), Value: strPtr(consumer1)},
{Name: strPtr("type"), Value: strPtr("io.open-cluster-management.works.v1alpha1.manifestbundles")},
{Name: strPtr("subresource"), Value: strPtr(string(types.SubResourceStatus))},
Expand All @@ -75,6 +76,7 @@ func TestStatusDispatcher(t *testing.T) {
checkServerCounterMetric(t, families, "cloudevents_sent_total", labels, 1.0)
labels = []*prommodel.LabelPair{
{Name: strPtr("source"), Value: strPtr("maestro")},
{Name: strPtr("original_source"), Value: strPtr("none")},
{Name: strPtr("cluster"), Value: strPtr(consumer2)},
{Name: strPtr("type"), Value: strPtr("io.open-cluster-management.works.v1alpha1.manifestbundles")},
{Name: strPtr("subresource"), Value: strPtr(string(types.SubResourceStatus))},
Expand Down

0 comments on commit 6fbeb6b

Please sign in to comment.