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

handle source.spec.helm.ignoreMissingValuesFiles = true #303

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

sl1pm4t
Copy link
Collaborator

@sl1pm4t sl1pm4t commented Nov 8, 2024

If the helm source has ignoreMissingValuesFiles = true kubechecks should ignore values file copy errors where the file is not found.

In one of our multi source appsets we reference a bunch of optional values files that allow overriding values at different levels / layers / environments / tiers / providers / whatever.

failed to generate manifests: failed to package application: failed to copy referenced value file: "$values/apps/aws-provider/default.values.yaml": open /tmp/kubechecks-repo-4238925250/apps/aws-provider/default.values.yaml: no such file or directory

@djeebus
Copy link
Collaborator

djeebus commented Nov 8, 2024

Good call, thanks!

@sl1pm4t sl1pm4t changed the title handle source.spec.helm.ignoreMissingValues = true handle source.spec.helm.ignoreMissingValuesFiles = true Nov 8, 2024
@zapier-sre-bot
Copy link
Collaborator

Mergecat's Review

Click to read mergecats review!

😼 Mergecat review of pkg/argo_client/manifests.go

@@ -334,7 +334,12 @@ func packageApp(ctx context.Context, source v1alpha1.ApplicationSource, refs []v
 				src := filepath.Join(refRepo.Directory, refPath)
 				dst := filepath.Join(tempDir, refPath)
 				if err = copyFile(src, dst); err != nil {
-					return "", errors.Wrapf(err, "failed to copy referenced value file: %q", valueFile)
+					// handle source.spec.helm.ignoreMissingValues = true
+					if errors.Is(err, os.ErrNotExist) && source.Helm.IgnoreMissingValueFiles {
+						log.Debug().Str("valueFile", valueFile).Msg("ignore missing values file, because source.Helm.IgnoreMissingValueFiles is true")
+					} else {
+						return "", errors.Wrapf(err, "failed to copy referenced value file: %q", valueFile)
+					}
 				}
 
 				relPath, err := filepath.Rel(tempAppDir, dst)

Feedback & Suggestions:

  1. Error Handling Improvement: The added condition to handle missing value files when IgnoreMissingValueFiles is true is a good addition. However, consider logging at a higher level (e.g., Info) if this is an expected behavior that should be visible in production logs. If it's purely for debugging, Debug is appropriate.

  2. Code Clarity: The comment // handle source.spec.helm.ignoreMissingValues = true could be more descriptive. Consider rephrasing it to explain the logic, such as // Skip missing value files if IgnoreMissingValueFiles is set to true.

  3. Performance Consideration: If the IgnoreMissingValueFiles flag is frequently used, consider measuring the performance impact of logging each missing file. If it becomes a bottleneck, you might want to batch log these messages or provide a summary at the end.

  4. Security Consideration: Ensure that the valueFile being logged does not contain sensitive information. If there's any chance it might, consider sanitizing the output.

Overall, the changes are well-implemented for the intended functionality. 🛠️



Dependency Review

Click to read mergecats review!

No suggestions found

@djeebus djeebus merged commit 0598e32 into zapier:multi-source-apps Nov 8, 2024
3 checks passed
@sl1pm4t sl1pm4t deleted the multi-source-apps branch November 8, 2024 20:28
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.

3 participants