Skip to content

Instantly share code, notes, and snippets.

@yuvalif
Last active April 28, 2022 19:28
Show Gist options
  • Save yuvalif/e1766b75594a45dcdea8717bcc6f4525 to your computer and use it in GitHub Desktop.
Save yuvalif/e1766b75594a45dcdea8717bcc6f4525 to your computer and use it in GitHub Desktop.

Goal

Ceph is a distributed storage system that supports: block, file, and object storage. All types of storage use the RADOS backend storage system. S3 compliant object storage is provided by the Object Gateway (a.k.a. the RADOS Gateway or the RGW). Since we are S3 compliant, clients can connect to the RGW using standard client libraries provided by AWS. However, our bucket notification offering extends the functionality offerent by AWS. We have several examples of how to hack the standard AWS clients to use our extended bucket notifications APIs. Currently, we have such examples for python (using the boto3 library) - however, we need to keep them up to date with the recent changes in our code we are missing an example of how to hack the golang/java AWS SDK for the same purpose.

In this project we should:

  1. Python: make sure that all of the python (boto3 based) examples are up-to-date with the code
  2. Golang: extend the golang AWS SDK to include our bucket notification extensions. This was partially done as part of the Rook project but should be completed and moved to our go ceph library
  3. Java: similarly it should be done in the AWS Java SDK. This should be added as a new subdirectory in the ceph examples directory
  4. Documentation: Ceph's S3 client documentation should be updated

Evaluation Period

Try out Ceph

Install Linux

First, would be to have a Linux based development environment, as a minimum you would need an 8 CPU machine, with 16G RAM and 50GB disk.

Note that using a machine with a lower spec is also possible, but Ceph build time might take several hours

Unless you already have a Linux distro you like, I would recommend choosing from:

  • Fedora - my favorite (34 or higher)
  • Ubuntu (20.04 and up)
  • OpenSuse (Leap 15.2 or tumbleweed)

Using WSL on your Windows machine is also possible, but build times would be longer than running native Linux

Git

Once you have that up and running, you should clone the Ceph repo from Github (https://github.com/ceph/ceph). If you don’t know what Github and git are, this is the right time to close these gaps :-) And yes, you should have a Github account, so you can later share your work on the project.

Build

The repo has a readme file with instructions on how to build ceph - just follow these instructions and build it (depending on the amount of CPUs you have this may take a while). Our build system is based on cmake - so it is probably a good idea to know a little bit about that. Assuming the build was completed successfully, you can run the unit tests (see: https://github.com/ceph/ceph#running-unit-tests).

Try the RGW

Now you are ready to run the ceph processes, as explained here: https://github.com/ceph/ceph#running-a-test-cluster You probably would also like to check the developer guide (https://docs.ceph.com/docs/master/dev/developer_guide/) and learn more on how to build Ceph and run it locally (https://docs.ceph.com/docs/master/dev/quick_guide/). Would recommend running vstrat as following (from inside the build directory):

MON=1 OSD=1 MDS=0 MGR=0 RGW=1 ../src/vstart.sh -n -d

Assuming you have everything up and running, you can create a bucket in Ceph and upload an object to it. The best way for doing that is the s3cmd python command-line tool: https://github.com/s3tools/s3cmd Note that the tool is mainly geared towards AWS S3, so make sure to specify the location of the RGW as the endpoint, and the RGW credentials (as printed to the screen after running vstart.sh).

For example:

$ s3cmd --no-ssl --host=localhost:8000 --host-bucket="localhost:8000/%(bucket)" \
--access_key=0555b35654ad1656d804 \
--secret_key=h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q== \
mb s3://mybucket

Would create a bucket called mybucket in Ceph. And:

$ s3cmd --no-ssl --host=localhost:8000 --host-bucket="localhost:8000/%(bucket)" \
--access_key=0555b35654ad1656d804 \
--secret_key=h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q== \
put myimage.jpg s3://mybucket

Would put myimage.jpg into that bucket.

Try Bucket Notifications

Currently bucket notifications support sending messages to HTTP, AMQP and Kafka endpoints. To test bucket notifications over HTTP use:

  • assuming the local vstart cluster is already running
  • setup AWS CLI with RGW extensions according to this (note that this was tested only with aws cli v1). The s3cmd tool used above, does not have the notification related APIs, so we should use the AWS CLI tool here
  • start an HTTP server (which accepts POST messages) on port 10900 (or any other port, but then change the topic configuration below accordingly). you can use the following python server (note that you would need python 3 for this server):
wget https://gist.githubusercontent.com/mdonkers/63e115cc0c79b4f6b8b3a6b797e485c7/raw/a6a1d090ac8549dac8f2bd607bd64925de997d40/server.py
python server.py 10900
  • create a bucket notification topic with the above HTTP server as its endpoint:
aws --endpoint-url http://localhost:8000 sns create-topic --name=fishtopic \
  --attributes='{"push-endpoint": "http://localhost:10900"}'
  • create a bucket:
aws --endpoint-url http://localhost:8000 s3 mb s3://fish
  • create a bucket notification tying together the above topic and bucket:
aws --region=default --endpoint-url http://localhost:8000 s3api put-bucket-notification-configuration \
  --bucket fish \
  --notification-configuration='{"TopicConfigurations": [{"Id": "notif1", "TopicArn": "arn:aws:sns:default::fishtopic", "Events": []}]}'
  • create and upload a file to the bucket and make sure that the HTTP server got the notification
head -c 1024 </dev/urandom > myfile
aws --endpoint-url http://localhost:8000 s3 cp myfile s3://fish

Try the AWS Golang Client

Write a small golang app that uploads an object using the AWS golang SDK. Code should be submitted as a PR that:

  • add a directory called "golang" under ceph examples
  • add your code under that directory
  • add a README.md file that hold full instruction on how to build and run your example againts a vstart cluster

Try the AWS Java Client

Write a small Java app that uploads an object using the AWS Java SDK. Code should be submitted as a PR that:

  • add a directory called "java" under ceph examples
  • add your code under that directory
  • add a README.md file that hold full instruction on how to build and run your example againts a vstart cluster
@ydv-sahitya
Copy link

I'm on the fly right now with fedora35, no stress at all

well, that's what I was saying.

@Gre8t
Copy link

Gre8t commented Apr 12, 2022

Well, thank you @ydv-sahitya. If anybody's process keeps getting terminated, just increase your machine swap memory.

@E-Simiyu
Copy link

I get this error after running the script ./install-deps.sh

Running transaction test
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Transaction test error:
file /usr/share/man/man1/setup-nsssysinit.1.gz conflicts between attempted installs of nss-sysinit-3.77.0-1.fc35.x86_64 and nspr-devel-4.32.0-3.fc35.x86_64
file /usr/share/man/man5/cert9.db.5.gz conflicts between attempted installs of nss-3.77.0-1.fc35.x86_64 and nspr-devel-4.32.0-3.fc35.x86_64
file /usr/share/man/man5/key4.db.5.gz conflicts between attempted installs of nss-3.77.0-1.fc35.x86_64 and nspr-devel-4.32.0-3.fc35.x86_64
file /usr/share/man/man5/pkcs11.txt.5.gz conflicts between attempted installs of nss-3.77.0-1.fc35.x86_64 and nspr-devel-4.32.0-3.fc35.x86_64
file /usr/share/man/man1/nss-config.1.gz conflicts between attempted installs of nss-devel-3.77.0-1.fc35.x86_64 and nspr-devel-4.32.0-3.fc35.x86_64

@ydv-sahitya
Copy link

I get this error after running the script ./install-deps.sh

Running transaction test The downloaded packages were saved in cache until the next successful transaction. You can remove cached packages by executing 'dnf clean packages'. Error: Transaction test error: file /usr/share/man/man1/setup-nsssysinit.1.gz conflicts between attempted installs of nss-sysinit-3.77.0-1.fc35.x86_64 and nspr-devel-4.32.0-3.fc35.x86_64 file /usr/share/man/man5/cert9.db.5.gz conflicts between attempted installs of nss-3.77.0-1.fc35.x86_64 and nspr-devel-4.32.0-3.fc35.x86_64 file /usr/share/man/man5/key4.db.5.gz conflicts between attempted installs of nss-3.77.0-1.fc35.x86_64 and nspr-devel-4.32.0-3.fc35.x86_64 file /usr/share/man/man5/pkcs11.txt.5.gz conflicts between attempted installs of nss-3.77.0-1.fc35.x86_64 and nspr-devel-4.32.0-3.fc35.x86_64 file /usr/share/man/man1/nss-config.1.gz conflicts between attempted installs of nss-devel-3.77.0-1.fc35.x86_64 and nspr-devel-4.32.0-3.fc35.x86_64

so did you execute this dnf clean packages ? did you tried again ./install-deps.sh? are you getting the same error?

@E-Simiyu
Copy link

Yes I executed both commands but the error is still there

@Ochuwa-sophie
Copy link

I'm on the fly right now with fedora35, no stress at all

well, that's what I was saying.

Ubuntu works fine for me

@Ochuwa-sophie
Copy link

Please how do I interact with ceph using golang? Anyone has resources I can use?

@yuvalif
Copy link
Author

yuvalif commented Apr 13, 2022

Please how do I interact with ceph using golang? Anyone has resources I can use?

the AWS golang SDK should work with AWS and with Ceph in similar ways.
the main difference would be that you will have to specify the right endpoint (which is where vstart is running the rados gateway)
and the right credentials that vstart is creating for a user

@miracle1504
Copy link

hi @yuvalif, It wasn't easy setting this up. I think it would be easier for other applicant if we can add this to the note RGW=1 ../src/vstart.sh --debug --new -x --localhost --bluestore. The command enables RadosGatway on a vstart cluster

@miracle1504
Copy link

Also, AWS CLI should be V1

@yuvalif
Copy link
Author

yuvalif commented Apr 14, 2022

Also, AWS CLI should be V1

thanks @miracle1504
will update the gist on both things!

@miracle1504
Copy link

Thank you @yuvalif . I see the changes has been implemented with additional information.This would make it easier for a lot of applicants.

@miracle1504
Copy link

Hi @yuvalif , I want to ask a dumb question. If the golang sdk is extended do we create a golang AWS CLI extension, or do we just use the existing extension in boto3?

@yuvalif
Copy link
Author

yuvalif commented Apr 15, 2022

@miracle1504 the AWS CLI is based on boto3 (AWS python SDK).
so, this is unrelated to any work done on the golang SDK.
BTW, we already extended the boto3 SDK, as it has a much easier mechanism to do that that does not require writing code

@Elmaurdehni
Copy link

Please i am facing a problem building Ceph. First I was using Ubuntu 20 after the cloning it was left for me to run the build command I realized I keep getting fatal error, so I decided to used fedora it works pretty good but while running the build command it run at one point stop the terminal in which I was running it can't been seen. I tried removing the build and run the same thing keep happening. Please I need help

@miracle1504
Copy link

miracle1504 commented Apr 15, 2022

This is a classic out of memory issue.
To solve this issue you have to do either of these:
1.) Limit the amount of cpu used for building. Each cpu core takes about 2.5 gigs of ram (do the maths to know how many cores you would use for the build). Use the -j flag with the number of cpu as argument to do this.
2.) Increase your swap memory temporarily.

@Elmaurdehni

@miracle1504
Copy link

@miracle1504 the AWS CLI is based on boto3 (AWS python SDK). so, this is unrelated to any work done on the golang SDK. BTW, we already extended the boto3 SDK, as it has a much easier mechanism to do that that does not require writing code

Thank you. This cleared all confusion.

@Elmaurdehni
Copy link

Thank you so much let me work on it

@Ochuwa-sophie
Copy link

Please how do I interact with ceph using golang? Anyone has resources I can use?

the AWS golang SDK should work with AWS and with Ceph in similar ways. the main difference would be that you will have to specify the right endpoint (which is where vstart is running the rados gateway) and the right credentials that vstart is creating for a user

thanks done.

@miracle1504
Copy link

miracle1504 commented Apr 20, 2022

hi @yuvalif kindly review my code

@miracle1504
Copy link

@yuvalif I am quite confused at this statement
Golang: extend the [golang AWS SDK](https://github.com/aws/aws-sdk-go) to include our bucket notification extensions. This was partially done as part of the [Rook project](https://github.com/rook/rook/blob/master/pkg/operator/ceph/object/notification/s3ext.go) but should be completed and moved to our [go ceph](https://github.com/ceph/go-ceph) library.

Are we not supposed to make ceph-go support putBucketNotification instead, because aws-golang-sdk already supports putBucketNotification?

@miracle1504
Copy link

hi @yuvalif is there any community specific question we should answer as we submit our final application.

@ydv-sahitya
Copy link

hi @yuvalif is there any community specific question we should answer as we submit our final application.

@yuvalif sir is on vacation for a week.so I do not think he will answer you.

@IshikaMeghaSaha
Copy link

Also do we need to submit a timeline?

@Ochuwa-sophie
Copy link

@yuvalif I am quite confused at this statement Golang: extend the [golang AWS SDK](https://github.com/aws/aws-sdk-go) to include our bucket notification extensions. This was partially done as part of the [Rook project](https://github.com/rook/rook/blob/master/pkg/operator/ceph/object/notification/s3ext.go) but should be completed and moved to our [go ceph](https://github.com/ceph/go-ceph) library.

Are we not supposed to make ceph-go support putBucketNotification instead, because aws-golang-sdk already supports putBucketNotification?

Heyy, I am also applying to ceph but I will like to make a guess. I think what Yuvalif means is that we should actually make the Golang aws sdk support putBucketNotification.

@yuvalif
Copy link
Author

yuvalif commented Apr 23, 2022

@yuvalif I am quite confused at this statement Golang: extend the [golang AWS SDK](https://github.com/aws/aws-sdk-go) to include our bucket notification extensions. This was partially done as part of the [Rook project](https://github.com/rook/rook/blob/master/pkg/operator/ceph/object/notification/s3ext.go) but should be completed and moved to our [go ceph](https://github.com/ceph/go-ceph) library.

Are we not supposed to make ceph-go support putBucketNotification instead, because aws-golang-sdk already supports putBucketNotification?

they already implemented it, but are missing some extensions that were added to the API as part of Ceph
note that this is the actual project, and not part of the "evaluation period"

@yuvalif
Copy link
Author

yuvalif commented Apr 23, 2022

hi @yuvalif is there any community specific question we should answer as we submit our final application.

not sure what you mean by "community specific question"?

@yuvalif
Copy link
Author

yuvalif commented Apr 23, 2022

@yuvalif I am quite confused at this statement Golang: extend the [golang AWS SDK](https://github.com/aws/aws-sdk-go) to include our bucket notification extensions. This was partially done as part of the [Rook project](https://github.com/rook/rook/blob/master/pkg/operator/ceph/object/notification/s3ext.go) but should be completed and moved to our [go ceph](https://github.com/ceph/go-ceph) library.
Are we not supposed to make ceph-go support putBucketNotification instead, because aws-golang-sdk already supports putBucketNotification?

Heyy, I am also applying to ceph but I will like to make a guess. I think what Yuvalif means is that we should actually make the Golang aws sdk support putBucketNotification.

please see: https://gist.github.com/yuvalif/e1766b75594a45dcdea8717bcc6f4525?permalink_comment_id=4142747#gistcomment-4142747

@Ochuwa-sophie
Copy link

Ok, thanks.

@yuvalif I am quite confused at this statement Golang: extend the [golang AWS SDK](https://github.com/aws/aws-sdk-go) to include our bucket notification extensions. This was partially done as part of the [Rook project](https://github.com/rook/rook/blob/master/pkg/operator/ceph/object/notification/s3ext.go) but should be completed and moved to our [go ceph](https://github.com/ceph/go-ceph) library.
Are we not supposed to make ceph-go support putBucketNotification instead, because aws-golang-sdk already supports putBucketNotification?

Heyy, I am also applying to ceph but I will like to make a guess. I think what Yuvalif means is that we should actually make the Golang aws sdk support putBucketNotification.

please see: https://gist.github.com/yuvalif/e1766b75594a45dcdea8717bcc6f4525?permalink_comment_id=4142747#gistcomment-4142747

@miracle1504
Copy link

@yuvalif I am quite confused at this statement Golang: extend the [golang AWS SDK](https://github.com/aws/aws-sdk-go) to include our bucket notification extensions. This was partially done as part of the [Rook project](https://github.com/rook/rook/blob/master/pkg/operator/ceph/object/notification/s3ext.go) but should be completed and moved to our [go ceph](https://github.com/ceph/go-ceph) library.
Are we not supposed to make ceph-go support putBucketNotification instead, because aws-golang-sdk already supports putBucketNotification?

they already implemented it, but are missing some extensions that were added to the API as part of Ceph note that this is the actual project, and not part of the "evaluation period"

Ok, thank you!

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