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

Fix nil pointer deref in metrics exporter (#1187) #1188

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

zcross
Copy link
Contributor

@zcross zcross commented Jul 7, 2023

This is a very targeted fix for the NPE shown in #1187 since it's a known problem. The general pattern of guarding status lookups may be worth thinking about. Maybe we just need an intermediate type that decouples the application level usage of this state from its serialization/deserialization, at which point we can use basic language features like field visibility to reduce the probability of future unsafe accesses.

Important items to consider before making a Pull Request

Please check items PR complies to:

  • All commits in the PR are squashed. More info
  • The PR is made into dedicated next-release branch, not into master branch1. More info
  • The PR is signed. More info

…ureStatus() access

Signed-off-by: Zach Cross <zcross@chronosphere.io>
@zcross
Copy link
Contributor Author

zcross commented Jul 7, 2023

Meta: it would seem to be going against the trend to add some highly specific unit test for this, so I'm going to let integration tests "cover it" ... although they didn't catch its first introduction (possibly due to the self-healing / temporal element of the "status" state). I made this quick edit in a text editor so I'm crossing my fingers for a green build :)

@sunsingerus sunsingerus merged commit d1414ea into Altinity:0.21.3 Jul 7, 2023
@zcross
Copy link
Contributor Author

zcross commented Jul 7, 2023

Whoops:

133.0 pkg/apis/metrics/exporter.go:295:8: invalid operation: operator ! not defined on chi.EnsureStatus().GetNormalizedCHICompleted() (value of type *"github.com/***/clickhouse-operator/pkg/apis/clickhouse.***.com/v1".ClickHouseInstallation)

I'll fire this up on my actual development machine and fix that now

zcross added a commit to zcross/clickhouse-operator that referenced this pull request Jul 7, 2023
Signed-off-by: Zach Cross <zcross@chronosphere.io>
zcross added a commit to zcross/clickhouse-operator that referenced this pull request Jul 7, 2023
Signed-off-by: Zach Cross <zcross@chronosphere.io>
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.

2 participants