-
Notifications
You must be signed in to change notification settings - Fork 562
Bug 1932626: Gracefully handle service unavailable errors from kube-apiserver #2024
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ import ( | |
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/operator-framework/api/pkg/operators/v1alpha1" | ||
olmErrors "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/errors" | ||
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install" | ||
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil" | ||
) | ||
|
@@ -156,7 +155,7 @@ func (a *Operator) requirementStatus(strategyDetailsDeployment *v1alpha1.Strateg | |
} | ||
|
||
// Check if GVK exists | ||
if err := a.isGVKRegistered(r.Group, r.Version, r.Kind); err != nil { | ||
if ok, err := a.isGVKRegistered(r.Group, r.Version, r.Kind); !ok || err != nil { | ||
status.Status = "NotPresent" | ||
met = false | ||
statuses = append(statuses, status) | ||
|
@@ -219,7 +218,7 @@ func (a *Operator) requirementStatus(strategyDetailsDeployment *v1alpha1.Strateg | |
Name: name, | ||
} | ||
|
||
if err := a.isGVKRegistered(r.Group, r.Version, r.Kind); err != nil { | ||
if ok, err := a.isGVKRegistered(r.Group, r.Version, r.Kind); !ok || err != nil { | ||
status.Status = v1alpha1.RequirementStatusReasonNotPresent | ||
status.Message = "Native API does not exist" | ||
met = false | ||
|
@@ -397,7 +396,7 @@ func (a *Operator) requirementAndPermissionStatus(csv *v1alpha1.ClusterServiceVe | |
return met, statuses, nil | ||
} | ||
|
||
func (a *Operator) isGVKRegistered(group, version, kind string) error { | ||
func (a *Operator) isGVKRegistered(group, version, kind string) (bool, error) { | ||
logger := a.logger.WithFields(logrus.Fields{ | ||
"group": group, | ||
"version": version, | ||
|
@@ -408,15 +407,15 @@ func (a *Operator) isGVKRegistered(group, version, kind string) error { | |
resources, err := a.opClient.KubernetesInterface().Discovery().ServerResourcesForGroupVersion(gv.String()) | ||
if err != nil { | ||
logger.WithField("err", err).Info("could not query for GVK in api discovery") | ||
return err | ||
return false, err | ||
} | ||
|
||
for _, r := range resources.APIResources { | ||
if r.Kind == kind { | ||
return nil | ||
return true, nil | ||
} | ||
} | ||
|
||
logger.Info("couldn't find GVK in api discovery") | ||
return olmErrors.GroupVersionKindNotFoundError{group, version, kind} | ||
return false, nil | ||
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. I could not find any usage of If necessary, any caller of func (a *Operator) oldIsGVKRegistered(group, version, kind string) error {
ok, err := a.isGVKRegistered(group, version, kind)
if err != nil {
return err
}
if !ok {
return olmErrors.GroupVersionKindNotFoundError{group, version, kind}
}
return nil
} |
||
} |
Uh oh!
There was an error while loading. Please reload this page.