Skip to content
This repository was archived by the owner on Jun 4, 2021. It is now read-only.

AWS SQS source#124

Merged
knative-prow-robot merged 16 commits into
knative:masterfrom
srvaroa:master
Dec 18, 2018
Merged

AWS SQS source#124
knative-prow-robot merged 16 commits into
knative:masterfrom
srvaroa:master

Conversation

@srvaroa
Copy link
Copy Markdown
Contributor

@srvaroa srvaroa commented Nov 20, 2018

Proposed Changes

  • Provide basic suport for an AWS SQS source.

@knative-prow-robot knative-prow-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 20, 2018
@knative-prow-robot knative-prow-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 20, 2018
@srvaroa
Copy link
Copy Markdown
Contributor Author

srvaroa commented Nov 20, 2018

I have been able to run this successfully. I still want to give a pass to the READMEs and cleanup code but it should be in a decent state to get some feedback.

cc @rootfs, I used some of your earlier work at knative/eventing#328 as reference, if you have some time to take a look that'd be great.

name: awssqs-bus-ext
spec:
hosts:
- "*.amazonaws.com"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is actually not working and I had to use the FQDN (sqs.eu-west-1.amazonaws.com in my case) to make it work.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

what do you see in the istio sidecar container?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @rootfs. It looks like a false alarm. The istio-proxy container takes longer to start than the receive-adapter so you can see this in the logs:

default/awssqs-devhose-source-vzrsc-765c547b68-gmp7m[receive-adapter]: {"level":"info","ts":1542735771.9919236,"caller":"awssqs_receive_adapter/main.go:68","msg":"Starting AWS SQS Receive Adapter. %v","adapter":{"Region":"eu-west-1","QueueUrl":"...","SinkURI":"http://qux-1-channel.default.svc.cluster.local/","CredsFile":"/var/secrets/aws/credentials"}}
default/awssqs-test-source-vzrsc-765c547b68-gmp7m[receive-adapter]: {"level":"info","ts":1542735771.9922512,"logger":"fallback","caller":"awssqs/adapter.go:63","msg":"Starting with config: {adapter 22 0 0xc4200cedc0}"}
default/awssqs-test-source-vzrsc-765c547b68-gmp7m[receive-adapter]: {"level":"warn","ts":1542735772.3487105,"logger":"fallback","caller":"awssqs/adapter.go:77","msg":"Failed to poll from SQS queue{error 25 0 RequestError: send request failed\ncaused by: Post https://sqs.eu-west-1.amazonaws.com/: dial tcp 52.95.114.128:443: connect: connection refused}"}

But the istio-proxy does initialize correctly after a while

default/awssqs-devhose-source-vzrsc-765c547b68-gmp7m[istio-proxy]: [2018-11-20 17:42:53.579][19][info][upstream] external/envoy/source/common/upstream/cluster_manager_impl.cc:494] add/update cluster outbound|80||message-dumper-00001-service.default.svc.cluster.local during init
default/awssqs-devhose-source-vzrsc-765c547b68-gmp7m[istio-proxy]: [2018-11-20 17:42:53.579][19][info][upstream] external/envoy/source/common/upstream/cluster_manager_impl.cc:494] add/update cluster outbound|443||controller-manager-service.knative-sources.svc.cluster.local during init
default/awssqs-devhose-source-vzrsc-765c547b68-gmp7m[istio-proxy]: [2018-11-20 17:42:53.580][19][info][upstream] external/envoy/source/common/upstream/cluster_manager_impl.cc:494] add/update cluster outbound|443||*.amazonaws.com during init

At this point, the receive adapter starts to poll successfully.

In my tests I had a plain exit if there was a poll error (I'm reading from a queue with a lot of messages so it was hard to read the logs while debugging.) I didn't realize that the sleep I added on error actually masks this behaviour.

@rootfs
Copy link
Copy Markdown

rootfs commented Nov 20, 2018

@srvaroa thanks for mentioning :)

I am adopting container source for my new event source here. It is quite similar to SQS. Except secret volume (which is to be addressed in #55, container source is ready for its prime time.

cc @grantr @n3wscott

@srvaroa srvaroa changed the title WIP: AWS SQS source [WIP]: AWS SQS source Nov 20, 2018
Comment thread cmd/awssqs_receive_adapter/main.go Outdated
Comment thread cmd/awssqs_receive_adapter/main.go Outdated
Comment thread cmd/awssqs_receive_adapter/main.go Outdated
Comment thread cmd/awssqs_receive_adapter/main.go Outdated
Comment thread cmd/awssqs_receive_adapter/main.go Outdated
Comment thread pkg/controller/awssqs/reconcile.go
Comment thread pkg/controller/awssqs/reconcile.go Outdated
Comment thread samples/awssqs_source/README.md
Comment thread samples/awssqs_source/README.md
Comment thread samples/awssqs_source/README.md Outdated
Provide basic suport for an AWS SQS source.

Signed-off-by: Galo Navarro <anglorvaroa@gmail.com>
@srvaroa srvaroa changed the title [WIP]: AWS SQS source AWS SQS source Nov 22, 2018
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 22, 2018
Signed-off-by: Galo Navarro <anglorvaroa@gmail.com>
Signed-off-by: Galo Navarro <anglorvaroa@gmail.com>
@srvaroa
Copy link
Copy Markdown
Contributor Author

srvaroa commented Nov 27, 2018

@Harwayne I applied your other suggestion re. having stopCh parametrized to the start method in the adapter (see 6cec8fc) - I couldn't reply on that thread

Signed-off-by: Galo Navarro <anglorvaroa@gmail.com>
Comment thread pkg/apis/sources/v1alpha1/aws_sqs_types.go Outdated
@whynowy
Copy link
Copy Markdown
Contributor

whynowy commented Nov 29, 2018

@srvaroa - Since it's AWS SQS event source, I would assume people use SQS are running their K8s clusters on AWS EC2 instances. From within the cluster to access AWS resources (like SQS), there's another way to do it with kiam (https://github.com/uswitch/kiam) or kube2iam instead of using a long lived credential stored in k8s secret, I implemented the SQS event source by using kiam (https://github.com/whynowy/eventing-sources/commits/develop), I think it would be better to support both ways, what do you think?

@whynowy
Copy link
Copy Markdown
Contributor

whynowy commented Nov 29, 2018

@srvaroa - Since it's AWS SQS event source, I would assume people use SQS are running their K8s clusters on AWS EC2 instances. From within the cluster to access AWS resources (like SQS), there's another way to do it with kiam (https://github.com/uswitch/kiam) or kube2iam instead of using a long lived credential stored in k8s secret, I implemented the SQS event source by using kiam (https://github.com/whynowy/eventing-sources/commits/develop), I think it would be better to support both ways, what do you think?

As I know, a lot of people are using kiam to do delegated access to AWS resources, which is much more secure than using a stored credential. The approach of using secret is not going to be approved by the security team in my company.

@srvaroa
Copy link
Copy Markdown
Contributor Author

srvaroa commented Nov 29, 2018

Hi @whynowy thanks for the review. I agree that also having support for kiam would be good. Since it doesn't replace the secret-based approach (which covers also non AWS environments) I would add that support in a separate PR after this one is in (happy to do it myself or help out). WDYT? (cc @Harwayne @vaikas-google)

Comment thread pkg/adapter/awssqs/adapter.go Outdated
Comment thread pkg/adapter/awssqs/adapter.go Outdated
Comment thread pkg/controller/awssqs/reconcile.go
@Harwayne
Copy link
Copy Markdown
Contributor

Hi @whynowy thanks for the review. I agree that also having support for kiam would be good. Since it doesn't replace the secret-based approach (which covers also non AWS environments) I would add that support in a separate PR after this one is in (happy to do it myself or help out). WDYT? (cc @Harwayne @vaikas-google)

I don't know enough about SQS to have an informed opinion. In general, I think this PR is looking pretty good and can get in soon, so my preference is to add the kiam support in a subsequent PR, rather than slow this one down. But, as I said, I don't know how important kiam support is.

@srvaroa
Copy link
Copy Markdown
Contributor Author

srvaroa commented Nov 29, 2018

@Harwayne IAM is a better solution, but valid only if you're running your k8s cluster in AWS. The solution proposed here based on secrets would work regardless of where the k8s cluster runs (AWS included - I went down this route because I'm using GKE + and minikube for dev). The downside is that it's less secure (you're spreading secrets around, if an attacker gets access to the k8s secrets that store the values they could use them to consume from the queue.)

I think kiam support is important for the reasons @whynowy points out so I think it's a very desirable addition. I can work on this shortly after.

Signed-off-by: Galo Navarro <anglorvaroa@gmail.com>
Signed-off-by: Galo Navarro <anglorvaroa@gmail.com>
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Dec 5, 2018
This was needed in all types following a bump to /pkg, so the new type
needs it too.

See rev 9741f15

Signed-off-by: Galo Navarro <anglorvaroa@gmail.com>
@srvaroa
Copy link
Copy Markdown
Contributor Author

srvaroa commented Dec 5, 2018

@Harwayne there was a small change to the type tests required after the bump to /pkg which I forgot to add to the type. The change is simply applying the same fix to the newly added type and this should make tests pass now (needs the lgtm though)

@Harwayne
Copy link
Copy Markdown
Contributor

Harwayne commented Dec 5, 2018

/lgtm

And thanks for not rebasing! It made it much easier to see what changed 😄

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 5, 2018
@Harwayne
Copy link
Copy Markdown
Contributor

Harwayne commented Dec 5, 2018

/ok-to-test

@knative-prow-robot knative-prow-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 5, 2018
Signed-off-by: Galo Navarro <anglorvaroa@gmail.com>
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Dec 5, 2018
@srvaroa
Copy link
Copy Markdown
Contributor Author

srvaroa commented Dec 5, 2018

@Harwayne sorry, looks like it also needed an update-manifests (tests were passing locally so I didn't spot this)

Copy link
Copy Markdown
Contributor

@Harwayne Harwayne left a comment

Choose a reason for hiding this comment

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

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 5, 2018
@Harwayne
Copy link
Copy Markdown
Contributor

Harwayne commented Dec 5, 2018

/ok-to-test

@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Dec 6, 2018
Updated signature in getSinkURI + merge conflict in Gopkg.toml

Signed-off-by: Galo Navarro <anglorvaroa@gmail.com>
Signed-off-by: Galo Navarro <anglorvaroa@gmail.com>
@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-sources-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/adapter/awssqs/adapter.go Do not exist 54.1%
pkg/apis/sources/v1alpha1/aws_sqs_types.go Do not exist 100.0%

Copy link
Copy Markdown
Contributor

@grantr grantr left a comment

Choose a reason for hiding this comment

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

Thanks @srvaroa!

@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grantr, srvaroa

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

The pull request process is described here

Details 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-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 18, 2018
@grantr
Copy link
Copy Markdown
Contributor

grantr commented Dec 18, 2018

and sorry for the approval delay :(

@srvaroa
Copy link
Copy Markdown
Contributor Author

srvaroa commented Dec 18, 2018

Thanks @grantr, no worries! Let me know if there's anything else I should fix to enable merging (cc @Harwayne)

@grantr
Copy link
Copy Markdown
Contributor

grantr commented Dec 18, 2018

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 18, 2018
@whynowy
Copy link
Copy Markdown
Contributor

whynowy commented Dec 18, 2018

@srvaroa - one last request, please continue on the KIAM support :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants