Skip to content

Commit

Permalink
Merge pull request #18 from stolostron/merge
Browse files Browse the repository at this point in the history
Merge from upstream
  • Loading branch information
clyang82 authored Dec 6, 2024
2 parents 38b17bb + 4a5a5a1 commit 428b846
Show file tree
Hide file tree
Showing 161 changed files with 10,093 additions and 2,061 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
make e2e-test
env:
container_tool: docker
SERVER_REPLICAS: 2
e2e-broadcast-subscription:
runs-on: ubuntu-latest
steps:
Expand All @@ -39,15 +40,29 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
# - name: Setup kind
# uses: engineerd/[email protected]
# with:
# version: v0.17.0
- name: install ginkgo
run: go install github.com/onsi/ginkgo/v2/[email protected]
- name: Test E2E
run: |
make e2e-test
env:
container_tool: docker
SERVER_REPLICAS: 2
ENABLE_BROADCAST_SUBSCRIPTION: true
e2e-grpc-broker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: install ginkgo
run: go install github.com/onsi/ginkgo/v2/[email protected]
- name: Test E2E
run: |
make e2e-test
env:
container_tool: docker
MESSAGE_DRIVER_TYPE: grpc
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ hack/mosquitto-passwd.txt
vendor/

# Ignore test data
_output
test/e2e/.kubeconfig
test/e2e/.consumer_id
test/e2e/.consumer_name
test/e2e/.external_host_ip
test/e2e/report/*
unit-test-results.json
integration-test-results.json
integration-test-results.json
test/e2e/setup/aro/aro-hcp
2 changes: 1 addition & 1 deletion .tekton/integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
dnf -y install jq git make
# Install golang with a given version
export GOVERSION=1.22.4
export GOVERSION=1.22.5
curl -O -J https://dl.google.com/go/go$GOVERSION.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go$GOVERSION.linux-amd64.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion .tekton/unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
dnf -y install jq git make
# Install golang with a given version
export GOVERSION=1.22.4
export GOVERSION=1.22.5
curl -O -J https://dl.google.com/go/go$GOVERSION.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go$GOVERSION.linux-amd64.tar.gz
Expand Down
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mqtt_password_file=${PWD}/secrets/mqtt.password
mqtt_config_file=${PWD}/secrets/mqtt.config

# Log verbosity level
glog_v:=10
klog_v:=10

# Location of the JSON web key set used to verify tokens:
jwks_url:=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/certs
Expand All @@ -76,10 +76,13 @@ CLIENT_SECRET ?= maestro
ENABLE_JWT ?= true
ENABLE_AUTHZ ?= true
ENABLE_OCM_MOCK ?= false
ENABLE_GRPC ?= false
ENABLE_GRPC_SERVER ?= false

# message driver type, mqtt or grpc, default is mqtt.
MESSAGE_DRIVER_TYPE ?= mqtt

# default replicas for maestro server
REPLICAS ?= 1
SERVER_REPLICAS ?= 1

# Enable set images
POSTGRES_IMAGE ?= docker.io/library/postgres:14.2
Expand Down Expand Up @@ -114,7 +117,7 @@ help:

# Encourage consistent tool versions
OPENAPI_GENERATOR_VERSION:=5.4.0
GO_VERSION:=go1.21.
GO_VERSION:=go1.22.

### Constants:
version:=$(shell date +%s)
Expand Down Expand Up @@ -266,8 +269,8 @@ cmds:
--local="true" \
--ignore-unknown-parameters="true" \
--param="ENVIRONMENT=$(OCM_ENV)" \
--param="GLOG_V=$(glog_v)" \
--param="REPLICAS=$(REPLICAS)" \
--param="KLOG_V=$(klog_v)" \
--param="SERVER_REPLICAS=$(SERVER_REPLICAS)" \
--param="DATABASE_HOST=$(db_host)" \
--param="DATABASE_NAME=$(db_name)" \
--param="DATABASE_PASSWORD=$(db_password)" \
Expand Down Expand Up @@ -303,7 +306,8 @@ cmds:
--param="EXTERNAL_APPS_DOMAIN=${external_apps_domain}" \
--param="CONSUMER_NAME=$(consumer_name)" \
--param="ENABLE_OCM_MOCK=$(ENABLE_OCM_MOCK)" \
--param="ENABLE_GRPC=$(ENABLE_GRPC)" \
--param="ENABLE_GRPC_SERVER=$(ENABLE_GRPC_SERVER)" \
--param="MESSAGE_DRIVER_TYPE"=$(MESSAGE_DRIVER_TYPE) \
> "templates/$*-template.json"


Expand Down Expand Up @@ -413,10 +417,12 @@ e2e-test/teardown:
.PHONY: e2e-test/teardown

e2e-test: e2e-test/teardown e2e-test/setup
ginkgo --output-dir="${PWD}/test/e2e/report" --json-report=report.json --junit-report=report.xml \
ginkgo -v --fail-fast --label-filter="!(e2e-tests-spec-resync-reconnect||e2e-tests-status-resync-reconnect)" \
--output-dir="${PWD}/test/e2e/report" --json-report=report.json --junit-report=report.xml \
${PWD}/test/e2e/pkg -- \
-api-server=https://$(shell cat ${PWD}/test/e2e/.external_host_ip):30080 \
-grpc-server=$(shell cat ${PWD}/test/e2e/.external_host_ip):30090 \
-server-kubeconfig=${PWD}/test/e2e/.kubeconfig \
-consumer-name=$(shell cat ${PWD}/test/e2e/.consumer_name) \
-consumer-kubeconfig=${PWD}/test/e2e/.kubeconfig
-agent-kubeconfig=${PWD}/test/e2e/.kubeconfig
.PHONY: e2e-test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ $ oc -n maestro port-forward svc/maestro-grpc 8090 &
3. Create a resource bundle with multiple resources using the gRPC client, for example:

```shell
go run ./examples/grpcclient.go -cloudevents_json_file ./examples/cloudevent-bundle.json -grpc_server localhost:8090
go run ./examples/grpc/grpcclient.go -cloudevents_json_file ./examples/grpc/cloudevent-bundle.json -grpc_server localhost:8090
```

4. Get the resource bundle with multiple resources, for example:
Expand Down
28 changes: 13 additions & 15 deletions cmd/maestro/agent/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@ package agent

import (
"context"
"flag"
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
utilflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/metrics/legacyregistry"
"k8s.io/component-base/version"
"k8s.io/klog/v2"
ocmfeature "open-cluster-management.io/api/feature"
commonoptions "open-cluster-management.io/ocm/pkg/common/options"
"open-cluster-management.io/ocm/pkg/features"
"open-cluster-management.io/ocm/pkg/work/spoke"
"open-cluster-management.io/sdk-go/pkg/cloudevents/generic"
)

var (
commonOptions = commonoptions.NewAgentOptions()
agentOption = spoke.NewWorkloadAgentOptions()
)

func init() {
// register the cloud events metrics for the agent
generic.RegisterCloudEventsMetrics(legacyregistry.Registerer())
}

// by default uses 1M as the limit for state feedback
const maxJSONRawLength int32 = 1024 * 1024

Expand All @@ -38,17 +42,8 @@ func NewAgentCommand() *cobra.Command {
cmd.Short = "Start the Maestro Agent"
cmd.Long = "Start the Maestro Agent"

// check if the flag is already registered to avoid duplicate flag define error
if flag.CommandLine.Lookup("alsologtostderr") != nil {
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
}

// add klog flags
klog.InitFlags(nil)

flags := cmd.Flags()
flags := cmd.PersistentFlags()
flags.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
flags.AddGoFlagSet(flag.CommandLine)

// add common flags
// commonOptions.AddFlags(flags)
Expand All @@ -58,8 +53,11 @@ func NewAgentCommand() *cobra.Command {
// add alias flags
addFlags(flags)

utilruntime.Must(features.SpokeMutableFeatureGate.Add(ocmfeature.DefaultSpokeWorkFeatureGates))
utilruntime.Must(features.SpokeMutableFeatureGate.Set(fmt.Sprintf("%s=true", ocmfeature.RawFeedbackJsonString)))
// add pre-run to set feature gates
cmd.PreRun = func(cmd *cobra.Command, args []string) {
utilruntime.Must(features.SpokeMutableFeatureGate.Add(ocmfeature.DefaultSpokeWorkFeatureGates))
utilruntime.Must(features.SpokeMutableFeatureGate.Set(fmt.Sprintf("%s=true", ocmfeature.RawFeedbackJsonString)))
}

return cmd
}
Expand Down
Loading

0 comments on commit 428b846

Please sign in to comment.