Skip to content

Commit

Permalink
Log only log with level panic and above for TA (#1046)
Browse files Browse the repository at this point in the history
[comment]: # (Note that your PR title should follow the conventional
commit format: https://conventionalcommits.org/en/v1.0.0/#summary)
# PR Description
I will make the changes in upstream in the zap library to include panic
level. Currently it only includes highest criticality of error -
https://github.com/kubernetes-sigs/controller-runtime/blob/1ec7c1b76e98efd4f177eb8cd96050596b0fa3d3/pkg/log/zap/flags.go#L31C1-L35C2
After this change we can just provide container arg to specify panic

[comment]: # (The below checklist is for PRs adding new features. If a
box is not checked, add a reason why it's not needed.)
# New Feature Checklist

- [ ] List telemetry added about the feature.
- [ ] Link to the one-pager about the feature.
- [ ] List any tasks necessary for release (3P docs, AKS RP chart
changes, etc.) after merging the PR.
- [ ] Attach results of scale and perf testing.

[comment]: # (The below checklist is for code changes. Not all boxes
necessarily need to be checked. Build, doc, and template changes do not
need to fill out the checklist.)
# Tests Checklist

- [ ] Have end-to-end Ginkgo tests been run on your cluster and passed?
To bootstrap your cluster to run the tests, follow [these
instructions](/otelcollector/test/README.md#bootstrap-a-dev-cluster-to-run-ginkgo-tests).
  - Labels used when running the tests on your cluster:
    - [ ] `operator`
    - [ ] `windows`
    - [ ] `arm64`
    - [ ] `arc-extension`
    - [ ] `fips`
- [ ] Have new tests been added? For features, have tests been added for
this feature? For fixes, is there a test that could have caught this
issue and could validate that the fix works?
  - [ ] Is a new scrape job needed?
- [ ] The scrape job was added to the folder
[test-cluster-yamls](/otelcollector/test/test-cluster-yamls/) in the
correct configmap or as a CR.
  - [ ] Was a new test label added?
- [ ] A string constant for the label was added to
[constants.go](/otelcollector/test/utils/constants.go).
- [ ] The label and description was added to the [test
README](/otelcollector/test/README.md).
- [ ] The label was added to this [PR
checklist](/.github/pull_request_template).
- [ ] The label was added as needed to
[testkube-test-crs.yaml](/otelcollector/test/testkube/testkube-test-crs.yaml).
  - [ ] Are additional API server permissions needed for the new tests?
- [ ] These permissions have been added to
[api-server-permissions.yaml](/otelcollector/test/testkube/api-server-permissions.yaml).
  - [ ] Was a new test suite (a new folder under `/tests`) added?
- [ ] The new test suite is included in
[testkube-test-crs.yaml](/otelcollector/test/testkube/testkube-test-crs.yaml).
  • Loading branch information
rashmichandrashekar authored Jan 16, 2025
1 parent 477939d commit 6046862
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 12 additions & 2 deletions internal/docs/UpgradeotelCol.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,18 @@ Get latest release version and latest prometheusreceiver code:
go build -buildmode=pie -ldflags '-linkmode external -extldflags=-Wl,-z,now -s -X github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring.GroupName=azmonitoring.coreos.com' -o main . ; else CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -buildmode=pie -ldflags '-linkmode external -extldflags=-Wl,-z,now -s -X github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring.GroupName=azmonitoring.coreos.com'
```
6. Update main.go to include ARC EULA (lines 69-73)
7. Update go.mod file in the otel-allocator folder with the go.mod of the opentelemetry-operator file.
8. Run go mod tidy from the otel-allocator directory and then run make.
7. In the file - otelcollector/otel-allocator/config/flags.go add the below in the import section.
```
uberzap "go.uber.org/zap"
```
and add the below after *zapCmdLineOpts.BindFlags(zapFlagSet)* in the getFlagSet method.
```
lvl := uberzap.NewAtomicLevelAt(uberzap.PanicLevel)
zapCmdLineOpts.Level = &lvl
```

8. Update go.mod file in the otel-allocator folder with the go.mod of the opentelemetry-operator file.
9. Run go mod tidy from the otel-allocator directory and then run make.

## Configuration Reader Builder
1. Update the version of operator in go.mod of configuration-reader-builder to match versions in go.mod of otel-allocator
Expand Down
3 changes: 3 additions & 0 deletions otelcollector/otel-allocator/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"path/filepath"

"github.com/spf13/pflag"
uberzap "go.uber.org/zap"
"k8s.io/client-go/util/homedir"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
)
Expand Down Expand Up @@ -53,6 +54,8 @@ func getFlagSet(errorHandling pflag.ErrorHandling) *pflag.FlagSet {
flagSet.String(httpsTLSKeyFilePathFlagName, "", "The path to the HTTPS server TLS key file.")
zapFlagSet := flag.NewFlagSet("", flag.ErrorHandling(errorHandling))
zapCmdLineOpts.BindFlags(zapFlagSet)
lvl := uberzap.NewAtomicLevelAt(uberzap.PanicLevel)
zapCmdLineOpts.Level = &lvl
flagSet.AddGoFlagSet(zapFlagSet)
return flagSet
}
Expand Down

0 comments on commit 6046862

Please sign in to comment.