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

[WIP][DNM][RFC] Create a unified binary and container image #273

Merged
merged 3 commits into from
Apr 10, 2019

Conversation

phlogistonjohn
Copy link
Contributor

Creating a unified binary and container image has come up a few times in conversations I've been involved with (generally in-person). I confirmed this was still something on the table with @travisn but it might be nice if you could confirm @rootfs.

Regardless, the PR is the start of a single image and binary. Currently, this only adds the new unified version and leaves the current items as-is. This is mainly to start the discussion and the final version would remove them.

Some points I'd like to discuss:

  • Currently a cli switch must be provided to select between rbd and cephfs. I was wondering it it would be nicer to select mode (also) by "argv 0" and have symlinks to the binary under the previous names such that the new binary can behave similarly to the old split binaries
  • Since this is early its a good time to "bikeshed" any of the naming
  • Does the "CEPH_VERSION" env var in the Dockerfile do anything? If not should it be removed?

Makefile Outdated Show resolved Hide resolved
cmd/cephcsi.go Outdated
@@ -0,0 +1,113 @@
/*
Copyright 2018 The Kubernetes Authors.
Copy link
Member

Choose a reason for hiding this comment

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

2019

cmd/cephcsi.go Outdated

func getDriverName() string {
// was explicitly passed a driver name
if *driverName != "" {
Copy link
Member

Choose a reason for hiding this comment

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

if driver != nil && len(*drivername) != 0

Copy link
Contributor Author

@phlogistonjohn phlogistonjohn Mar 27, 2019

Choose a reason for hiding this comment

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

I'll make these changes, but I'll like to understand why the preference of len(str) vs. direct comparision to "". Golang should optimize checking for the empty string, no?
The nil check I have no issues with.

cmd/cephcsi.go Outdated
return *driverName
}
// select driver name based on volume type
switch *vtype {
Copy link
Member

Choose a reason for hiding this comment

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

if vtype == nil {
  return nil
}

cmd/cephcsi.go Outdated
}

func main() {
if *vtype == "" {
Copy link
Member

Choose a reason for hiding this comment

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

if vtype == nil || len(*vtype) == 0

cmd/cephcsi.go Outdated
klog.Fatalln(err) // calls exit
}

switch *vtype {
Copy link
Member

Choose a reason for hiding this comment

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

switch dnam makes more sense based on the context

Copy link
Contributor

Choose a reason for hiding this comment

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

dname can be user specified as well, hence switching on the same may not be the right thing to do.

@rootfs
Copy link
Member

rootfs commented Mar 21, 2019

also need to add the image to deploy.sh

@@ -0,0 +1,17 @@

FROM centos:7
Copy link
Member

Choose a reason for hiding this comment

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

Why not using ceph/ceph image instead? See: https://hub.docker.com/r/ceph/ceph/tags

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would be happy to make that change if other ceph-csi experts agree. @rootfs @ShyamsundarR @gman0 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@Lseb I like the general idea, but an unaware if the ceph/ceph image is unduly bigger than what we require in this case.

This image needs "ceph-common kmod ceph-fuse attr e2fsprogs xfsprogs rbd-nbd" as in the yum install below.

The ceph/ceph image seems to contain iSCSI, NFS Ganesha etc, which are not needed in this case.

Also, the image size is ~228MB as compared to the current ceph-csi images running at ~150MB (just pointing it out, not attempting to save bits and bytes at these sizes yet).

The ceph image is better from an operational standpoint, as ensuring it has the right dependencies is done by the image itself, hence more apt to use the same.

The above is what I notice, @leseb your thoughts on these and if they matter much?

Copy link
Member

Choose a reason for hiding this comment

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

@ShyamsundarR the image size, as well as the unnecessary packages, are a valid point. However, it doesn't hurt much, I'm just trying to avoid using home-made images that could use wrong sources. The images we build on ceph/ceph are Ceph's official image, supported and maintained by the Ceph team.

I just realized that our current image does not contain rbd-nbd and ceph-fuse, this can be easily fixed but I don't want to hold to PR for that. We can still fix this later.

Btw why do we need rbd-nbd, AFAIK we don't use NBD but KRBD, can someone clarify? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

@ShyamsundarR the image size, as well as the unnecessary packages, are a valid point. However, it doesn't hurt much, I'm just trying to avoid using home-made images that could use wrong sources. The images we build on ceph/ceph are Ceph's official image, supported and maintained by the Ceph team.

I agree, the extra size does not really bother me, also staying on the official image is the right option.

I just realized that our current image does not contain rbd-nbd and ceph-fuse, this can be easily fixed but I don't want to hold to PR for that. We can still fix this later.

Btw why do we need rbd-nbd, AFAIK we don't use NBD but KRBD, can someone clarify? Thanks!

NBD can be used via a mounter option provided, and so we support it. I am not sure about why we do and if we should carry it forward, but possibly a different discussion. As you have started the process of including it in the Ceph official image, it should be good for now.

Copy link

Choose a reason for hiding this comment

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

ceph/ceph-container#1337 has just recently merged, which should allow us to use ceph/ceph as a base.

Copy link
Member

Choose a reason for hiding this comment

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

Not yet, we haven't built the image yet.

deploy/cephcsi/image/Dockerfile Outdated Show resolved Hide resolved
deploy/cephcsi/image/Dockerfile Outdated Show resolved Hide resolved
deploy/cephcsi/image/Dockerfile Outdated Show resolved Hide resolved
Copy link
Contributor

@ShyamsundarR ShyamsundarR left a comment

Choose a reason for hiding this comment

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

Broadly, I am fine with the naming and changes.

You did mention that based on the binary name the appropriate mode can be selected, I wonder how we could do that when the docker file expects an ENTRYPOINT anyway, and that is going to be common. I like the idea, but am possibly missing how we would achieve the same.

cmd/cephcsi.go Outdated
klog.Fatalln(err) // calls exit
}

switch *vtype {
Copy link
Contributor

Choose a reason for hiding this comment

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

dname can be user specified as well, hence switching on the same may not be the right thing to do.

@phlogistonjohn
Copy link
Contributor Author

Broadly, I am fine with the naming and changes.

You did mention that based on the binary name the appropriate mode can be selected, I wonder how we could do that when the docker file expects an ENTRYPOINT anyway, and that is going to be common. I like the idea, but am possibly missing how we would achieve the same.

I didn't actually implement that in this version but I'll do so to demonstrate what I mean and then I'll remove it if no-one likes that version. As for providing both... I think as long as our order of precedence is clear it shouldn't be much of an issue.

@phlogistonjohn
Copy link
Contributor Author

I've updated the series to include switching on the name of the binary as well as most of the other suggestions made. To demonstrate, I now create symlinks within the unified container image and copy the binary to the "old" names in the split images.

I didn't change the base of the image as @leseb suggested yet because I wanted to get some buy-in from others before I did that. It would be a good change IMO though.

@leseb @Madhu-1 @rootfs @ShyamsundarR PTAL

deploy/cephcsi/image/Dockerfile Outdated Show resolved Hide resolved
@humblec
Copy link
Collaborator

humblec commented Apr 3, 2019

@phlogistonjohn @leseb IMO, we should not remove individual targets like rbdplugin or cephfsplugin from makefile , rather keep it as it is for someone who want to make a target separately for his requirement. It could be that, one want to only experiment one of it. Its good to have a seperate target in makefile for common binary which can be used for achieving the goal mentioned in the PR.. Thoughts ?

@ktdreyer
Copy link
Member

ktdreyer commented Apr 3, 2019

@humblec , I think that would mean extra "experimental" code that could rot over time, because it will not be in the path that QE tests regularly.


var (
// common flags
vtype = flag.String("type", "", "driver type [rbd|cephfs]")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to update the deployment templates for this one, and also the files in deploy folder for new flags

is this a breaking change? because once PR is merged new image will be pushed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eventually yes, but I didn't plan to immediately deprecate the "split" images. Only new templates would be needed after the image was ready. I wasn't going to do that in this PR.

Create a single binary that can start ceph-csi in either rbd
or cephfs mode.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
@leseb leseb added the DNM DO NOT MERGE label Apr 9, 2019
Copy link
Member

@leseb leseb left a comment

Choose a reason for hiding this comment

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

One last thing :), the image has the packages too now.

deploy/cephcsi/image/Dockerfile Outdated Show resolved Hide resolved
Copy link
Contributor

@ShyamsundarR ShyamsundarR left a comment

Choose a reason for hiding this comment

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

Looks clean (other than DockerFile comments by @leseb ).

Just some queries, implementation looks fine.

cephfsplugin:
if [ ! -d ./vendor ]; then dep ensure -vendor-only; fi
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o _output/cephfsplugin ./cmd/cephfs
image-rbdplugin: cephcsi
Copy link
Contributor

Choose a reason for hiding this comment

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

(query) I would assume the targets image-rbdplugin and image-cephfsplugin would go away eventually, as noted here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah.


func getType() string {
if vtype == nil || len(*vtype) == 0 {
a0 := path.Base(os.Args[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

(query) In the end the command to execute maybe set using the container:command directive in kubernetes say, would that be right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's one way, there's also the args parameter. These changes "don't care" how the command is invoked, just that if it is invoked as the rbd or cephfs variant it uses that type as default.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add rules and variables to the Makefile so that the unified binary
and container image can be built.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
@phlogistonjohn
Copy link
Contributor Author

phlogistonjohn commented Apr 9, 2019

Updated version pushed to incorporate @leseb latest comment.

Folks, please help me get a checklist of what's an absolute blocker for this PR and what's nice to have. Once I resolve the blockers I can move this out of RFC state and I can move forward with additional follow-up prs for the nice-to-haves.
@ShyamsundarR @rootfs @Madhu-1

@ShyamsundarR
Copy link
Contributor

Updated version pushed to incorporate @leseb latest comment.

Folks, please help me get a checklist of what's an absolute blocker for this PR and what's nice to have. Once I resolve the blockers I can move this out of RFC state and I can move forward with additional follow-up prs for the nice-to-haves.
@ShyamsundarR @rootfs @Madhu-1

I have none, I am good as long as @leseb is good with the DockerFile

@leseb leseb removed the DNM DO NOT MERGE label Apr 10, 2019
@mergify mergify bot merged commit de94cb6 into ceph:csi-v1.0 Apr 10, 2019
@leseb
Copy link
Member

leseb commented Apr 10, 2019

Thanks @phlogistonjohn for your patience 👍

@Madhu-1
Copy link
Collaborator

Madhu-1 commented Apr 10, 2019

@leseb someone needs to pick this to master branch

@leseb
Copy link
Member

leseb commented Apr 10, 2019

@phlogistonjohn can you please cherry-pick this into the master branch?

@phlogistonjohn
Copy link
Contributor Author

@phlogistonjohn can you please cherry-pick this into the master branch?

Happy to do the work but not sure what needs to be done. Cherry-pick changes on top of master and then file a new PR for those?

@leseb
Copy link
Member

leseb commented Apr 10, 2019

@phlogistonjohn yes, checkout master, checkout a new branch, cherry-pick, send a PR against master.

@phlogistonjohn phlogistonjohn deleted the jjm-unified-build branch April 23, 2020 15:32
nixpanic pushed a commit to nixpanic/ceph-csi that referenced this pull request Mar 27, 2024
Syncing latest changes from upstream devel for ceph-csi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants