Skip to content
This repository has been archived by the owner on Mar 28, 2020. It is now read-only.

cluster: add option to specify busybox repository #1928

Merged
merged 6 commits into from
Mar 6, 2018

Conversation

yehiyam
Copy link
Contributor

@yehiyam yehiyam commented Feb 17, 2018

cluster: add option to specify busybox repository
add 2 options in EtcdCluster.spec:
busyboxRepository. Defaults to "busybox"
busyboxVersion. Defaults to "1.28.0-glibc"

for #1927

add 2 options in EtcdCluster.spec:
busyboxRepository. Defaults to "busybox"
busyboxVersion. Defaults to "1.28.0-glibc"
@etcd-bot
Copy link
Collaborator

Can one of the admins verify this patch?

2 similar comments
@etcd-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@etcd-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@@ -99,6 +101,15 @@ type ClusterSpec struct {

// etcd cluster TLS configuration
TLS *TLSPolicy `json:"TLS,omitempty"`

// busybox:latest uses uclibc which contains a bug that sometimes prevents name resolution
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't bloat the top level spec.

I would suggest adding these to PodPolicy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hongchaodeng OK. I'll do that.
Any other suggestions while i'm on it?

Move definition to PodPolicy
Add unit-test
@hongchaodeng
Copy link
Member

hongchaodeng commented Feb 18, 2018

Since you changed the API, please also update the generated code: https://github.com/coreos/etcd-operator/blob/master/hack/k8s/codegen/README.md

After that I can enable the test on this PR.

@yehiyam
Copy link
Contributor Author

yehiyam commented Feb 18, 2018

@hongchaodeng Running the script did not change the generated code. Is it possible, or am I missing anything?

@hongchaodeng
Copy link
Member

What's the output of running the command?

@yehiyam
Copy link
Contributor Author

yehiyam commented Feb 18, 2018

Generating deepcopy funcs
Generating clientset for etcd:v1beta2 at github.com/coreos/etcd-operator/pkg/generated/clientset
Generating listers for etcd:v1beta2 at github.com/coreos/etcd-operator/pkg/generated/listers
Generating informers for etcd:v1beta2 at github.com/coreos/etcd-operator/pkg/generated/informers

@hongchaodeng
Copy link
Member

@etcd-bot ok to test

@hongchaodeng
Copy link
Member

hongchaodeng commented Feb 18, 2018

gofmt check failed:

gofmt checking failed:
/go/src/github.com/coreos/etcd-operator/pkg/util/k8sutil/k8sutils_test.go
diff -u /go/src/github.com/coreos/etcd-operator/pkg/util/k8sutil/k8sutils_test.go.orig /go/src/github.com/coreos/etcd-operator/pkg/util/k8sutil/k8sutils_test.go
--- /go/src/github.com/coreos/etcd-operator/pkg/util/k8sutil/k8sutils_test.go.orig	2018-02-18 21:16:38.840869766 +0000
+++ /go/src/github.com/coreos/etcd-operator/pkg/util/k8sutil/k8sutils_test.go	2018-02-18 21:16:38.840869766 +0000
@@ -1,23 +1,23 @@
 package k8sutil
 
 import (
-	"testing"
 	"fmt"
 	api "github.com/coreos/etcd-operator/pkg/apis/etcd/v1beta2"
+	"testing"
 )
 
 func TestDefaultBusyboxImageName(t *testing.T) {
 	policy := &api.PodPolicy{}
-	image:=ImageNameBusybox(policy)
-	expected:= fmt.Sprintf("%s:%v",defaultBusyboxRepository , defaultBusyboxVersion)
+	image := ImageNameBusybox(policy)
+	expected := fmt.Sprintf("%s:%v", defaultBusyboxRepository, defaultBusyboxVersion)
 	if image != expected {
 		t.Errorf("expect image=%s, get=%s", expected, image)
 	}
 }
 
 func TestDefaultNilBusyboxImageName(t *testing.T) {
-	image:=ImageNameBusybox(nil)
-	expected:= fmt.Sprintf("%s:%v",defaultBusyboxRepository , defaultBusyboxVersion)
+	image := ImageNameBusybox(nil)
+	expected := fmt.Sprintf("%s:%v", defaultBusyboxRepository, defaultBusyboxVersion)
 	if image != expected {
 		t.Errorf("expect image=%s, get=%s", expected, image)
 	}
@@ -25,12 +25,12 @@
 
 func TestSetBusyboxImageName(t *testing.T) {
 	policy := &api.PodPolicy{
-		BusyboxVersion:"1.3.2",
-		BusyboxRepository:"myRepo/busybox",
+		BusyboxVersion:    "1.3.2",
+		BusyboxRepository: "myRepo/busybox",
 	}
-	image:=ImageNameBusybox(policy)
-	expected:= fmt.Sprintf("%s:%v","myRepo/busybox" , "1.3.2")
+	image := ImageNameBusybox(policy)
+	expected := fmt.Sprintf("%s:%v", "myRepo/busybox", "1.3.2")
 	if image != expected {
 		t.Errorf("expect image=%s, get=%s", expected, image)
 	}
-}
\ No newline at end of file
+}

Copy link
Member

@hongchaodeng hongchaodeng left a comment

Choose a reason for hiding this comment

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

The code looks good. Just some minor nits.

Almost dismiss the update. Please ping me when you made the change again. Thanks!

@@ -143,6 +143,14 @@ type PodPolicy struct {
// etcd cluster.
// The "etcd.version" annotation is reserved for the internal use of the etcd operator.
Annotations map[string]string `json:"annotations,omitempty"`

// busybox:latest uses uclibc which contains a bug that sometimes prevents name resolution
Copy link
Member

Choose a reason for hiding this comment

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

Can you put these comment below on the BusyboxVersion comment? They are more related there.

@@ -66,7 +66,9 @@ const (
// AnnotationScope annotation name for defining instance scope. Used for specifing cluster wide clusters.
AnnotationScope = "etcd.database.coreos.com/scope"
//AnnotationClusterWide annotation value for cluster wide clusters.
AnnotationClusterWide = "clusterwide"
AnnotationClusterWide = "clusterwide"
defaultBusyboxRepository = "busybox"
Copy link
Member

Choose a reason for hiding this comment

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

Add a blank line between public and private var?

@@ -134,6 +136,21 @@ func ImageName(repo, version string) string {
return fmt.Sprintf("%s:v%v", repo, version)
}

func ImageNameBusybox(policy *api.PodPolicy) string {
Copy link
Member

Choose a reason for hiding this comment

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

Make this method private by uncapitalize it imageName...
It is not used outside this package.

@yehiyam
Copy link
Contributor Author

yehiyam commented Mar 5, 2018

@hongchaodeng Fixed your comments.

@@ -143,6 +143,14 @@ type PodPolicy struct {
// etcd cluster.
// The "etcd.version" annotation is reserved for the internal use of the etcd operator.
Annotations map[string]string `json:"annotations,omitempty"`

// busybox init container repository. default is busybox
BusyboxRepository string `json:"busyboxRepository,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Sorry to bother gain.
But after a second though, it would be better and easier to combine BusyboxRepository and BusyboxVersion into one field, e.g. BusyboxImage. Default to "busybox:1.28.0-glibc".

@yehiyam
Copy link
Contributor Author

yehiyam commented Mar 5, 2018 via email

@hongchaodeng
Copy link
Member

as it is the same as the etcd image and tag.

The etcd image is a special case. We expect that most of time users would only upgrade versions, aka tags. But that's not the case here.

@yehiyam
Copy link
Contributor Author

yehiyam commented Mar 5, 2018 via email

@hongchaodeng
Copy link
Member

LGTM

@hongchaodeng
Copy link
Member

@fanminshi @hasbro17
Can one of you also review and then merge this?

func imageNameBusybox(policy *api.PodPolicy) string {
// set defaults for busybox init container
image := defaultBusyboxImage

Copy link
Contributor

Choose a reason for hiding this comment

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

no need to have a newline here.
also is the following simpler?

if policy != nil && len(policy.BusyboxImage) > 0 {
		return policy.BusyboxImage
}
return defaultBusyboxImage

@@ -134,6 +136,16 @@ func ImageName(repo, version string) string {
return fmt.Sprintf("%s:v%v", repo, version)
}

func imageNameBusybox(policy *api.PodPolicy) string {
// set defaults for busybox init container
Copy link
Contributor

@fanminshi fanminshi Mar 5, 2018

Choose a reason for hiding this comment

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

move the comment on top of imageNameBusybox?
and change the comment to be imageNameBusybox sets the default image for busybox init container

@yehiyam
Copy link
Contributor Author

yehiyam commented Mar 6, 2018

@fanminshi Updated the PR.

@fanminshi
Copy link
Contributor

lgtm

@herikwebb
Copy link

@yehiyam @hongchaodeng are there any examples on how to use this to pass in an alternate repo for busybox?

@yehiyam
Copy link
Contributor Author

yehiyam commented Jul 15, 2019

@herikwebb you can look at an example in our helm chart

@herikwebb
Copy link

@yehiyam great, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants