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

Workload resource mapping #1086

Merged

Conversation

sadlerap
Copy link
Contributor

Motivation

We need to be able to be informed where container data lives within a workload resource. This introduces support for workload resource mapping, which is how the specification API defines how we can be informed of this data.

Changes

A lot of the functionality of pipeline.Application has been changed to meet this need. To facilitate the requirement to look up data almost arbitrarily within an workload resource, we need to store and carry around the data to look up where our workload's data lives.

Testing

Unit tests should largely pass (with one exception, see below). The infrastructure for acceptance tests is largely there, but we're still a little short on the actual tests. I'll be working to have some more before this gets merged.

Other notes

  1. This crashes under integration/acceptance test scenarios. This is because go panics whenever I try to do a deep copy of a slice of maps (i.e. []map[string]interface); I haven't quite figured out why this is happing nor how to fix it.
  2. This enables support in both the specification API and our API. Judging from discussion a few weeks ago, we wanted to have a replacement for the bindingPath entry within a service binding; this is probably a more robust solution (current spec issues aside).
  3. Acceptance tests are a little short at the moment. I'm hoping to expand them going forward.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 23, 2021

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@codecov
Copy link

codecov bot commented Jan 7, 2022

Codecov Report

Merging #1086 (c6b8005) into master (78327d1) will decrease coverage by 1.42%.
The diff coverage is 56.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1086      +/-   ##
==========================================
- Coverage   58.92%   57.50%   -1.43%     
==========================================
  Files          30       31       +1     
  Lines        1670     2673    +1003     
==========================================
+ Hits          984     1537     +553     
- Misses        560      974     +414     
- Partials      126      162      +36     
Impacted Files Coverage Δ
apis/spec/v1alpha3/servicebinding_webhook.go 65.38% <ø> (-1.29%) ⬇️
apis/spec/v1alpha3/zz_generated.deepcopy.go 12.06% <0.00%> (-7.71%) ⬇️
pkg/reconcile/pipeline/api.go 77.77% <ø> (+2.77%) ⬆️
pkg/reconcile/pipeline/handler/project/impl.go 51.09% <47.91%> (-11.90%) ⬇️
pkg/reconcile/pipeline/context/application.go 64.10% <57.37%> (-13.68%) ⬇️
pkg/reconcile/pipeline/mapping.go 64.50% <64.50%> (ø)
pkg/reconcile/pipeline/context/impl.go 66.75% <73.19%> (+1.59%) ⬆️
...kg/reconcile/pipeline/context/spec_binding_impl.go 68.96% <75.00%> (-3.59%) ⬇️
pkg/converter/unstructured.go 72.09% <76.92%> (+49.87%) ⬆️
... and 29 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 78327d1...c6b8005. Read the comment docs.

@sadlerap sadlerap force-pushed the workload-resource-mapping branch 2 times, most recently from 0cdacdc to 2bbf251 Compare January 10, 2022 13:49
@sadlerap sadlerap marked this pull request as ready for review January 14, 2022 23:13
@sadlerap
Copy link
Contributor Author

This is probably good enough to review, at least from a high level. There are still some parts that might change: some acceptance tests are failing, and I know I need to add some more unit tests to make code coverage happy. However, I doubt the design is going to change all that much from these fixes, and most of this should be in good-enough shape to review.

Copy link
Contributor

@pedjak pedjak left a comment

Choose a reason for hiding this comment

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

Changes to the userguide should be also a part of this PR.

Side note: I somehow expected less changes on pkg/reconcile/pipeline/handler/project/impl.go

Makefile Outdated Show resolved Hide resolved
config/manager/kustomization.yaml Outdated Show resolved Hide resolved
controllers/common.go Outdated Show resolved Hide resolved
Comment on lines +162 to +165
_, err = client.
Resource(v1alpha3.WorkloadResourceMappingGroupVersionResource).
Get(c.Background(), serviceGVK.GroupKind().String(), metav1.GetOptions{})
Expect(err).To(Equal(errors.NewNotFound(v1alpha3.WorkloadResourceMappingGroupVersionResource.GroupResource(), serviceGVK.GroupKind().String())), "Binding should occur without a workload resource mapping")
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this assertion in the integration scenario?

apis/spec/v1alpha3/cluster_workload_resource_mapping.go Outdated Show resolved Hide resolved
pkg/reconcile/pipeline/context/impl.go Outdated Show resolved Hide resolved
@@ -425,9 +445,31 @@ func (i *impl) Close() error {
}
for _, app := range i.applications {
if app.IsUpdated() {
_, err = i.client.Resource(*app.gvr).Namespace(i.bindingMeta.Namespace).Update(context.Background(), app.Resource(), metav1.UpdateOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

why we needed to replace this line?

pkg/reconcile/pipeline/context/application.go Show resolved Hide resolved
pkg/reconcile/pipeline/handler/project/impl.go Outdated Show resolved Hide resolved
pkg/reconcile/pipeline/handler/project/impl.go Outdated Show resolved Hide resolved
@pmacik pmacik linked an issue Feb 10, 2022 that may be closed by this pull request
@sadlerap sadlerap marked this pull request as draft February 21, 2022 13:51
@sadlerap sadlerap force-pushed the workload-resource-mapping branch 2 times, most recently from 4ab5023 to 2311f33 Compare March 15, 2022 19:59
@baijum
Copy link
Member

baijum commented Apr 11, 2022

/retest

@baijum
Copy link
Member

baijum commented Apr 11, 2022

@baijum - I've added the tests you requested. I wrote them against the spec API; should we also have these tests against the coreos API as well?

I think tests in spec API are enough.

@baijum
Copy link
Member

baijum commented Apr 11, 2022

/retest

@sadlerap sadlerap force-pushed the workload-resource-mapping branch 4 times, most recently from d628f53 to 3a2b276 Compare April 11, 2022 19:27
@baijum
Copy link
Member

baijum commented Apr 12, 2022

/retest

2 similar comments
@pmacik
Copy link
Contributor

pmacik commented Apr 12, 2022

/retest

@sadlerap
Copy link
Contributor Author

/retest

@sadlerap
Copy link
Contributor Author

/retest

1 similar comment
@sadlerap
Copy link
Contributor Author

/retest

Implement support for ClusterWorkloadResourceMapping resources and most
of their required semantics as dictated by the specification.

The following are not implemented, and will be submitted in later
patches:
- validation on resource creation/modification
- correct unbind behavior when the mapping changes
- necessary documentation

Signed-off-by: Andy Sadler <ansadler@redhat.com>
@sadlerap
Copy link
Contributor Author

/retest

2 similar comments
@sadlerap
Copy link
Contributor Author

/retest

@sadlerap
Copy link
Contributor Author

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 13, 2022

@sadlerap: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/4.7-acceptance 6895640 link true /test 4.7-acceptance

Full PR test history. Your PR dashboard.

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.

@baijum
Copy link
Member

baijum commented Apr 14, 2022

/retest

@baijum
Copy link
Member

baijum commented Apr 14, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Apr 14, 2022
@dperaza4dustbit
Copy link
Contributor

This PR looks good to merge, any improvements we will like to see, lets add a Jira story under epic https://issues.redhat.com/browse/APPSVC-1082, any regression we notice lets add a jira bug.

@dperaza4dustbit dperaza4dustbit merged commit 6f7dadf into redhat-developer:master Apr 19, 2022
growi pushed a commit to growi/service-binding-operator that referenced this pull request Apr 27, 2022
Implement support for ClusterWorkloadResourceMapping resources and most
of their required semantics as dictated by the specification.

The following are not implemented, and will be submitted in later
patches:
- validation on resource creation/modification
- correct unbind behavior when the mapping changes
- necessary documentation

Signed-off-by: Andy Sadler <ansadler@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Workload Resource Mapping
6 participants