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

Revised Proposal to param based operator service creation #4751

Merged
merged 18 commits into from
Jun 16, 2021

Conversation

girishramnani
Copy link
Contributor

What type of PR is this?
/kind design
/kind documentation
[skip ci]

What does this PR do / why we need it:
see $SUBJECT

Which issue(s) this PR fixes:

Fixes #4240

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

  • Update changelog

  • I have read the test guidelines

How to test changes / Special notes to the reviewer:

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label May 26, 2021
@girishramnani girishramnani added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label May 26, 2021
@girishramnani
Copy link
Contributor Author

girishramnani commented May 26, 2021

@kadel @dharmit The swagger.json that is present on the cluster is currently 15MBs when I tried. What would be the best approach to cache it?
And we need to be sure that we update the swagger when a new operator is installed on the cluster.

So I was thinking of fetching it parallely when a user does odo catalog list services? This would give us a headstart?

Once we have the swagger.json, we can either store it whole, or specifically store all the CRDs that are listed in odo catalog list services?

I was thinking of storing the operator listing ( just the operator part of odo catalog list services) in the cache as well so when the user runs the command again we can diff between the old and new operator listing to confirm if a new one was installed? and if it was then we fetch the swagger.json again from the cluster?

@girishramnani girishramnani changed the title Revised Proposal to param based operator service creation [WIP] Revised Proposal to param based operator service creation May 26, 2021
@openshift-ci openshift-ci bot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Jun 8, 2021
@girishramnani girishramnani removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jun 8, 2021
@girishramnani girishramnani changed the title [WIP] Revised Proposal to param based operator service creation Revised Proposal to param based operator service creation Jun 8, 2021
# Improved schema for operator backed services

This proposal is about improving the experience for a user of the operator backed services. Currently a user doesn't know exaustively which fields are available in a CR as we depend on optional metadata present in CRDs, to improve this we are considering using the metadata available from the cluster about the CRDs.
Getting that metadata from the cluster is challenging because a normal cluster user ( plain vanilla ) doesn't have access to that metadata so we are gonna follow a 3 tiered approach
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the "plain vanilla" in this case? Is it normal user on vanilla k8s or non-admin user on any of k8s/ocp clusters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both actually, a normal user or non admin user. From the metadata perspective both are same

This proposal is about improving the experience for a user of the operator backed services. Currently a user doesn't know exaustively which fields are available in a CR as we depend on optional metadata present in CRDs, to improve this we are considering using the metadata available from the cluster about the CRDs.
Getting that metadata from the cluster is challenging because a normal cluster user ( plain vanilla ) doesn't have access to that metadata so we are gonna follow a 3 tiered approach

- check if the user has access to the CRD, if so then use that.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what scenario(s) is the CRD accessible to non-admin user? My understanding is that kubectl get crds fails when done as a non-admin user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user has permissions to that endpoint but is not admin user then they can use it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Technically feasible. But doesn't seem like a scenario we would have too often. Again, I can't back up my comment with Telemetry. It's more of a hunch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we should still account for such event as web console uses that same approach so they would have a reason to do this


This change would affect multiple service commands and the changes are described briefly below -
- `odo catalog describe service` should include the metadata fields with description so the users can provide then when doing `odo service create`
- `odo catalog list service` shouldn't change much other then listing CRDs per operator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're already listing all the CRDs provided by all the installed Operators. I think this won't change at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, changing that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

docs/proposals/improved-schema-for-services.md Outdated Show resolved Hide resolved
@dharmit
Copy link
Member

dharmit commented Jun 9, 2021

@girishramnani @kadel I'm probably missing something simple here. Where in the swagger AP (http://<cluster-url>/openapi/v2) that we're discussing here is the information about parameters available?

I'm referring to the JSON available at this endpoint and I can't find the parameters that we see in the alm-example. I'm currently trying to find parameters for etcdcluster.

Besides that, in the JSON, is there one place where I can find all the Operators? I ask this because information for etcd Operator and service binding Operator are available at two different endpoints:

  • /apis/etcd.database.coreos.com/v1beta2/etcdclusters
  • /apis/binding.operators.coreos.com/v1alpha1/servicebindings

Am I looking at the right place?

@girishramnani
Copy link
Contributor Author

@girishramnani @kadel I'm probably missing something simple here. Where in the swagger AP (http://<cluster-url>/openapi/v2) that we're discussing here is the information about parameters available?

I'm referring to the JSON available at this endpoint and I can't find the parameters that we see in the alm-example. I'm currently trying to find parameters for etcdcluster.

Besides that, in the JSON, is there one place where I can find all the Operators? I ask this because information for etcd Operator and service binding Operator are available at two different endpoints:

  • /apis/etcd.database.coreos.com/v1beta2/etcdclusters
  • /apis/binding.operators.coreos.com/v1alpha1/servicebindings

Am I looking at the right place?

The json that I would have pasted wouldn’t have etcd as I didn’t have that installed at the time.
Also that gist is half, will paste a full file soon

@dharmit
Copy link
Member

dharmit commented Jun 9, 2021

The json that I would have pasted wouldn’t have etcd as I didn’t have that installed at the time.
Also that gist is half, will paste a full file soon

I was referring to the Swagger data I got from my cluster which had etcd Opreator installed.

@girishramnani
Copy link
Contributor Author

The json that I would have pasted wouldn’t have etcd as I didn’t have that installed at the time.
Also that gist is half, will paste a full file soon

I was referring to the Swagger data I got from my cluster which had etcd Opreator installed.

Could you please share that file?


At this stage the user either has access to the `openAPIV3Schema` or `ClusterServiceVersion` and also the user has provided the service parameters they want to set as well. To hide the difference between these implementation from the user the `catalog describe` output would follow the same format. e.g.
```
- FieldPath: zookeeper.resources
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how are arrays of objects going to be represented in this output?

lets say that there is that first.second.envVars is and array of env variable objects ({name: "foo", value:"bar"})
How the FieldPath will look like, so users know that envVars is an array of objects and the format they need to use is first.second.envVars[0].name=foo first.second.envVars[0].value=bar)
and they don't try to do something like first.second.envVars.name=foo first.second.envVars.value=bar or first.second[0].envVars.name=foo first.second[0].envVars.value=bar)

Copy link
Contributor Author

@girishramnani girishramnani Jun 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my thought was to Maybe we can show it as first.second.envVars[*].name and explain in describe that * needs to be an index 0,1….?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my thought was to Maybe we can show it as first.second.envVars[*].name and explain in describe that * needs to be an index 0,1….?

👍 If there is enough information to do that that would be great!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we have information on what is an array from swagger

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added conversion detail in the proposal

@girishramnani
Copy link
Contributor Author

So I worked on going through the swagger and realised some CRs dont have any information.

      "com.redhat.quay.v1.QuayRegistry": {
        "type": "object",
        "x-kubernetes-group-version-kind": [
          {
            "group": "quay.redhat.com",
            "kind": "QuayRegistry",
            "version": "v1"
          }
        ]
      }

in such cases we will as usual fallback to x-descriptor

@kadel
Copy link
Member

kadel commented Jun 15, 2021

There is still a lot of details that need to be figured out. But those are going to be easier to figure out once we start implementing this.
From a high level, this looks good.
/approve

@openshift-ci
Copy link

openshift-ci bot commented Jun 15, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kadel

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Jun 15, 2021
@dharmit
Copy link
Member

dharmit commented Jun 16, 2021

So I worked on going through the swagger and realised some CRs dont have any information.

      "com.redhat.quay.v1.QuayRegistry": {
        "type": "object",
        "x-kubernetes-group-version-kind": [
          {
            "group": "quay.redhat.com",
            "kind": "QuayRegistry",
            "version": "v1"
          }
        ]
      }

in such cases we will as usual fallback to x-descriptor

This particular one is my main concern/worry. But we got to start implementing things to realize what's working and what's not.

/LGTM

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 16, 2021
@openshift-merge-robot openshift-merge-robot merged commit 0e9e971 into redhat-developer:main Jun 16, 2021

If the user doesn't have CRD access or that portion is not implemented yet then we fetch try to fetch the same `openAPIV3Schema` from the cluster's `swagger.json` from the endpoint `<cluster-url>/api/kubernetes/openapi/v2`. This is a very large document as it holds all the definitions present on the cluster.

So this needs to be cached and refreshed whenever a new operator is installed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very comfortable with managing an automatic cache (which, without a serious protocol between the two parts, is doomed to be inefficient).

What about a specific and explicit odo command, that the user could run to fetch the param information for one or more services?

User story:

  1. odo catalog list services indicates the params or number of params if known, or if not known, that the user can fetch them.
  2. fetch the params for a specific service
$ odo catalog list services
Services available through Operators
NAME                                             CRDs                                                          Params
etcdoperator.v0.9.4-clusterwide     EtcdCluster, EtcdBackup, EtcdRestore       (to fetch)
service-binding-operator.v0.7.1     ServiceBinding                                             3 parameters
To fetch params for a service, you can run `odo service fetch-params <service-name>


$ odo service fetch-params etcdoperator.v0.9.4-clusterwide/EtcdCluster
...

Also, only the params information could be stored locally (and not the complete swagger/CRD info), independently of the source of the params (ClusterServiceVersion, swagger, CRD), so the use of this data by odo service create is generic.

The user could detect which method for fetching the data is available, or give the user the choice to select one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch the params for a specific service

I'm not sure about this. As a user I would be pretty annoyed that I have to run extra command to get information that is essentially required for creating services.
Why odo catalog list services couldn't do that automatically?

Also, only the params information could be stored locally (and not the complete swagger/CRD info), independently of the source of the params (ClusterServiceVersion, swagger, CRD), so the use of this data by odo service create is generic.

I like the idea of caching just params for all sources. This is good.

The user could detect which method for fetching the data is available, or give the user the choice to select one.

I think that this is exposing implementation to users. The user doesn't care where the data comes from. Especially when it can be a fairly complicated decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal for improved and interactive operator backed services
5 participants