Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add manifest bundle support #59

Merged
merged 6 commits into from
Mar 20, 2024

Conversation

morvencao
Copy link
Contributor

@morvencao
Copy link
Contributor Author

test results:

# make test-integration
CGO_ENABLED=1 GOEXPERIMENT=boringcrypto go install -ldflags="" ./cmd/maestro
OCM_ENV=testing gotestsum --format short-verbose -- -p 1 -ldflags -s -v -timeout 1h  \
		./test/integration
I0307 09:30:50.606715  386039 framework.go:76] Initializing testing environment
I0307 09:30:50.887469  386039 framework.go:161] Using Mock OCM Authz Client
I0307 09:30:50.890513  386039 framework.go:199] Disabling Sentry error reporting
I0307 09:30:50.898980  386039 grpc_server.go:74] Serving gRPC service without TLS at 8090
I0307 09:30:50.899286  386039 api_server.go:151] Serving without TLS at 8000
PASS test/integration.TestConsumerGet (5.06s)
PASS test/integration.TestConsumerPost (0.23s)
PASS test/integration.TestConsumerPaging (0.35s)
PASS test/integration.TestControllerRacing (1.76s)
PASS test/integration.TestControllerReconcile (1.38s)
PASS test/integration.TestControllerSync (1.30s)
PASS test/integration.TestPulseServer (5.31s)
PASS test/integration.TestResourceGet (0.19s)
PASS test/integration.TestResourcePost (5.20s)
PASS test/integration.TestResourcePatch (0.35s)
PASS test/integration.TestResourcePaging (0.39s)
PASS test/integration.TestResourceListSearch (0.26s)
PASS test/integration.TestUpdateResourceWithRacingRequests (2.29s)
PASS test/integration.TestResourceFromGRPC (2.28s)
E0307 09:31:17.272039  386039 logger.go:129]   Unable to get all maestro instances: pq: relation "server_instances" does not exist
E0307 09:31:17.273825  386039 logger.go:129]   Unable to get all maestro instances: pq: relation "server_instances" does not exist
E0307 09:31:17.275218  386039 logger.go:129]   Unable to get all maestro instances: pq: relation "server_instances" does not exist
E0307 09:31:17.276482  386039 logger.go:129]   Unable to get all maestro instances: pq: relation "server_instances" does not exist
PASS test/integration

DONE 14 tests in 30.024s

@morvencao morvencao force-pushed the br_bundle_support branch 2 times, most recently from d43380b to 5331ebc Compare March 7, 2024 10:02
},
},

for _, obj := range objs {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check/filter event type matching?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean single or bundle match?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you can get the event data type from the resync request event, then you can only response the type matched, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank! done.

resourceVersionInt := int64(0)
resourceVersion, err := cloudeventstypes.ToString(evtExtensions[cetypes.ExtensionResourceVersion])
if err != nil {
resourceVersionIntVal, err := cloudeventstypes.ToInteger(evtExtensions[cetypes.ExtensionResourceVersion])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only use ToInteger?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, we now ensure the resource version is integer.
Updated all the occurrences.

@skeeey
Copy link
Contributor

skeeey commented Mar 8, 2024

And cloud you also append the e2e test result?

@morvencao
Copy link
Contributor Author

e2e test results:

# make e2e-test
ginkgo --output-dir="/home/oasis/workspace/openshift-online-maestro/test/e2e/report" --json-report=report.json --junit-report=report.xml \
/home/oasis/workspace/openshift-online-maestro/test/e2e/pkg -- -consumer_id="34617c63-5f52-4ae0-8428-35daf6b9a45f" \
-api-server=https://127.0.0.1:30080 -kubeconfig=/home/oasis/workspace/openshift-online-maestro/test/e2e/.kubeconfig
Ginkgo detected a version mismatch between the Ginkgo CLI and the version of Ginkgo imported by your packages:
  Ginkgo CLI Version:
    2.6.0
  Mismatched package versions found:
    2.13.2 used by pkg

  Ginkgo will continue to attempt to run but you may see errors (including flag
  parsing errors) and should either update your go.mod or your version of the
  Ginkgo CLI to match.

  To install the matching version of the CLI run
    go install github.com/onsi/ginkgo/v2/ginkgo
  from a path that contains a go.mod file.  Alternatively you can use
    go run github.com/onsi/ginkgo/v2/ginkgo
  from a path that contains a go.mod file to invoke the matching version of the
  Ginkgo CLI.

  If you are attempting to test multiple packages that each have a different
  version of the Ginkgo library with a single Ginkgo CLI that is currently
  unsupported.

Running Suite: End-to-End Test Suite - /home/oasis/workspace/openshift-online-maestro/test/e2e/pkg
============================================================================================
Random Seed: 1709873066

Will run 5 of 5 specs
•••••

Ran 5 of 5 Specs in 4.149 seconds
SUCCESS! -- 5 Passed | 0 Failed | 0 Pending | 0 Skipped
PASS

Ginkgo ran 1 suite in 8.021418251s
Test Suite Passed

@morvencao morvencao force-pushed the br_bundle_support branch 2 times, most recently from 63012f9 to 949dbc6 Compare March 14, 2024 13:23
@morvencao
Copy link
Contributor Author

/assign @qiujian16 @clyang82


// DecodeStatus converts a CloudEvent JSONMap representation of a resource status
// into resource status (map[string]interface{}).
func DecodeStatus(status datatypes.JSONMap) (map[string]interface{}, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So when we store in DB, we store a cloudEvent structure right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we now store spec and status in cloudevent format in DB now. This function is used to decode cloudevent status to resource status in openapi format to restful client.

@@ -13,6 +13,7 @@ func addResources() *gormigrate.Migration {
Source string `gorm:"index"`
ConsumerID string `gorm:"index"`
Version int `gorm:"not null"`
Type string `gorm:"index"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add some comments here? It is not clear to me what data structure is stored in DB.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comments.

@morvencao
Copy link
Contributor Author

@qiujian16 An example of resource status in DB:

# select jsonb_pretty(resources.status) from resources;
                              jsonb_pretty
--------------------------------------------------------------------
  {
      "id": "0fd2b15f-e4d5-4ecb-a5fb-455284d27e2b",
      "data": {
          "status": {
              "conditions": [
                  {
                      "type": "Applied",
                      "reason": "AppliedManifestComplete",
                      "status": "True",
                      "message": "Apply manifest complete",
                      "lastTransitionTime": "2024-03-18T12:57:58Z"
                  },
                  {
                      "type": "Available",
                      "reason": "ResourceAvailable",
                      "status": "True",
                      "message": "Resource is available",
                      "lastTransitionTime": "2024-03-18T12:57:58Z"
                  },
                  {
                      "type": "StatusFeedbackSynced",
                      "reason": "StatusFeedbackSynced",
                      "status": "True",
                      "message": "",
                      "lastTransitionTime": "2024-03-18T12:57:58Z"
                  }
              ],
              "resourceMeta": {
                  "kind": "Deployment",
                  "name": "nginx1",
                  "group": "apps",
                  "ordinal": 0,
                  "version": "v1",
                  "resource": "deployments",
                  "namespace": "default"
              },
              "statusFeedback": {
                  "values": [
                      {
                          "name": "status",
                          "fieldValue": {
                              "type": "JsonRaw",
                              "jsonRaw": "{\"availableReplicas\":1,\"conditions\":[{\"lastTransitionTime\":\"2024-03-18T12:58:04Z\",\"lastUpdateTime\":\"2024-03-18T12:58:04Z\",\"m
  essage\":\"Deployment has minimum availability.\",\"reason\":\"MinimumReplicasAvailable\",\"status\":\"True\",\"type\":\"Available\"},{\"lastTransitionTime\":\"2024-03-18T12:57:58Z\",\"lastUpdateTime\":\"2024-03-18T12:58:04Z\",\"message\":\"ReplicaSet \\\"nginx1-5d6b548959\\\" has successfully progressed.\",\"reason\":\"NewReplicaSetAvailable\",\"status\
  ":\"True\",\"type\":\"Progressing\"}],\"observedGeneration\":1,\"readyReplicas\":1,\"replicas\":1,\"updatedReplicas\":1}"
                          }
                      }
                  ]
              }
          },
          "conditions": [
              {
                  "type": "Applied",
                  "reason": "AppliedManifestWorkComplete",
                  "status": "True",
                  "message": "Apply manifest work complete",
                  "lastTransitionTime": "2024-03-18T12:57:58Z"
              },
              {
                  "type": "Available",
                  "reason": "ResourcesAvailable",
                  "status": "True",
                  "message": "All resources are available",
                  "lastTransitionTime": "2024-03-18T12:57:58Z"
              }
          ]
      },
      "time": "2024-03-18T12:58:11.020848168Z",
      "type": "io.open-cluster-management.works.v1alpha1.manifests.status.update_request",
      "source": "b288a9da-8bfe-4c82-94cc-2b48e773fc46-work-agent",
      "resourceid": "dc970bd3-da6d-4a63-992b-dc0ae0419a7c",
      "sequenceid": "1769709885668200448",
      "clustername": "b288a9da-8bfe-4c82-94cc-2b48e773fc46",
      "specversion": "1.0",
      "originalsource": "maestro",
      "datacontenttype": "application/json",
      "resourceversion": "1"
  }
(1 row)

Signed-off-by: morvencao <lcao@redhat.com>
Signed-off-by: morvencao <lcao@redhat.com>
Signed-off-by: morvencao <lcao@redhat.com>
Signed-off-by: morvencao <lcao@redhat.com>
Signed-off-by: morvencao <lcao@redhat.com>
Signed-off-by: morvencao <lcao@redhat.com>
Copy link
Contributor

@clyang82 clyang82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@clyang82 clyang82 merged commit 95c5468 into openshift-online:main Mar 20, 2024
1 check was pending
@morvencao morvencao deleted the br_bundle_support branch March 20, 2024 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants