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

feat: support auto generation of ContainerSource identity service account and expose in AuthStatus #7461

Merged

Conversation

prakrit55
Copy link
Contributor

Fixes #7228

Proposed Changes

  • Added feature for autogeneration of serviceaccount in ContainerSource
  • Added tests
  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

Release Note


Docs

Signed-off-by: Griffin <prakritimandal611@gmail.com>
Signed-off-by: Griffin <prakritimandal611@gmail.com>
@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 21, 2023
Copy link

knative-prow bot commented Nov 21, 2023

Hi @prakrit55. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

Signed-off-by: Griffin <prakritimandal611@gmail.com>
Copy link
Member

@creydr creydr left a comment

Choose a reason for hiding this comment

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

Hey @prakrit55,
thanks a lot for your PR. I left a few comments.

/ok-to-test

pkg/reconciler/containersource/containersource_test.go Outdated Show resolved Hide resolved
serviceaccountInformer := serviceaccountinformer.Get(ctx)

var globalResync func(obj interface{})
featureStore := feature.NewStore(logging.FromContext(ctx).Named("featur-config-store"),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
featureStore := feature.NewStore(logging.FromContext(ctx).Named("featur-config-store"),
featureStore := feature.NewStore(logging.FromContext(ctx).Named("feature-config-store"),

@@ -361,3 +435,22 @@ func makeSinkBindingStatus(ready *corev1.ConditionStatus) *sourcesv1.SinkBinding
},
}
}

func makeContainerSourceOIDCServiceAccount() *corev1.ServiceAccount {
return auth.GetOIDCServiceAccountForResource(sourcesv1.SchemeGroupVersion.WithKind("Source"), metav1.ObjectMeta{
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return auth.GetOIDCServiceAccountForResource(sourcesv1.SchemeGroupVersion.WithKind("Source"), metav1.ObjectMeta{
return auth.GetOIDCServiceAccountForResource(sourcesv1.SchemeGroupVersion.WithKind("ContainerSource"), metav1.ObjectMeta{

@knative-prow knative-prow bot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Nov 21, 2023
@knative-prow knative-prow bot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 21, 2023
Signed-off-by: Griffin <prakritimandal611@gmail.com>
pkg/apis/sources/v1/container_lifecycle_test.go Outdated Show resolved Hide resolved
pkg/apis/sources/v1/container_lifecycle_test.go Outdated Show resolved Hide resolved
pkg/apis/sources/v1/container_lifecycle_test.go Outdated Show resolved Hide resolved
pkg/apis/sources/v1/container_lifecycle_test.go Outdated Show resolved Hide resolved
pkg/apis/sources/v1/container_lifecycle_test.go Outdated Show resolved Hide resolved
@@ -179,6 +195,7 @@ func TestContainerSourceStatusIsReady(t *testing.T) {
s.InitializeConditions()
s.PropagateSinkBindingStatus(&notReadySinkBinding.Status)
s.PropagateReceiveAdapterStatus(availableDeployment)
s.MarkOIDCIdentityCreatedFailed("unknown", "")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
s.MarkOIDCIdentityCreatedFailed("unknown", "")
s.MarkOIDCIdentityCreatedSucceeded()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we should put some cases where it gets failed, to make the tests more obedient.

Copy link
Member

Choose a reason for hiding this comment

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

That would be great if you could add such a test

pkg/apis/sources/v1/container_lifecycle_test.go Outdated Show resolved Hide resolved
Copy link
Member

@creydr creydr left a comment

Choose a reason for hiding this comment

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

two more comments regarding the unit test failures.
BTW: you can always run all unit test locally via go test ./...

Signed-off-by: Griffin <prakritimandal611@gmail.com>
Copy link

codecov bot commented Nov 22, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (c8f4624) 76.74% compared to head (eae182c) 76.81%.
Report is 27 commits behind head on main.

Files Patch % Lines
pkg/reconciler/containersource/controller.go 68.75% 3 Missing and 2 partials ⚠️
pkg/reconciler/containersource/containersource.go 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7461      +/-   ##
==========================================
+ Coverage   76.74%   76.81%   +0.06%     
==========================================
  Files         253      253              
  Lines       13916    14136     +220     
==========================================
+ Hits        10680    10858     +178     
- Misses       2702     2736      +34     
- Partials      534      542       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Griffin <prakritimandal611@gmail.com>
Signed-off-by: Griffin <prakritimandal611@gmail.com>
Copy link
Member

@creydr creydr left a comment

Choose a reason for hiding this comment

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

Hello @prakrit55,
thanks for adding the tests.
I left a few comments. As mentioned, you can run the tests locally too (via go test ./...) - this also saves review time 🙃

pkg/apis/sources/v1/container_lifecycle_test.go Outdated Show resolved Hide resolved
pkg/apis/sources/v1/container_lifecycle_test.go Outdated Show resolved Hide resolved
pkg/apis/sources/v1/container_lifecycle_test.go Outdated Show resolved Hide resolved
pkg/apis/sources/v1/container_lifecycle_test.go Outdated Show resolved Hide resolved
Signed-off-by: Griffin <prakritimandal611@gmail.com>
Copy link
Member

@creydr creydr left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your contribution @prakrit55!

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Nov 23, 2023
Copy link

knative-prow bot commented Nov 23, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: creydr, prakrit55

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

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 23, 2023
@creydr
Copy link
Member

creydr commented Nov 23, 2023

/test reconciler-tests

@knative-prow knative-prow bot merged commit 116abe2 into knative:main Nov 23, 2023
38 of 41 checks passed
creydr added a commit to creydr/knative-eventing that referenced this pull request May 3, 2024
…vice account and expose in AuthStatus (knative#7461)"

This reverts commit 116abe2.
creydr added a commit to creydr/knative-eventing that referenced this pull request May 3, 2024
…vice account and expose in AuthStatus (knative#7461)"

This reverts commit 116abe2.
creydr added a commit to creydr/knative-eventing that referenced this pull request May 3, 2024
…vice account and expose in AuthStatus (knative#7461)"

This reverts commit 116abe2.
creydr added a commit to creydr/knative-eventing that referenced this pull request May 3, 2024
…vice account and expose in AuthStatus (knative#7461)"

This reverts commit 116abe2.
creydr added a commit to creydr/knative-eventing that referenced this pull request May 3, 2024
…vice account and expose in AuthStatus (knative#7461)"

This reverts commit 116abe2.
creydr added a commit to creydr/knative-eventing that referenced this pull request May 3, 2024
…vice account and expose in AuthStatus (knative#7461)"

This reverts commit 116abe2.
knative-prow bot pushed a commit that referenced this pull request May 3, 2024
* Revert "feat: support auto generation of ContainerSource identity service account and expose in AuthStatus (#7461)"

This reverts commit 116abe2.

* Containersource use OIDC identity of corresponding SinkBinding

* Update dependencies

* Add e2e test

* Run gofmt and goimport
creydr added a commit to creydr/knative-eventing that referenced this pull request May 3, 2024
…vice account and expose in AuthStatus (knative#7461)"

This reverts commit 116abe2.
creydr added a commit to creydr/knative-eventing that referenced this pull request May 3, 2024
…vice account and expose in AuthStatus (knative#7461)"

This reverts commit 116abe2.
creydr added a commit to creydr/knative-eventing that referenced this pull request May 3, 2024
…vice account and expose in AuthStatus (knative#7461)"

This reverts commit 116abe2.
openshift-merge-bot bot pushed a commit to openshift-knative/eventing that referenced this pull request May 6, 2024
…nkBinding (#603)

* Revert "feat: support auto generation of ContainerSource identity service account and expose in AuthStatus (knative#7461)"

This reverts commit 116abe2.

* Containersource use OIDC identity of corresponding SinkBinding
knative-prow bot pushed a commit that referenced this pull request May 6, 2024
…kBinding (#7892)

* Revert "feat: support auto generation of ContainerSource identity service account and expose in AuthStatus (#7461)"

This reverts commit 116abe2.

* Containersource use OIDC identity of corresponding SinkBinding

* Run gofmt and goimport
creydr added a commit to creydr/knative-eventing that referenced this pull request May 7, 2024
…vice account and expose in AuthStatus (knative#7461)"

This reverts commit 116abe2.
knative-prow bot pushed a commit that referenced this pull request May 7, 2024
…kBinding (#7898)

* Revert "feat: support auto generation of ContainerSource identity service account and expose in AuthStatus (#7461)"

This reverts commit 116abe2.

* Containersource use OIDC identity of corresponding SinkBinding

* Run gofmt and goimports

* Fix build issue
openshift-merge-bot bot pushed a commit to openshift-knative/eventing that referenced this pull request May 8, 2024
…nkBinding (#604)

* Revert "feat: support auto generation of ContainerSource identity service account and expose in AuthStatus (knative#7461)"

This reverts commit 116abe2.

* Containersource use OIDC identity of corresponding SinkBinding
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. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support auto generation of ContainerSource identity service account and expose in AuthStatus
2 participants