Skip to content

Commit

Permalink
Fix: Fix logging of resources in case of group and apiversion not exi…
Browse files Browse the repository at this point in the history
…sting for resource managed by ArgoCD

Signed-off-by: TheCoolDrop <[email protected]>
  • Loading branch information
thecooldrop committed Nov 17, 2024
1 parent b22f54b commit 61ee025
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1836,21 +1836,21 @@ func printAppResources(w io.Writer, app *argoappv1.Application, discoveryClient

func mergeDuplicateClusterLevelResources(resourceStates []*versionedResourceState, discoveryClient discovery.DiscoveryInterface) []*versionedResourceState {
resourcesByKey := make(map[kube.ResourceKey]*versionedResourceState)
// GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE
// argoproj.io Fake argocd-e2e--test-app-sync-wrong-version-xunes fake-crd-instance OutOfSync Missing The Kubernetes API could not find version "v1alpha2" of argoproj.io/Fake for requested resource argocd-e2e--test-app-sync-wrong-version-xunes/fake-crd-instance. Version "v1alpha1" of argoproj.io/Fake is installed on the destination cluster.

for _, resource := range resourceStates {
groupVersion := ""
if resource.Group != "" {
groupVersion += (resource.Group + "/")
}
groupVersion += resource.Version
apiResourceList, err := discoveryClient.ServerResourcesForGroupVersion(groupVersion)
if err != nil {
errors.CheckError(fmt.Errorf("unable to retrieve server resources for group and version combination %s: %w", groupVersion, err))
}

for _, apiResource := range apiResourceList.APIResources {
if resource.Group == apiResource.Group && resource.Version == apiResource.Version && resource.Kind == apiResource.Kind {
if !apiResource.Namespaced {
resource.Namespace = ""
if apiResourceList, err := discoveryClient.ServerResourcesForGroupVersion(groupVersion); err == nil {
for _, apiResource := range apiResourceList.APIResources {
if resource.Group == apiResource.Group && resource.Version == apiResource.Version && resource.Kind == apiResource.Kind {
if !apiResource.Namespaced {
resource.Namespace = ""
}
}
}
}
Expand Down

0 comments on commit 61ee025

Please sign in to comment.