stolostron / multicluster-global-hub

the main repository for the multicluster global hub
Apache License 2.0
21 stars 32 forks source link

:sparkles: Switch zap log for global hub agent #1184

Closed yanmxa closed 1 month ago

yanmxa commented 1 month ago

Summary

Related issue(s)

Fixes # https://github.com/stolostron/multicluster-global-hub/issues/1178, https://issues.redhat.com/browse/ACM-13421

  1. Configure the LogLevel at runtime!
  2. Integrate the log format with the third part library - cloudevents, and controller-runtime
  3. The underlayer is based on Zap Logger and SugarLogger, we also provide the zapr if you use the logr interface.
  4. The manifestwork only updates the configmap, the agent deployment will not be updated. Let the operator read the config and propagate it to the configmap in the manifest
  5. Format
    
    2024-10-29T03:43:41.290Z        INFO    utils/utils.go:28       Go OS/Arch: linux/amd64
    2024-10-29T03:43:41.290Z        INFO    utils/utils.go:29       Go Version: go1.22.5
    2024-10-29T03:43:41.290Z        INFO    utils/utils.go:30       Git Commit: b46e471c
    2024-10-29T03:43:41.313Z        INFO    controller-runtime.metrics      server/server.go:208    Starting metrics server
    I1029 03:43:41.313460       1 leaderelection.go:254] attempting to acquire leader lease multicluster-global-hub-agent/multicluster-global-hub-agent-lock...
    2024-10-29T03:43:41.313Z        INFO    controller-runtime.metrics      server/server.go:247    Serving metrics server  {"bindAddress": "0.0.0.0:8384", "secure": false}
    I1029 03:43:41.317722       1 leaderelection.go:268] successfully acquired lease multicluster-global-hub-agent/multicluster-global-hub-agent-lock
    2024-10-29T03:43:41.318Z        INFO    controller/controller.go:175    Starting EventSource    {"controller": "secret", "controllerGroup": "", "controllerKind": "Secret", "source": "kind source: *v1.Secret"}
    2024-10-29T03:43:41.318Z        INFO    controller/controller.go:183    Starting Controller     {"controller": "secret", "controllerGroup": "", "controllerKind": "Secret"}
    2024-10-29T03:43:41.521Z        INFO    controller/controller.go:217    Starting workers        {"controller": "secret", "controllerGroup": "", "controllerKind": "Secret", "worker count": 1}
    2024-10-29T03:43:41.521Z        INFO    kafka-consumer  consumer/generic_consumer.go:84 transport consumer with cloudevents-kafka receiver
    2024-10-29T03:43:41.525Z        INFO    cloudevents     v2@v2.0.0-20240911135016-682f3a9684e4/protocol.go:166   Subscribing to topics: [gh-spec]
    2024-10-29T03:43:41.526Z        INFO    cmd/main.go:240 add the init controller to manager


We can see the cloudevents, controller runtime is the same as the format we set. But the lease still uses the klog, which we won't update in this PR. Visit here for more detail about that: https://github.com/kubernetes-sigs/controller-runtime/issues/2656, https://github.com/kubernetes/enhancements/issues/3077
## Tests
* [ ] Unit/function tests have been added and incorporated into `make unit-tests`.
* [ ] Integration tests have been added and incorporated into `make integration-test`.
* [ ] E2E tests have been added and incorporated into `make e2e-test-all`.
* [x] List other manual tests you have done.
yanmxa commented 1 month ago

the environment isn't ready, re run it

/test e2e-test

openshift-ci[bot] commented 1 month ago

@yanmxa: The specified target(s) for /test were not found. The following commands are available to trigger required jobs:

Use /test all to run all jobs.

In response to [this](https://github.com/stolostron/multicluster-global-hub/pull/1184#issuecomment-2441087342): >the environment isn't ready, re run it > >/test e2e-test Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
yanmxa commented 1 month ago

/test test-e2e

yanmxa commented 1 month ago

/override ci/prow/sonarcloud

openshift-ci[bot] commented 1 month ago

@yanmxa: Overrode contexts on behalf of yanmxa: ci/prow/sonarcloud

In response to [this](https://github.com/stolostron/multicluster-global-hub/pull/1184#issuecomment-2441785560): >/override ci/prow/sonarcloud Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
yanmxa commented 1 month ago

setup error

/test test-e2e

yanmxa commented 1 month ago

database isn't ready

/test test-e2e

yanmxa commented 1 month ago

the kafka cluster is not created

/test test-e2e

sonarcloud[bot] commented 1 month ago

Quality Gate Failed Quality Gate failed

Failed conditions
61.8% Coverage on New Code (required ≥ 70%)

See analysis details on SonarCloud

yanmxa commented 1 month ago

/override ci/prow/sonarcloud

openshift-ci[bot] commented 1 month ago

@yanmxa: Overrode contexts on behalf of yanmxa: ci/prow/sonarcloud

In response to [this](https://github.com/stolostron/multicluster-global-hub/pull/1184#issuecomment-2443139957): >/override ci/prow/sonarcloud Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
yanmxa commented 1 month ago

/cc @clyang82 @ldpliu

yanmxa commented 1 month ago

Need to have a document about how to change the log level in the runtime environment

Add the document in this pr: https://github.com/stolostron/multicluster-global-hub/pull/1188

clyang82 commented 1 month ago

/lgtm

openshift-ci[bot] commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clyang82, yanmxa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/stolostron/multicluster-global-hub/blob/main/OWNERS)~~ [clyang82,yanmxa] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment