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: Fail gracefully when unable to unmarshal cluster secret #6427

Merged
merged 4 commits into from
Jun 9, 2021

Conversation

jannfis
Copy link
Member

@jannfis jannfis commented Jun 8, 2021

Correctly handle errors when failing to parse cluster secrets instead of emitting a panic()

Fixes #6423

Signed-off-by: jannfis jann@mistrust.net

Note on DCO:

If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).

Signed-off-by: jannfis <jann@mistrust.net>
clusterList.Items[i] = cluster
cluster, err := secretToCluster(clusterSecret)
if err != nil {
log.Errorf("could not unmarshal cluster secret: %v", err)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure (here as well as below) whether we should pass the value of err to the Logger, since it may contain some confidential information?

Is the error content required for users to troubelshoot, or shall we just omit the details?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. The error might have token. Even if it is just part of a token still not good to log it. May be just print secret name e.g.:

log.Errorf("could not unmarshal cluster secret: %s", clusterSecret.Name)

clusterList.Items[i] = cluster
cluster, err := secretToCluster(clusterSecret)
if err != nil {
log.Errorf("could not unmarshal cluster secret: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. The error might have token. Even if it is just part of a token still not good to log it. May be just print secret name e.g.:

log.Errorf("could not unmarshal cluster secret: %s", clusterSecret.Name)

Copy link
Collaborator

@alexmt alexmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please resolve comment about error before merging

Signed-off-by: jannfis <jann@mistrust.net>
@codecov
Copy link

codecov bot commented Jun 9, 2021

Codecov Report

Merging #6427 (54ff852) into master (12c95d6) will increase coverage by 0.01%.
The diff coverage is 38.70%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6427      +/-   ##
==========================================
+ Coverage   41.01%   41.02%   +0.01%     
==========================================
  Files         152      152              
  Lines       20088    20131      +43     
==========================================
+ Hits         8239     8259      +20     
- Misses      10716    10733      +17     
- Partials     1133     1139       +6     
Impacted Files Coverage Δ
util/db/cluster.go 63.33% <38.70%> (+1.02%) ⬆️
util/webhook/webhook.go 62.56% <0.00%> (-3.53%) ⬇️
reposerver/cache/cache.go 64.51% <0.00%> (-2.93%) ⬇️
pkg/apis/application/v1alpha1/types.go 57.89% <0.00%> (-0.18%) ⬇️
server/server.go 54.95% <0.00%> (+0.08%) ⬆️
controller/clusterinfoupdater.go 36.20% <0.00%> (+1.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 12c95d6...54ff852. Read the comment docs.

Signed-off-by: jannfis <jann@mistrust.net>
Signed-off-by: jannfis <jann@mistrust.net>
@jannfis jannfis merged commit 1f9fc2c into argoproj:master Jun 9, 2021
@jannfis jannfis self-assigned this Jun 25, 2021
@jannfis jannfis added the needs-verification PR requires pre-release verification label Jun 25, 2021
@alexmt alexmt removed the needs-verification PR requires pre-release verification label Aug 13, 2021
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.

Bad Kubernetes Secret Breaks ArgoCD Deployment
2 participants