fix: improve CMP logging and error messages (#24022)

Signed-off-by: Jongwon Youn <eatingcookieman@gmail.com>
Signed-off-by: Alexandre Gaudreault <alexandre_gaudreault@intuit.com>
Co-authored-by: Alexandre Gaudreault <alexandre_gaudreault@intuit.com>
This commit is contained in:
Jongwon Youn 2025-09-13 01:54:58 +09:00 committed by GitHub
parent 48933252b4
commit ba38778d8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 13 additions and 13 deletions

View file

@ -857,7 +857,7 @@ func (r *ApplicationSetReconciler) removeFinalizerOnInvalidDestination(ctx conte
// Detect if the destination is invalid (name doesn't correspond to a matching cluster)
if destCluster, err := argoutil.GetDestinationCluster(ctx, app.Spec.Destination, r.ArgoDB); err != nil {
appLog.Warnf("The destination cluster for %s couldn't be found: %v", app.Name, err)
appLog.Warnf("The destination cluster for %s could not be found: %v", app.Name, err)
validDestination = false
} else {
// Detect if the destination's server field does not match an existing cluster
@ -876,7 +876,7 @@ func (r *ApplicationSetReconciler) removeFinalizerOnInvalidDestination(ctx conte
}
if !matchingCluster {
appLog.Warnf("A match for the destination cluster for %s, by server url, couldn't be found", app.Name)
appLog.Warnf("A match for the destination cluster for %s, by server url, could not be found", app.Name)
}
validDestination = matchingCluster

View file

@ -399,19 +399,19 @@ func addInvalidGeneratorNames(names map[string]bool, applicationSetInfo *argoapp
var values map[string]any
err := json.Unmarshal([]byte(config), &values)
if err != nil {
log.Warnf("couldn't unmarshal kubectl.kubernetes.io/last-applied-configuration: %+v", config)
log.Warnf("could not unmarshal kubectl.kubernetes.io/last-applied-configuration: %+v", config)
return
}
spec, ok := values["spec"].(map[string]any)
if !ok {
log.Warn("couldn't get spec from kubectl.kubernetes.io/last-applied-configuration annotation")
log.Warn("could not get spec from kubectl.kubernetes.io/last-applied-configuration annotation")
return
}
generators, ok := spec["generators"].([]any)
if !ok {
log.Warn("couldn't get generators from kubectl.kubernetes.io/last-applied-configuration annotation")
log.Warn("could not get generators from kubectl.kubernetes.io/last-applied-configuration annotation")
return
}
@ -422,7 +422,7 @@ func addInvalidGeneratorNames(names map[string]bool, applicationSetInfo *argoapp
generator, ok := generators[index].(map[string]any)
if !ok {
log.Warn("couldn't get generator from kubectl.kubernetes.io/last-applied-configuration annotation")
log.Warn("could not get generator from kubectl.kubernetes.io/last-applied-configuration annotation")
return
}

View file

@ -1542,7 +1542,7 @@ func GenerateManifests(ctx context.Context, appPath, repoRoot, revision string,
// if pluginName is provided it has to be `<metadata.name>-<spec.version>` or just `<metadata.name>` if plugin version is empty
targetObjs, err = runConfigManagementPluginSidecars(ctx, appPath, repoRoot, pluginName, env, q, q.Repo.GetGitCreds(gitCredsStore), opt.cmpTarDoneCh, opt.cmpTarExcludedGlobs, opt.cmpUseManifestGeneratePaths)
if err != nil {
err = fmt.Errorf("plugin sidecar failed. %s", err.Error())
err = fmt.Errorf("CMP processing failed for application %q: %w", q.AppName, err)
}
case v1alpha1.ApplicationSourceTypeDirectory:
var directory *v1alpha1.ApplicationSourceDirectory

View file

@ -103,7 +103,7 @@ func DetectConfigManagementPlugin(ctx context.Context, appPath, repoPath, plugin
// check if the given plugin supports the repo
conn, cmpClient, connFound = cmpSupports(ctx, pluginSockFilePath, appPath, repoPath, fmt.Sprintf("%v.sock", pluginName), env, tarExcludedGlobs, true)
if !connFound {
return nil, nil, fmt.Errorf("couldn't find cmp-server plugin with name %q supporting the given repository", pluginName)
return nil, nil, fmt.Errorf("could not find cmp-server plugin with name %q supporting the given repository", pluginName)
}
} else {
fileList, err := os.ReadDir(pluginSockFilePath)

View file

@ -670,12 +670,12 @@ func (a *ClientApp) GetUserInfo(actualClaims jwt.MapClaims, issuerURL, userInfoP
if errors.Is(err, cache.ErrCacheMiss) {
return claims, true, fmt.Errorf("no accessToken for %s: %w", sub, err)
} else if err != nil {
return claims, true, fmt.Errorf("couldn't read accessToken from cache for %s: %w", sub, err)
return claims, true, fmt.Errorf("could not read accessToken from cache for %s: %w", sub, err)
}
accessToken, err := crypto.Decrypt(encAccessToken, a.encryptionKey)
if err != nil {
return claims, true, fmt.Errorf("couldn't decrypt accessToken for %s: %w", sub, err)
return claims, true, fmt.Errorf("could not decrypt accessToken for %s: %w", sub, err)
}
url := issuerURL + userInfoPath
@ -743,11 +743,11 @@ func (a *ClientApp) GetUserInfo(actualClaims jwt.MapClaims, issuerURL, userInfoP
rawClaims, err := json.Marshal(claims)
if err != nil {
return claims, false, fmt.Errorf("couldn't marshal claim to json: %w", err)
return claims, false, fmt.Errorf("could not marshal claim to json: %w", err)
}
encClaims, err = crypto.Encrypt(rawClaims, a.encryptionKey)
if err != nil {
return claims, false, fmt.Errorf("couldn't encrypt user info response: %w", err)
return claims, false, fmt.Errorf("could not encrypt user info response: %w", err)
}
err = a.clientCache.Set(&cache.Item{
@ -758,7 +758,7 @@ func (a *ClientApp) GetUserInfo(actualClaims jwt.MapClaims, issuerURL, userInfoP
},
})
if err != nil {
return claims, false, fmt.Errorf("couldn't put item to cache: %w", err)
return claims, false, fmt.Errorf("could not put item to cache: %w", err)
}
return claims, false, nil