Skip to content

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

Merged
sunsingerus merged 1 commit intoAltinity:0.21.3from
zcross:zcross/bugfix-npe-issue-1187
Jul 7, 2023
Merged

Fix nil pointer deref in metrics exporter (#1187) #1188
sunsingerus merged 1 commit intoAltinity:0.21.3from
zcross:zcross/bugfix-npe-issue-1187

Conversation

@zcross
Copy link
Copy Markdown
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

@zcross
Copy link
Copy Markdown
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
Copy Markdown
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

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