-
Notifications
You must be signed in to change notification settings - Fork 740
[WIP] *: Add initial PersistentVolume feature #1349
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: "etcd.database.coreos.com/v1beta2" | ||
kind: "EtcdCluster" | ||
metadata: | ||
name: "example-etcd-cluster" | ||
spec: | ||
size: 3 | ||
version: "3.1.8" | ||
pod: | ||
usePV: true | ||
pvPolicy: | ||
volumeSizeInMB: 1024 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,10 @@ function e2e_pass { | |
|
||
# Run all the tests by default | ||
E2E_TEST_SELECTOR=${E2E_TEST_SELECTOR:-.*} | ||
go test "./test/e2e/" -run "$E2E_TEST_SELECTOR" -timeout 30m --race --kubeconfig $KUBECONFIG --operator-image $OPERATOR_IMAGE --namespace ${TEST_NAMESPACE} | ||
# Run tests with PV support disabled | ||
go test -v "./test/e2e/" -run "$E2E_TEST_SELECTOR" -timeout 30m --race --kubeconfig $KUBECONFIG --operator-image $OPERATOR_IMAGE --namespace ${TEST_NAMESPACE} | ||
# Run tests with PV support enabled | ||
PV_TEST=true go test -v "./test/e2e/" -run "$E2E_TEST_SELECTOR" -timeout 30m --race --kubeconfig $KUBECONFIG --operator-image $OPERATOR_IMAGE --namespace ${TEST_NAMESPACE} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of changing all the test functions to use a common function that accept a |
||
} | ||
|
||
function e2eslow_pass { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,8 @@ import ( | |
const ( | ||
defaultBaseImage = "quay.io/coreos/etcd" | ||
defaultVersion = "3.1.8" | ||
|
||
minPVSize = 512 // 512MiB | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a sane min size default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems ok |
||
) | ||
|
||
var ( | ||
|
@@ -154,6 +156,14 @@ type PodPolicy struct { | |
// bootstrap the cluster (for example `--initial-cluster` flag). | ||
// This field cannot be updated. | ||
EtcdEnv []v1.EnvVar `json:"etcdEnv,omitempty"` | ||
|
||
UsePV bool `json:"usePV,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kill this bool? we can check if PVPolicy is empty. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that was just one idea: use a bool to enable PV usage and the user could leave an nil PVPolicy (that will use the default VolumeSizeInMB value). Removing it will require users to always set PVPolicy.VolumeSizeInMB but I think it's not so complicated from the user perspective. |
||
PVPolicy *PVPolicy `json:"pvPolicy,omitempty"` | ||
} | ||
|
||
type PVPolicy struct { | ||
// VolumeSizeInMB specifies the required volume size for storing etcd data. | ||
VolumeSizeInMB int `json:"volumeSizeInMB"` | ||
} | ||
|
||
func (c *ClusterSpec) Validate() error { | ||
|
@@ -182,6 +192,11 @@ func (c *ClusterSpec) Validate() error { | |
return errors.New("spec: pod labels contains reserved label") | ||
} | ||
} | ||
if c.Pod.UsePV && c.Pod.PVPolicy != nil { | ||
if c.Pod.PVPolicy.VolumeSizeInMB < minPVSize { | ||
return fmt.Errorf("spec: pod pv volume size lesser than min size (%dMiB)", minPVSize) | ||
} | ||
} | ||
} | ||
return nil | ||
} | ||
|
@@ -198,6 +213,10 @@ func (c *ClusterSpec) Cleanup() { | |
} | ||
|
||
c.Version = strings.TrimLeft(c.Version, "v") | ||
|
||
if c.Pod.UsePV && c.Pod.PVPolicy == nil { | ||
c.Pod.PVPolicy = &PVPolicy{VolumeSizeInMB: minPVSize} | ||
} | ||
} | ||
|
||
type ClusterPhase string | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,10 @@ func (m *Member) PeerURL() string { | |
return fmt.Sprintf("%s://%s:2380", m.peerScheme(), m.FQDN()) | ||
} | ||
|
||
func (m *Member) PVCName() string { | ||
return fmt.Sprintf("%s-pvc", m.Name) | ||
} | ||
|
||
type MemberSet map[string]*Member | ||
|
||
func NewMemberSet(ms ...*Member) MemberSet { | ||
|
@@ -188,3 +192,11 @@ func clusterNameFromMemberName(mn string) string { | |
} | ||
return mn[:i] | ||
} | ||
|
||
func MemberNameFromPVCName(pn string) string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doc string. |
||
i := strings.LastIndex(pn, "-") | ||
if i == -1 { | ||
panic(fmt.Sprintf("unexpected pvc name: %s", pn)) | ||
} | ||
return pn[:i] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a proposed spec. I put it under the PodPolicy but I'm not sure about its location. I'm also not sure about the
usePV
bool name and the related pvPolicy. I'm open for any better idea.