Skip to content
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

use swagger.json to get available parameters for odo service create #4850

Closed
2 of 4 tasks
kadel opened this issue Jun 24, 2021 · 7 comments · Fixed by #5074
Closed
2 of 4 tasks

use swagger.json to get available parameters for odo service create #4850

kadel opened this issue Jun 24, 2021 · 7 comments · Fixed by #5074
Assignees
Labels
estimated-size/M (10-20) Rough sizing for Epics. About 1 sprint of work for one person estimated-size/S (5-10) Rough sizing for Epics. Less then one sprint of work for one person kind/epic An issue categorized as a high-level Epic. Needs to be scoped and broken down in 1+ stories/tasks

Comments

@kadel
Copy link
Member

kadel commented Jun 24, 2021

Acceptance criteria:

  • output format of odo catalog describe service and odo catalog describe service -o json needs to be the same regardless of where the information about parameters is coming from CSV or swagger.json
  • output of odo catalog describe service -o json should be in some standard format like OpenAPIV3, JSONSchema etc...
  • information about parameters should be cached for both CSV and swagger.json. No need to cache the whole swagger.json we can just store information about parameters (more at Revised Proposal to param based operator service creation #4751 (comment))
  • allow setting parameters using odo service create -p ...
@kadel kadel added this to the 2.4 (planning) milestone Jun 24, 2021
@kadel kadel added the kind/epic An issue categorized as a high-level Epic. Needs to be scoped and broken down in 1+ stories/tasks label Jun 24, 2021
@girishramnani
Copy link
Contributor

@dharmit
Copy link
Member

dharmit commented Aug 12, 2021

/triage needs-information

As a part of research, please also break this "Epic" down into "User Stories".

@openshift-ci openshift-ci bot added the triage/needs-information Indicates an issue needs more information in order to work on it. label Aug 12, 2021
@dharmit dharmit added this to For Consideration in Sprint 206 via automation Aug 12, 2021
@dharmit
Copy link
Member

dharmit commented Aug 18, 2021

We need to consider how this will help odo catalog describe service <operator>/<cr>. For example, currently, odo can't print anything helpful for Redis Operator:

$ odo catalog list services
Services available through Operators
NAME                                CRDs
etcdoperator.v0.9.4-clusterwide     EtcdCluster, EtcdBackup, EtcdRestore
redis-operator.v0.6.0               RedisCluster, Redis

$ odo catalog describe service redis-operator.v0.6.0/RedisCluster 
Kind: RedisCluster
Version: v1beta1
Description: Redis Cluster
Parameters:

 PATH  DISPLAYNAME  DESCRIPTION 



$ odo catalog describe service redis-operator.v0.6.0/Redis       
Kind: Redis
Version: v1beta1
Description: Redis
Parameters:

 PATH  DISPLAYNAME  DESCRIPTION 

@dharmit
Copy link
Member

dharmit commented Aug 19, 2021

Currently, there are three places where we know we can get the parameters' info from:

  • X Descriptors from the CSV
  • swagger.json
  • CRD (but only accessible via admin user)

Based on the discussion between @kadel and Adapters team, ODC is mainly using swagger.json and relies on X descriptors only for additional data it provides on top of what's available via swagger.json.

In odo, so far, we have relied on X descriptors as primary source of info, and only now we're trying to use what swagger.json has to offer. odo should try and change its approach to how ODC is doing it, because swagger seems to have much more information than X Descriptors.

@mik-dass
Copy link
Contributor

mik-dass commented Aug 19, 2021

Three cases (arranged by ascending priority):

Case 1: User has access to the CRD's api path, cluster provides an api to get metadata for any CRD needed. URL - <cluster-url>/api/kubernetes/apis/apiextensions.k8s.io/v1/customresourcedefinitions

Case 2: Get the swagger.json from the openapi endpoint provided by kubernetes, <cluster-url>/api/kubernetes/openapi/v2. We fetch the file during odo catalog list services. Steps: https://github.com/openshift/odo/blob/main/docs/proposals/improved-schema-for-services.md#kuberenetes-cluster-swagger-has-the-schema

Case 3: Admin-only approach of using CRD api from the cluster: https://github.com/openshift/odo/blob/main/docs/proposals/improved-schema-for-services.md#fetch-clusterserviceversion-to-generate-the-information

Parsing the data

Case 1:

  • Traverse the openAPIv3schema and if we find standard types (like string, integer) we add it to the descriptor listing with its path
  • while traversing if we find any complex types like object or array we don't add then to the listing but traverse deeper.
  • if we find an array we add [*] as a suffix of the path traversed so far, so that its obvious to the user that they need to add an index there. i.e. zookeeper.env[*].key

Case 2: Fetch the same openAPIV3Schema from the cluster's swagger.json from the endpoint /api/kubernetes/openapi/v2 and parse it as mentioned in https://github.com/openshift/odo/blob/main/docs/proposals/improved-schema-for-services.md#user-has-access-to-openapiv3schema

Case 3: Use the spec.customresourcedefinitions present in the ClusterServiceVersion. This CRD def is different from what is provided by the CustomResourceDefinition as it has less information. Example output: https://github.com/openshift/odo/blob/main/docs/proposals/improved-schema-for-services.md#fetch-clusterserviceversion-to-generate-the-information

Commands

odo catalog describe service

Human readable output:

- FieldPath: zookeeper.resources.limit.min
  DisplayName: Limit Min
  Description: <description>
  Type: string
- FieldPath: zookeeper.storage.type
  Type: string
- FieldPath: zookeeper.env[*].key
  Type: string

odo service create

Parse the user inputs provided via -p and validate it as mentioned in
https://github.com/openshift/odo/blob/main/docs/proposals/improved-schema-for-services.md#allowing-user-to-set-the-parameters

@mik-dass mik-dass added triage/ready and removed triage/needs-information Indicates an issue needs more information in order to work on it. labels Aug 19, 2021
@dharmit
Copy link
Member

dharmit commented Aug 19, 2021

Scope:

  • Get hands on swagger.
  • Store swagger in user's system
  • Pull swagger each time (don't cache)
  • odo catalog describe for Redis operator should work fine.
  • Parse whatever comes from swagger.json

@dharmit dharmit added the estimated-size/S (5-10) Rough sizing for Epics. Less then one sprint of work for one person label Aug 19, 2021
@dharmit dharmit moved this from For Consideration to To Do in Sprint 206 Aug 19, 2021
@feloy feloy moved this from To Do to In Progress in Sprint 206 Aug 23, 2021
@feloy feloy moved this from In Progress to For Review in Sprint 206 Aug 27, 2021
@dharmit dharmit moved this from For Review to Done in Sprint 206 Sep 6, 2021
@dharmit dharmit added this to For Consideration in Sprint 207 via automation Sep 6, 2021
@dharmit
Copy link
Member

dharmit commented Sep 9, 2021

Scope

  • If there is swagger info, we use that to validate the parameters.
  • if swagger info doesn't exist, we use x-descriptors from CSV
  • if nothing exists; we don't validate the parameters
  • we don't want to do caching right now
  • integration tests
  • Documentation, if possible.

@feloy feloy moved this from For Consideration to In Progress in Sprint 207 Sep 15, 2021
@feloy feloy moved this from In Progress to For Review in Sprint 207 Sep 20, 2021
Sprint 207 automation moved this from For Review to Done Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
estimated-size/M (10-20) Rough sizing for Epics. About 1 sprint of work for one person estimated-size/S (5-10) Rough sizing for Epics. Less then one sprint of work for one person kind/epic An issue categorized as a high-level Epic. Needs to be scoped and broken down in 1+ stories/tasks
Projects
No open projects
Sprint 206
  
Done
Sprint 207
  
Done
Development

Successfully merging a pull request may close this issue.

5 participants