-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
operator: Refactor CreateOrUpdateLokiStack handler #11592
operator: Refactor CreateOrUpdateLokiStack handler #11592
Conversation
Trivy scan found the following vulnerabilities:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment but apart from that it does make CreateOrUpdateLokiStack
simpler on the eyes
7fab92e
to
900a5a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I like this version much more! Just a small comment but this is going in a great direction
) | ||
|
||
var hashSeparator = []byte(",") | ||
|
||
// ExtractSecret reads a k8s secret into a manifest object storage struct if valid. | ||
func ExtractSecret(s *corev1.Secret, secretType lokiv1.ObjectStorageSecretType) (*storage.Options, error) { | ||
func getSecret(ctx context.Context, k k8s.Client, stack *lokiv1.LokiStack) (*corev1.Secret, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about error handling, if we plan for this function to be used to fetch other secrets other than the object storage one then, we should also provide a way to configure the DegradedError struct.
I am however more of the opinion of changing the name of this function to be more specific and not allude to the idea of reusing it when we need to get secrets from k8s. Instead, we should create a new function for getting new secrets out of k8s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea overall and seems to work just as before 👍
Only have a few minor comments. In general I noticed a few comments that we had before because most functions were public, which are not necessary anymore (because they do not document any special behaviour).
operator/internal/handlers/internal/gateway/tenant_configsecret.go
Outdated
Show resolved
Hide resolved
} | ||
|
||
// extractSecret reads a k8s secret into a manifest object storage struct if valid. | ||
func extractSecret(s *corev1.Secret, secretType lokiv1.ObjectStorageSecretType) (storage.Options, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we stick to the pointered return type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because when we pass back to the manifests.Options
we use a non-pointered version.
Co-authored-by: Robert Jacob <[email protected]>
Co-authored-by: Robert Jacob <[email protected]>
Co-authored-by: Robert Jacob <[email protected]>
Co-authored-by: Robert Jacob <[email protected]>
Co-authored-by: Robert Jacob <[email protected]>
Co-authored-by: Robert Jacob <[email protected]>
Co-authored-by: Robert Jacob <[email protected]>
[release-5.8] LOG-4969: Backport PRs grafana#11624 and grafana#11592
[release-5.7] LOG-4968: Backport PRs grafana#11624 and grafana#11592
[release-5.6] LOG-4967: Backport PRs grafana#11624 and grafana#11592
Co-authored-by: Robert Jacob <[email protected]>
What this PR does / why we need it:
Refactor the
CreateOrUpdateLokiStack
handler to separate functions to re-instantiate readability.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
The gist is moving and isolating all internal packages code into the internal package itself for gateway, storage and rules. This enhances readability in the handler itself. In addition the internal package's public interface is down to 1 or max 2 functions (i.e.
{gateway,storage,rules}.BuildOptions
) and the use cases can be tested locally w/o the heavy handler setup code.Checklist
CONTRIBUTING.md
guide (required)CHANGELOG.md
updatedadd-to-release-notes
labeldocs/sources/setup/upgrade/_index.md
production/helm/loki/Chart.yaml
and updateproduction/helm/loki/CHANGELOG.md
andproduction/helm/loki/README.md
. Example PRdeprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PRcc @JoaoBraveCoding