Fix odo hang when cluster is unreachable (#4307)

* Fix odo hang

Remove isResourceSupported call from command intialization

* Address review comments
This commit is contained in:
Aditi Sharma
2020-12-17 00:10:52 +05:30
committed by GitHub
parent 7d3341dcda
commit 802ce80bd1
5 changed files with 11 additions and 24 deletions

View File

@@ -200,6 +200,8 @@ func (c *Client) SetDiscoveryInterface(client discovery.DiscoveryInterface) {
}
func (c *Client) IsResourceSupported(apiGroup, apiVersion, resourceName string) (bool, error) {
klog.V(4).Infof("Checking if %q resource supported", resourceName)
if c.supportedResources == nil {
c.supportedResources = make(map[string]bool, 7)
}

View File

@@ -60,6 +60,7 @@ func newCommonLinkOptions() *commonLinkOptions {
// Complete completes LinkOptions after they've been created
func (o *commonLinkOptions) complete(name string, cmd *cobra.Command, args []string) (err error) {
o.csvSupport, _ = svc.IsCSVSupported()
o.operationName = name

View File

@@ -88,7 +88,6 @@ type LinkOptions struct {
func NewLinkOptions() *LinkOptions {
options := LinkOptions{}
options.commonLinkOptions = newCommonLinkOptions()
options.commonLinkOptions.csvSupport, _ = svc.IsCSVSupported()
options.commonLinkOptions.serviceBinding = &servicebinding.ServiceBinding{}
return &options
}
@@ -96,6 +95,7 @@ func NewLinkOptions() *LinkOptions {
// Complete completes LinkOptions after they've been created
func (o *LinkOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) {
o.commonLinkOptions.devfilePath = filepath.Join(o.componentContext, DevfilePath)
o.commonLinkOptions.csvSupport, _ = svc.IsCSVSupported()
err = o.complete(name, cmd, args)
if err != nil {

View File

@@ -49,12 +49,12 @@ type UnlinkOptions struct {
func NewUnlinkOptions() *UnlinkOptions {
options := UnlinkOptions{}
options.commonLinkOptions = newCommonLinkOptions()
options.commonLinkOptions.csvSupport, _ = svc.IsCSVSupported()
return &options
}
// Complete completes UnlinkOptions after they've been created
func (o *UnlinkOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) {
o.commonLinkOptions.csvSupport, _ = svc.IsCSVSupported()
err = o.complete(name, cmd, args)
if err != nil {
return err

View File

@@ -46,18 +46,9 @@ var (
# Create new EtcdCluster service from etcdoperator.v0.9.4 operator.
%[1]s etcdoperator.v0.9.4/EtcdCluster`)
createShortDesc = `Create a new service from service catalog using the plan defined and deploy it on OpenShift.`
createShortDesc = `Create a new service from Operator Hub or Service Catalog and deploy it on OpenShift.`
createLongDesc = ktemplates.LongDesc(`
Create a new service from service catalog using the plan defined and deploy it on OpenShift.
A --plan must be passed along with the service type. Parameters to configure the service are passed as key=value pairs.
For a full list of service types, use: 'odo catalog list services'`)
createShortDescOperatorHub = `Create a new service from Operator Hub or Service Catalog and deploy it on OpenShift.`
createLongDescOperatorHub = ktemplates.LongDesc(`
Create a new service from Operator Hub or Service Catalog and deploy it on OpenShift.
When creating a service using Operator Hub, provide a service name along with Operator name.
@@ -518,18 +509,11 @@ func NewCmdServiceCreate(name, fullName string) *cobra.Command {
},
}
// we ignore the error because it doesn't matter at this place to deal with it and the function returns a *cobra.Command
csvSupport, _ := svc.IsCSVSupported()
if csvSupport {
serviceCreateCmd.Use += fmt.Sprintf(" [flags]\n %s <operator_type>/<crd_name> [service_name] [flags]", o.CmdFullName)
serviceCreateCmd.Short = createShortDescOperatorHub
serviceCreateCmd.Long = createLongDescOperatorHub
serviceCreateCmd.Example += "\n\n" + fmt.Sprintf(createOperatorExample, fullName)
serviceCreateCmd.Flags().BoolVar(&o.DryRun, "dry-run", false, "Print the yaml specificiation that will be used to create the service")
// remove this feature after enabling service create interactive mode for operator backed services
serviceCreateCmd.Flags().StringVar(&o.fromFile, "from-file", "", "Path to the file containing yaml specification to use to start operator backed service")
}
serviceCreateCmd.Use += fmt.Sprintf(" [flags]\n %s <operator_type>/<crd_name> [service_name] [flags]", o.CmdFullName)
serviceCreateCmd.Example += "\n\n" + fmt.Sprintf(createOperatorExample, fullName)
serviceCreateCmd.Flags().BoolVar(&o.DryRun, "dry-run", false, "Print the yaml specificiation that will be used to create the operator backed service")
// remove this feature after enabling service create interactive mode for operator backed services
serviceCreateCmd.Flags().StringVar(&o.fromFile, "from-file", "", "Path to the file containing yaml specification to use to start operator backed service")
serviceCreateCmd.Flags().StringVar(&o.Plan, "plan", "", "The name of the plan of the service to be created")
serviceCreateCmd.Flags().StringArrayVarP(&o.parameters, "parameters", "p", []string{}, "Parameters of the plan where a parameter is expressed as <key>=<value")