-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
chore: give context to errors #15019
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
16585c0
chore: give context to error logs in reposerver
ashinsabu3 338bf59
chore: give context to errors in applicationset
ashinsabu3 0c79c87
chore: give context to errors(tweaks in error messages)
ashinsabu3 12131b2
chore: give context to errors(fix unit test)
ashinsabu3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1061,7 +1061,7 @@ func runHelmBuild(appPath string, h helm.Helm) error { | |||||
|
||||||
err = h.DependencyBuild() | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error building helm chart dependencies: %w", err) | ||||||
} | ||||||
return os.WriteFile(markerFile, []byte("marker"), 0644) | ||||||
} | ||||||
|
@@ -1102,15 +1102,15 @@ func helmTemplate(appPath string, repoRoot string, env *v1alpha1.Env, q *apiclie | |||||
|
||||||
resolvedValueFiles, err := getResolvedValueFiles(appPath, repoRoot, env, q.GetValuesFileSchemes(), appHelm.ValueFiles, q.RefSources, gitRepoPaths, appHelm.IgnoreMissingValueFiles) | ||||||
if err != nil { | ||||||
return nil, err | ||||||
return nil, fmt.Errorf("error resolving helm value files: %w", err) | ||||||
} | ||||||
|
||||||
templateOpts.Values = resolvedValueFiles | ||||||
|
||||||
if !appHelm.ValuesIsEmpty() { | ||||||
rand, err := uuid.NewRandom() | ||||||
if err != nil { | ||||||
return nil, err | ||||||
return nil, fmt.Errorf("error generating random unique id: %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
p := path.Join(os.TempDir(), rand.String()) | ||||||
defer func() { | ||||||
|
@@ -1121,7 +1121,7 @@ func helmTemplate(appPath string, repoRoot string, env *v1alpha1.Env, q *apiclie | |||||
}() | ||||||
err = os.WriteFile(p, appHelm.ValuesYAML(), 0644) | ||||||
if err != nil { | ||||||
return nil, err | ||||||
return nil, fmt.Errorf("error writing helm values file: %w", err) | ||||||
} | ||||||
templateOpts.Values = append(templateOpts.Values, pathutil.ResolvedFilePath(p)) | ||||||
} | ||||||
|
@@ -1136,7 +1136,7 @@ func helmTemplate(appPath string, repoRoot string, env *v1alpha1.Env, q *apiclie | |||||
for _, p := range appHelm.FileParameters { | ||||||
resolvedPath, _, err := pathutil.ResolveValueFilePathOrUrl(appPath, repoRoot, env.Envsubst(p.Path), q.GetValuesFileSchemes()) | ||||||
if err != nil { | ||||||
return nil, err | ||||||
return nil, fmt.Errorf("error resolving helm value file path: %w", err) | ||||||
} | ||||||
templateOpts.SetFile[p.Name] = resolvedPath | ||||||
} | ||||||
|
@@ -1160,17 +1160,17 @@ func helmTemplate(appPath string, repoRoot string, env *v1alpha1.Env, q *apiclie | |||||
|
||||||
helmRepos, err := getHelmRepos(appPath, q.Repos, q.HelmRepoCreds) | ||||||
if err != nil { | ||||||
return nil, err | ||||||
return nil, fmt.Errorf("error getting helm repos: %w", err) | ||||||
} | ||||||
h, err := helm.NewHelmApp(appPath, helmRepos, isLocal, version, proxy, passCredentials) | ||||||
if err != nil { | ||||||
return nil, err | ||||||
return nil, fmt.Errorf("error initializing helm app object: %w", err) | ||||||
} | ||||||
|
||||||
defer h.Dispose() | ||||||
err = h.Init() | ||||||
if err != nil { | ||||||
return nil, err | ||||||
return nil, fmt.Errorf("error initializing helm app: %w", err) | ||||||
} | ||||||
|
||||||
out, err := h.Template(templateOpts) | ||||||
|
@@ -1218,13 +1218,13 @@ func getResolvedValueFiles( | |||||
// If the $-prefixed path appears to reference another source, do env substitution _after_ resolving that source. | ||||||
resolvedPath, err = getResolvedRefValueFile(rawValueFile, env, allowedValueFilesSchemas, referencedSource.Repo.Repo, gitRepoPaths) | ||||||
if err != nil { | ||||||
return nil, err | ||||||
return nil, fmt.Errorf("error getting value file: %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
} else { | ||||||
// This will resolve val to an absolute path (or an URL) | ||||||
resolvedPath, isRemote, err = pathutil.ResolveValueFilePathOrUrl(appPath, repoRoot, env.Envsubst(rawValueFile), allowedValueFilesSchemas) | ||||||
if err != nil { | ||||||
return nil, err | ||||||
return nil, fmt.Errorf("error resolving value file path: %w", err) | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -1261,7 +1261,7 @@ func getResolvedRefValueFile( | |||||
// Resolve the path relative to the referenced repo and block any attempt at traversal. | ||||||
resolvedPath, _, err := pathutil.ResolveValueFilePathOrUrl(repoPath, repoPath, env.Envsubst(substitutedPath), allowedValueFilesSchemas) | ||||||
if err != nil { | ||||||
return "", err | ||||||
return "", fmt.Errorf("error resolving value file path: %w", err) | ||||||
} | ||||||
return resolvedPath, nil | ||||||
} | ||||||
|
@@ -1325,7 +1325,7 @@ func GenerateManifests(ctx context.Context, appPath, repoRoot, revision string, | |||||
|
||||||
appSourceType, err := GetAppSourceType(ctx, q.ApplicationSource, appPath, repoRoot, q.AppName, q.EnabledSourceTypes, opt.cmpTarExcludedGlobs) | ||||||
if err != nil { | ||||||
return nil, err | ||||||
return nil, fmt.Errorf("error getting app source type: %w", err) | ||||||
} | ||||||
repoURL := "" | ||||||
if q.Repo != nil { | ||||||
|
@@ -1505,7 +1505,7 @@ func GetAppSourceType(ctx context.Context, source *v1alpha1.ApplicationSource, a | |||||
} | ||||||
appType, err := discovery.AppType(ctx, appPath, repoPath, enableGenerateManifests, tarExcludedGlobs) | ||||||
if err != nil { | ||||||
return "", err | ||||||
return "", fmt.Errorf("error getting application type string: %v", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
return v1alpha1.ApplicationSourceType(appType), nil | ||||||
} | ||||||
|
@@ -2047,7 +2047,7 @@ func loadFileIntoIfExists(path pathutil.ResolvedFilePath, destination *string) e | |||||
if err == nil && !info.IsDir() { | ||||||
bytes, err := os.ReadFile(stringPath) | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error reading file from %s: %w", stringPath, err) | ||||||
} | ||||||
*destination = string(bytes) | ||||||
} | ||||||
|
@@ -2060,7 +2060,7 @@ func findHelmValueFilesInPath(path string) ([]string, error) { | |||||
|
||||||
files, err := os.ReadDir(path) | ||||||
if err != nil { | ||||||
return result, err | ||||||
return result, fmt.Errorf("error reading helm values file from %s: %w", path, err) | ||||||
} | ||||||
|
||||||
for _, f := range files { | ||||||
|
@@ -2189,7 +2189,7 @@ func (s *Service) GetRevisionMetadata(ctx context.Context, q *apiclient.RepoServ | |||||
}) | ||||||
|
||||||
if err != nil { | ||||||
return nil, err | ||||||
return nil, fmt.Errorf("error acquiring repo lock: %w", err) | ||||||
} | ||||||
|
||||||
defer io.Close(closer) | ||||||
|
Oops, something went wrong.
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.
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.
How about getting just slightly fancier?
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.
makes sense, its definitely better to give more context
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.
I'm assuming the index variable should also be changed to i
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.
Yep!