fix(nil pointer): storage class reference #92
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1
Description
This PR fixes the issue where the operator gets a nil pointer exception while trying to reach the storage class name of a storage class name template when it is not specified.
Important:
StorageClassName
is generally not a required field (https://github.com/kubernetes/kubernetes/blob/0cabb55f7c05eb269ae6f7292271833f095657ec/pkg/apis/core/types.go#L461).If a storage class is not provided, Kubernetes checks the default StorageClass (https://kubernetes.io/docs/concepts/storage/storage-classes/#default-storageclass).
This is tricky because there could be multiple storage classes and very dangerous to Druid (https://github.com/kubernetes/kubernetes/blob/0cabb55f7c05eb269ae6f7292271833f095657ec/test/e2e/framework/pv/pv.go#L822).
Therefore, we will require users to specify a storage class when they add a volume claim template to their StatefulSets.
Backward compatibility:
Not specifying
storageClassName
is a very unpopular behavior but it may happen. Such users will have to check theirDruid
workloads and add a storage class to their claim templatesThis PR adds a feature of validation of storage class names inside a Node of kind StatefulSet. It also adds a nil check before trying to reach this field.
Tests are also added to check both logics.
This PR has:
Key changed/added files in this PR
handler.go
volume_expansion.go
volume_expansion_test.go