Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

errors - explictly check for AccessErrors for CRDs and Events #2587

Merged
merged 3 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
errors - log all discovery errors, not just metrics
Signed-off-by: Wayne Witzel III <[email protected]>
  • Loading branch information
wwitzel3 committed Jul 12, 2021
commit 1e4f60a1ca63042ae4b6363919380dae92ec97b5
3 changes: 1 addition & 2 deletions internal/modules/applications/application_describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package applications
import (
"context"
"sort"
"strings"

"github.com/pkg/errors"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -128,7 +127,7 @@ func loadAppObjects(ctx context.Context, dashConfig config.Dash, namespace, name
resourceLists, err := discoveryClient.ServerPreferredResources()
if err != nil {
//TODO: determine the best way to handle these types of errors for all resources, not just metrics.
if discovery.IsGroupDiscoveryFailedError(err) && strings.Contains(err.Error(), "metrics") {
if discovery.IsGroupDiscoveryFailedError(err) {
logger := log.From(ctx)
logger.Debugf("preferred resources: %w", err)
} else {
Expand Down
2 changes: 1 addition & 1 deletion internal/printer/customresourcedefinition.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func CustomResourceDefinitionVersionList(
resourceLists, err := discoveryClient.ServerPreferredResources()
if err != nil {
//TODO: determine the best way to handle these types of errors for all resources, not just metrics.
if discovery.IsGroupDiscoveryFailedError(err) && strings.Contains(err.Error(), "metrics") {
if discovery.IsGroupDiscoveryFailedError(err) {
logger := log.From(ctx)
logger.Debugf("preferred resources: %w", err)
} else {
Expand Down
10 changes: 2 additions & 8 deletions internal/queryer/queryer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package queryer
import (
"context"
"fmt"
"strings"
"sync"

"github.com/pkg/errors"
Expand Down Expand Up @@ -212,7 +211,7 @@ func (osq *ObjectStoreQueryer) Children(ctx context.Context, owner *unstructured
}

resourceLists, err := osq.discoveryClient.ServerPreferredResources()
if err != nil && !osq.IsMetricsDiscoveryErr(err) {
if err != nil && !discovery.IsGroupDiscoveryFailedError(err) {
return nil, fmt.Errorf("objectStoreQueryer children: %w", err)
}

Expand Down Expand Up @@ -316,11 +315,6 @@ var allowed = []schema.GroupVersionKind{
gvk.ServiceAccount,
}

func (osq *ObjectStoreQueryer) IsMetricsDiscoveryErr(err error) bool {
//TODO: determine the best way to handle these types of errors for all resources, not just metrics.
return discovery.IsGroupDiscoveryFailedError(err) && strings.Contains(err.Error(), "metrics")
}

func (osq *ObjectStoreQueryer) canList(apiResource metav1.APIResource) bool {
return !dashstrings.Contains("watch", apiResource.Verbs) ||
!dashstrings.Contains("list", apiResource.Verbs)
Expand Down Expand Up @@ -552,7 +546,7 @@ func (osq *ObjectStoreQueryer) handle(
object *unstructured.Unstructured,
ownerReference metav1.OwnerReference) (bool, *unstructured.Unstructured, error) {
resourceList, err := osq.discoveryClient.ServerResourcesForGroupVersion(ownerReference.APIVersion)
if err != nil && !osq.IsMetricsDiscoveryErr(err) {
if err != nil && !discovery.IsGroupDiscoveryFailedError(err) {
return false, nil, fmt.Errorf("objectStoreQueryer handle: %w", err)
}
if resourceList == nil {
Expand Down