-
Notifications
You must be signed in to change notification settings - Fork 91
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
Change API Group and Kind, and Spec #495
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@lanceliuu Could you see my comment in the |
Should we use
Suggestions ? |
Issue #364 is discussing the same, right? I thought we decided to use |
@baijum Correct, we could end up using However, groups tend to be upstream or downstream organization / technology specific and |
Codecov Report
@@ Coverage Diff @@
## master #495 +/- ##
==========================================
- Coverage 63.07% 62.95% -0.13%
==========================================
Files 27 27
Lines 1774 1768 -6
==========================================
- Hits 1119 1113 -6
Misses 489 489
Partials 166 166
Continue to review full report at Codecov.
|
Name is required so IMO we should keep it as is, unless we have any scenario where it is optional |
// Service defines the selector based on resource name, version, and resource kind | ||
type Service struct { | ||
metav1.GroupVersionKind `json:",inline"` | ||
corev1.LocalObjectReference `json:",inline"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have LabelSelector
for Service.
Let's have it for Services
as well. We do support multiple services.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if that might affect the way we are:
- referring to backing services in custom env var.
- using env prefixes per service.
// +optional | ||
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"` | ||
metav1.GroupVersionResource `json:",inline"` | ||
ResourceRef string `json:"resourceRef,omitempty"` | ||
corev1.LocalObjectReference `json:",inline"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this // +optional
as well? In case when LabelSelector
is being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the content of the struct
is actually optional
LocalObjectReference struct {
// Name of the referent.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
// TODO: Add other useful fields. apiVersion, kind, uid?
// +optional
Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`
}
We could bubble up the information at this Application
struct level too though.
ResourceRef string `json:"resourceRef"` | ||
// Service defines the selector based on resource name, version, and resource kind | ||
type Service struct { | ||
metav1.GroupVersionKind `json:",inline"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove metav1.GroupVersionKind
and just have corev1.TypedLocalObjectReference
.
// TypedLocalObjectReference contains enough information to let you locate the
// typed referenced object inside the same namespace.
type TypedLocalObjectReference struct {
// APIGroup is the group for the resource being referenced.
// If APIGroup is not specified, the specified Kind must be in the core API group.
// For any other third-party types, APIGroup is required.
// +optional
APIGroup *string `json:"apiGroup" protobuf:"bytes,1,opt,name=apiGroup"`
// Kind is the type of resource being referenced
Kind string `json:"kind" protobuf:"bytes,2,opt,name=kind"`
// Name is the name of resource being referenced
Name string `json:"name" protobuf:"bytes,3,opt,name=name"`
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is an excellent idea. We could use it for Services
only though. Since name
is optional in Applications
, we'll not be able to use TypedLocalObjectReference
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..umm.. but APIGroup *string
isn't supposed to accept the Version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for services we need group version and Kind, corev1.TypedLocalObjectReference
will indeed not give the Version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moreover corev1.TypedLocalObjectReference is for the same namespace and we can have services in different namespaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps corev1.ObjectReference
can be a good fit, since it has both Namespace
and APIVersion
members?
Regardless, can you clarify the importance of the API version in this particular case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave it a shot here #495 (comment)
@@ -358,13 +358,13 @@ deploy-rbac: | |||
.PHONY: deploy-crds | |||
## Deploy-CRD: Deploy CRD | |||
deploy-crds: | |||
$(Q)kubectl apply -f deploy/crds/apps.openshift.io_servicebindingrequests_crd.yaml | |||
$(Q)kubectl apply -f deploy/crds/operators.coreos.com_servicebindings_crd.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we make this a bit more name agnostic, and avoid future changes as well:
$(Q)kubectl apply -f deploy/crds/*_crd.yaml
|
||
.PHONY: deploy-clean | ||
## Deploy-Clean: Removing CRDs and CRs | ||
deploy-clean: | ||
$(Q)-kubectl delete -f deploy/crds/apps_v1alpha1_servicebindingrequest_cr.yaml | ||
$(Q)-kubectl delete -f deploy/crds/apps.openshift.io_servicebindingrequests_crd.yaml | ||
$(Q)-kubectl delete -f deploy/crds/operators.coreos.com_servicebindings_cr.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you also consider extracting operators.coreos.com
in a variable and use it consistently across Makefile
? It would make later updates easier.
@@ -414,7 +414,7 @@ endif | |||
## Copy crd from deploy/crds to manifests-upstream/ | |||
consistent-crds-manifests-upstream: | |||
$(Q)cd ./manifests-upstream/${OPERATOR_VERSION}/ && ln -srf ../../deploy/crds/apps_v1alpha1_servicebindingrequest_crd.yaml \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line should be updated as well, since apps_v1alpha1_servicebindingrequest_crd.yaml
is getting renamed.
@@ -0,0 +1,18 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR diff and later git history would look nicer if we rename the files using git mv ...
command, and then apply the necessary changes/ With that git will able to understand that operators.coreos.com_servicebindings_cr.yaml
is the successor of apps_v1alpha1_servicebindingrequest_cr.yaml
, and all pending PRs that might contain changes to the old file would be applied correctly to the new one.
|
||
// DetectBindingResources is flag used to bind all non-bindable variables from | ||
// different subresources owned by backing operator CR. | ||
// +optional | ||
DetectBindingResources bool `json:"detectBindingResources,omitempty"` | ||
} | ||
|
||
// ServiceBindingRequestStatus defines the observed state of ServiceBindingRequest | ||
// ServiceBindingStatus defines the observed state of ServiceBindingStatus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ServiceBindingStatus defines the observed state of ServiceBindingStatus
you have a loop here :) It should be ServiceBindingStatus defines the observed state of ServiceBinding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, done, here you go
metav1.GroupVersionKind `json:",inline"` | ||
corev1.LocalObjectReference `json:",inline"` | ||
EnvVarPrefix *string `json:"envVarPrefix,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you provide description for these fields? Could we replace metav1.GroupVersionKind
and corev1.LocalObjectReference
with corev1.ObjectReference
perhaps? That would open up a possibility to refer Services in a different namespace, if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we could. @DhritiShikhar provided similar feedback 👍 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, Dhriti had a slightly different feedback.
#495 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made an attempt to use corev1.ObjectReference
but I see all the important fields ( Kind, Name, APIVersion) are optional.
The only option I see is to use the metav1.TypeMeta
in combination with name
/corev1.LocalObjectReference
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for metav1.TypeMeta
as it has APIVersion
instead of separate group
and version
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider this as well: kubernetes/community#4705.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we use
Group
,Version
,Resource
for anapplication
but
*APIVersion
&Kind
for aservice
?
@redhat-developer/service-binding Could you please chip in?
Please consider this as well: kubernetes/community#4705.
@isutton Would do you have a specific recommendation with regards to this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in role.yaml we define the resources on which we can perform the CRUD actions, a GVK is not specified. Since we edit/update the deployment with the envFrom: secretRef, we should use GVR schema when referring applications instead of GVK, IMO. From services we just collect information, not perform any update on it.
@@ -50,7 +50,7 @@ func TestApplicationSelectorByName(t *testing.T) { | |||
backingServiceResourceRef := "backingServiceRef" | |||
applicationResourceRef := "applicationRef" | |||
f := mocks.NewFake(t, reconcilerNs) | |||
f.AddMockedUnstructuredServiceBindingRequest(reconcilerName, backingServiceResourceRef, applicationResourceRef, deploymentsGVR, nil) | |||
f.AddMockedUnstructuredServiceBinding(reconcilerName, backingServiceResourceRef, applicationResourceRef, deploymentsGVR, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to log an issue for changes in variable names passed to mock functions. Not necessarily to be addressed in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the variable names could remain, they might make things more expressive?
Secret corev1.LocalObjectReference `json:"secretRef"` | ||
// ApplicationObjects contains all the application objects filtered by label | ||
// +optional | ||
Applications []BoundApplication `json:"applications,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we cannot bind to more than one application now, we should not have a list here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DhritiShikhar it is possible to have more than one application even if you can only declare one entry in spec.application
.
Application
embeds metav1.LabelSelector
as follows:
// Application defines the selector based on labels and GVR
type Application struct {
// +optional
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
metav1.GroupVersionResource `json:",inline"`
corev1.LocalObjectReference `json:",inline,omitempty"`
}
It is then used in Binder.search()
to list all resources matching the given GVR in the given namespace:
objects, err := b.dynClient.Resource(gvr).Namespace(ns).List(opts)
if err != nil {
return nil, ApplicationNotFound
}
This call to List()
can return multiple resources if multiple resources exist with labels declared in spec.application.matchLabels
.
@sbose78 Sure. I will pick up the item |
@@ -26,13 +26,13 @@ const ( | |||
// BindingFail binding has failed | |||
BindingFail = "BindingFail" | |||
//Finalizer annotation used in finalizer steps | |||
Finalizer = "finalizer.servicebindingrequest.openshift.io" | |||
Finalizer = "finalizer.servicebinding.openshift.io" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on finalizer.servicebinding.openshift.io
-> finalizer.servicebinding.operators.coreos.com
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being fixed in 5f8ae1e , thanks.
|
||
// DataMapping is used to map CR/CSV/CRD attributes to Custom env variables | ||
// +optional | ||
DataMapping []corev1.EnvVar `json:"dataMapping,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since DataMapping
is a list, should it be plural (DataMappings
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we revisit this rename?
The reason for this is is the input is a map of environment variable names and templates and its output are rendered environment variables, which makes it much closer to customEnvVars
than dataMapping
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I don't mind revisiting the name
@@ -5,19 +5,19 @@ metadata: | |||
alm-examples: |- | |||
[ | |||
{ | |||
"apiVersion": "apps.openshift.io/v1alpha1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the version going to remain as 0.0.23
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, I think is the template, but the version probably isn't used anywherre.
"group": "apps", | ||
"resource": "deployments", | ||
"resourceRef": "nodejs-rest-http-crud", | ||
"version": "v1" | ||
}, | ||
"backingServiceSelector": { | ||
"services": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be updated to reflect that services
is an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 67cd32c
examples/knative_postgresql_customvar/service-binding-request.yaml
Outdated
Show resolved
Hide resolved
@pedjak Thanks for the review, I'll get to your review comment shortly after I'm done handling the API changes! |
@sbose78: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@sbose78: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
I've summarized the changes in CHANGES section which contains feedback from OLM team.
The objective of this PR was to gather feedback from internal/external stakeholders. The objective has been met and summarized here in this comment and the Description. I'm closing the PR and letting the team take up the work to implement these in a separate PR. |
TLDR;
This is how the new CR looks like
NOTE: I've used the
operators.coreos.com
API Group for the time-being since we are in discussions with the OLM team on moving this project to github.com/operator-framework . However, folks are open to using a different API Group too. While I don't want to deviate too much, I am considering using an OperatorFramework-ish group & kind. Suggestions welcome! :)What should you review?
You don't really need to start looking at all 80+ files changed.
This file is what you need to be look at, to begin with: servicebinding_types.go
Motivation
Primarily
Also ..
corev1.LocalObjectReference
instead ofname
wherever application.Changes
Removed
spec.backingServiceSelector
Replaced
spec.applicationSelector
withspec.application
,Using
Application *Application
instead ofApplication Application
( feedback by OLM team )Using
DetectBindingResources *bool
instead ofDetectBindingResources bool
( feedback by OLM team )Replaced
spec.backingServiceSelectors
withspec.services
Replaced
spec.customEnvVar
withspec.dataMapping
<--- we don't have agreement on this, we may keep this as is.Replaced
resourceRef
inapplication
andservices
toname
corev1.LocalObjectReference
PENDING: The Application type has a label selector and a LocalObjectReference do I need to set a name and then use a label selector? I think that these should be a union type
PENDING: Change
spec.application
(Application
) tospec.applications
([]Application
). To do so without breaking changes ini add extraFieldsModifier to binder #426 , some amount of refactoring is needed.Pre-merge checklist
Group
( see NOTE in themotivation
section )Testing