Repository navigation
Add the repository URL to the Helm index parse failure message - #2063
Conversation
c3091bd to
232790f
Compare
|
Friendly ping on this one. It is a small error message change in the HelmRepository reconciler. If it is welcome I can rebase it, and if it would be better to open an issue first or to drop it, just let me know |
stefanprodan
left a comment
There was a problem hiding this comment.
Thanks for picking this up. A few issues before this can go in:
-
The URL is duplicated on fetch errors. Helm's HTTP getter error already includes the full index URL, so a 404 ends up as:
looks like "https://example.com" is not a valid chart repository or cannot be reached: failed to fetch https://example.com/index.yaml : 404 Not FoundPlease keep the
CacheIndexerror as it is. -
Credentials can leak.
spec.urlmay containuser:pass@. Conditions and events must not contain secrets, so any URL we add to a message has to be redacted first, e.g. with(*url.URL).Redacted(). -
Keep the existing wording. "failed to fetch Helm repository index" and "failed to load Helm repository from index YAML" tell users which step failed. Please don't swap them for one generic message. Tools and alerts may also match on these strings.
-
Tests. Please add a test case to
TestHelmRepositoryReconciler_reconcileSourcethat asserts the newFetchFailedmessage. For example, anindex.yamlthat's served with a 200 but isn't valid YAML.
The one case where the URL is missing is the index parse failure. Something like this would cover #654:
fmt.Errorf("failed to load Helm repository from index YAML at %s: %w", redactedURL, err)Please also rebase on main.
When the repository index is fetched but cannot be parsed (for example the server returns HTML instead of YAML), the message only said "failed to load Helm repository from index YAML" without saying which repository it was. Add the URL, with the password of its user info redacted so it is safe to put in conditions and events. The existing "failed to fetch Helm repository index" message is kept as it is, because the error from the Helm getter already contains the URL. Closes fluxcd#654 Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@gmail.com>
232790f to
c516e47
Compare
|
Thanks @stefanprodan, this is a much better scope. I kept the CacheIndex error and both existing messages as they were, and the only change is the URL in the index parse failure, redacted with Redacted() as you suggested. You were right about the credentials, my first version would have put user:pass@ in the condition. I added the test to the invalid index case plus one that checks the password is redacted, and rebased on main |
stefanprodan
left a comment
There was a problem hiding this comment.
LGTM
Thanks @ogulcanaydogan
What's changed
Adds the repository URL to the message of the index parse failure in the HelmRepository reconciler. When the index is fetched but cannot be parsed (for example the server returns HTML instead of YAML), the
FetchFailedmessage now is:The URL is passed through
(*url.URL).Redacted()first, so auser:pass@inspec.urldoes not end up in conditions or events.The existing messages are kept as they were. In particular the
CacheIndexerror is untouched, because the Helm getter error already contains the full index URL.Tests
TestHelmRepositoryReconciler_reconcileSource_cachedIndexFile: the invalid index case now asserts the new message in the returned error and in theFetchFailedcondition.user:xxxxx@, the password never shows up in the error or in the condition).Both fail on main without the change.
Related
Closes #654