diff --git a/pkg/api/testing/fuzzer.go b/pkg/api/testing/fuzzer.go index 47d16662230..3fa1d38a2a3 100644 --- a/pkg/api/testing/fuzzer.go +++ b/pkg/api/testing/fuzzer.go @@ -173,7 +173,7 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer { func(vs *api.VolumeSource, c fuzz.Continue) { // Exactly one of the fields should be set. //FIXME: the fuzz can still end up nil. What if fuzz allowed me to say that? - fuzzOneOf(c, &vs.HostPath, &vs.EmptyDir, &vs.GCEPersistentDisk, &vs.AWSPersistentDisk, &vs.GitRepo, &vs.Secret, &vs.NFS, &vs.ISCSI, &vs.Glusterfs) + fuzzOneOf(c, &vs.HostPath, &vs.EmptyDir, &vs.GCEPersistentDisk, &vs.AWSElasticBlockStore, &vs.GitRepo, &vs.Secret, &vs.NFS, &vs.ISCSI, &vs.Glusterfs) }, func(d *api.DNSPolicy, c fuzz.Continue) { policies := []api.DNSPolicy{api.DNSClusterFirst, api.DNSDefault} diff --git a/pkg/api/types.go b/pkg/api/types.go index 4ffd694e134..5fa63618649 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -189,9 +189,9 @@ type VolumeSource struct { // GCEPersistentDisk represents a GCE Disk resource that is attached to a // kubelet's host machine and then exposed to the pod. GCEPersistentDisk *GCEPersistentDiskVolumeSource `json:"gcePersistentDisk"` - // AWSPersistentDisk represents a AWS EBS disk that is attached to a + // AWSElasticBlockStore represents a AWS EBS disk that is attached to a // kubelet's host machine and then exposed to the pod. - AWSPersistentDisk *AWSPersistentDiskVolumeSource `json:"awsPersistentDisk"` + AWSElasticBlockStore *AWSElasticBlockStoreVolumeSource `json:"awsElasticBlockStore"` // GitRepo represents a git repository at a particular revision. GitRepo *GitRepoVolumeSource `json:"gitRepo"` // Secret represents a secret that should populate this volume. @@ -211,9 +211,9 @@ type PersistentVolumeSource struct { // GCEPersistentDisk represents a GCE Disk resource that is attached to a // kubelet's host machine and then exposed to the pod. GCEPersistentDisk *GCEPersistentDiskVolumeSource `json:"gcePersistentDisk"` - // AWSPersistentDisk represents a AWS EBS disk that is attached to a + // AWSElasticBlockStore represents a AWS EBS disk that is attached to a // kubelet's host machine and then exposed to the pod. - AWSPersistentDisk *AWSPersistentDiskVolumeSource `json:"awsPersistentDisk"` + AWSElasticBlockStore *AWSElasticBlockStoreVolumeSource `json:"awsElasticBlockStore"` // HostPath represents a directory on the host. // This is useful for development and testing only. // on-host storage is not supported in any way @@ -400,12 +400,12 @@ type ISCSIVolumeSource struct { ReadOnly bool `json:"readOnly,omitempty"` } -// AWSPersistentDiskVolumeSource represents a Persistent Disk resource in AWS. +// AWSElasticBlockStoreVolumeSource represents a Persistent Disk resource in AWS. // // An AWS EBS disk must exist and be formatted before mounting to a container. // The disk must also be in the same AWS zone as the kubelet. // A AWS EBS disk can only be mounted as read/write once. -type AWSPersistentDiskVolumeSource struct { +type AWSElasticBlockStoreVolumeSource struct { // Unique id of the persistent disk resource. Used to identify the disk in AWS VolumeId string `json:"volumeId"` // Required: Filesystem type to mount. diff --git a/pkg/api/v1beta1/conversion.go b/pkg/api/v1beta1/conversion.go index acce5370a1f..31219131d70 100644 --- a/pkg/api/v1beta1/conversion.go +++ b/pkg/api/v1beta1/conversion.go @@ -1170,7 +1170,7 @@ func init() { if err := s.Convert(&in.ISCSI, &out.ISCSI, 0); err != nil { return err } - if err := s.Convert(&in.AWSPersistentDisk, &out.AWSPersistentDisk, 0); err != nil { + if err := s.Convert(&in.AWSElasticBlockStore, &out.AWSElasticBlockStore, 0); err != nil { return err } if err := s.Convert(&in.HostPath, &out.HostDir, 0); err != nil { @@ -1200,7 +1200,7 @@ func init() { if err := s.Convert(&in.ISCSI, &out.ISCSI, 0); err != nil { return err } - if err := s.Convert(&in.AWSPersistentDisk, &out.AWSPersistentDisk, 0); err != nil { + if err := s.Convert(&in.AWSElasticBlockStore, &out.AWSElasticBlockStore, 0); err != nil { return err } if err := s.Convert(&in.HostDir, &out.HostPath, 0); err != nil { diff --git a/pkg/api/v1beta1/types.go b/pkg/api/v1beta1/types.go index 89e28c418b1..79192cf21dc 100644 --- a/pkg/api/v1beta1/types.go +++ b/pkg/api/v1beta1/types.go @@ -88,7 +88,7 @@ type Volume struct { // Source represents the location and type of a volume to mount. // This is optional for now. If not specified, the Volume is implied to be an EmptyDir. // This implied behavior is deprecated and will be removed in a future version. - Source VolumeSource `json:"source,omitempty" description:"location and type of volume to mount; at most one of HostDir, EmptyDir, GCEPersistentDisk, AWSPersistentDisk, or GitRepo; default is EmptyDir"` + Source VolumeSource `json:"source,omitempty" description:"location and type of volume to mount; at most one of HostDir, EmptyDir, GCEPersistentDisk, AWSElasticBlockStore, or GitRepo; default is EmptyDir"` } // VolumeSource represents the source location of a volume to mount. @@ -105,9 +105,9 @@ type VolumeSource struct { // GCEPersistentDisk represents a GCE Disk resource that is attached to a // kubelet's host machine and then exposed to the pod. GCEPersistentDisk *GCEPersistentDiskVolumeSource `json:"persistentDisk" description:"GCE disk resource attached to the host machine on demand"` - // AWSPersistentDisk represents a AWS Disk resource that is attached to a + // AWSElasticBlockStore represents a AWS Disk resource that is attached to a // kubelet's host machine and then exposed to the pod. - AWSPersistentDisk *AWSPersistentDiskVolumeSource `json:"awsPersistentDisk" description:"AWS disk resource attached to the host machine on demand"` + AWSElasticBlockStore *AWSElasticBlockStoreVolumeSource `json:"awsElasticBlockStore" description:"AWS disk resource attached to the host machine on demand"` // GitRepo represents a git repository at a particular revision. GitRepo *GitRepoVolumeSource `json:"gitRepo" description:"git repository at a particular revision"` // Secret represents a secret to populate the volume with @@ -127,9 +127,9 @@ type PersistentVolumeSource struct { // GCEPersistentDisk represents a GCE Disk resource that is attached to a // kubelet's host machine and then exposed to the pod. GCEPersistentDisk *GCEPersistentDiskVolumeSource `json:"persistentDisk" description:"GCE disk resource provisioned by an admin"` - // AWSPersistentDisk represents a AWS EBS volume that is attached to a + // AWSElasticBlockStore represents a AWS EBS volume that is attached to a // kubelet's host machine and then exposed to the pod. - AWSPersistentDisk *AWSPersistentDiskVolumeSource `json:"awsPersistentDisk" description:"AWS disk resource provisioned by an admin"` + AWSElasticBlockStore *AWSElasticBlockStoreVolumeSource `json:"awsElasticBlockStore" description:"AWS disk resource provisioned by an admin"` // HostPath represents a directory on the host. // This is useful for development and testing only. // on-host storage is not supported in any way. @@ -308,12 +308,12 @@ type ISCSIVolumeSource struct { ReadOnly bool `json:"readOnly,omitempty" description:"read-only if true, read-write otherwise (false or unspecified)"` } -// AWSPersistentDiskVolumeSource represents a Persistent Disk resource in AWS. +// AWSElasticBlockStoreVolumeSource represents a Persistent Disk resource in AWS. // // An AWS PD must exist and be formatted before mounting to a container. // The disk must also be in the same AWS zone as the kubelet. // A AWS PD can only be mounted on a single machine. -type AWSPersistentDiskVolumeSource struct { +type AWSElasticBlockStoreVolumeSource struct { // Unique id of the PD resource. Used to identify the disk in AWS VolumeId string `json:"volumeId" description:"unique id of the PD resource in AWS"` // Required: Filesystem type to mount. diff --git a/pkg/api/v1beta2/conversion.go b/pkg/api/v1beta2/conversion.go index 4d75080c4d3..6a0d75876da 100644 --- a/pkg/api/v1beta2/conversion.go +++ b/pkg/api/v1beta2/conversion.go @@ -1097,7 +1097,7 @@ func init() { if err := s.Convert(&in.GCEPersistentDisk, &out.GCEPersistentDisk, 0); err != nil { return err } - if err := s.Convert(&in.AWSPersistentDisk, &out.AWSPersistentDisk, 0); err != nil { + if err := s.Convert(&in.AWSElasticBlockStore, &out.AWSElasticBlockStore, 0); err != nil { return err } if err := s.Convert(&in.HostPath, &out.HostDir, 0); err != nil { diff --git a/pkg/api/v1beta2/types.go b/pkg/api/v1beta2/types.go index 5312acab062..1504a324ab0 100644 --- a/pkg/api/v1beta2/types.go +++ b/pkg/api/v1beta2/types.go @@ -55,7 +55,7 @@ type Volume struct { // Source represents the location and type of a volume to mount. // This is optional for now. If not specified, the Volume is implied to be an EmptyDir. // This implied behavior is deprecated and will be removed in a future version. - Source VolumeSource `json:"source,omitempty" description:"location and type of volume to mount; at most one of HostDir, EmptyDir, GCEPersistentDisk, AWSPersistentDisk, or GitRepo; default is EmptyDir"` + Source VolumeSource `json:"source,omitempty" description:"location and type of volume to mount; at most one of HostDir, EmptyDir, GCEPersistentDisk, AWSElasticBlockStore, or GitRepo; default is EmptyDir"` } // VolumeSource represents the source location of a volume to mount. @@ -76,7 +76,7 @@ type VolumeSource struct { GCEPersistentDisk *GCEPersistentDiskVolumeSource `json:"persistentDisk" description:"GCE disk resource attached to the host machine on demand"` // An AWS persistent disk that is mounted to the // kubelet's host machine and then exposed to the pod. - AWSPersistentDisk *AWSPersistentDiskVolumeSource `json:"awsPersistentDisk" description:"AWS disk resource attached to the host machine on demand"` + AWSElasticBlockStore *AWSElasticBlockStoreVolumeSource `json:"awsElasticBlockStore" description:"AWS disk resource attached to the host machine on demand"` // GitRepo represents a git repository at a particular revision. GitRepo *GitRepoVolumeSource `json:"gitRepo" description:"git repository at a particular revision"` // Secret is a secret to populate the volume with @@ -96,9 +96,9 @@ type PersistentVolumeSource struct { // GCEPersistentDisk represents a GCE Disk resource that is attached to a // kubelet's host machine and then exposed to the pod. GCEPersistentDisk *GCEPersistentDiskVolumeSource `json:"persistentDisk" description:"GCE disk resource provisioned by an admin"` - // AWSPersistentDisk represents a AWS Disk resource that is attached to a + // AWSElasticBlockStore represents a AWS Disk resource that is attached to a // kubelet's host machine and then exposed to the pod. - AWSPersistentDisk *AWSPersistentDiskVolumeSource `json:"awsPersistentDisk" description:"AWS disk resource provisioned by an admin"` + AWSElasticBlockStore *AWSElasticBlockStoreVolumeSource `json:"awsElasticBlockStore" description:"AWS disk resource provisioned by an admin"` // HostPath represents a directory on the host. // This is useful for development and testing only. // on-host storage is not supported in any way. @@ -290,12 +290,12 @@ type GCEPersistentDiskVolumeSource struct { ReadOnly bool `json:"readOnly,omitempty" description:"read-only if true, read-write otherwise (false or unspecified)"` } -// AWSPersistentDiskVolumeSource represents a Persistent Disk resource in AWS. +// AWSElasticBlockStoreVolumeSource represents a Persistent Disk resource in AWS. // // An AWS PD must exist and be formatted before mounting to a container. // The disk must also be in the same AWS zone as the kubelet. // A AWS PD can only be mounted on a single machine. -type AWSPersistentDiskVolumeSource struct { +type AWSElasticBlockStoreVolumeSource struct { // Unique id of the PD resource. Used to identify the disk in AWS VolumeId string `json:"volumeId" description:"unique id of the PD resource in AWS"` // Required: Filesystem type to mount. diff --git a/pkg/api/v1beta3/types.go b/pkg/api/v1beta3/types.go index 91d70b511f4..76d5070b313 100644 --- a/pkg/api/v1beta3/types.go +++ b/pkg/api/v1beta3/types.go @@ -206,9 +206,9 @@ type VolumeSource struct { // GCEPersistentDisk represents a GCE Disk resource that is attached to a // kubelet's host machine and then exposed to the pod. GCEPersistentDisk *GCEPersistentDiskVolumeSource `json:"gcePersistentDisk" description:"GCE disk resource attached to the host machine on demand"` - // AWSPersistentDisk represents a AWS Disk resource that is attached to a + // AWSElasticBlockStore represents a AWS Disk resource that is attached to a // kubelet's host machine and then exposed to the pod. - AWSPersistentDisk *AWSPersistentDiskVolumeSource `json:"awsPersistentDisk" description:"AWS disk resource attached to the host machine on demand"` + AWSElasticBlockStore *AWSElasticBlockStoreVolumeSource `json:"awsElasticBlockStore" description:"AWS disk resource attached to the host machine on demand"` // GitRepo represents a git repository at a particular revision. GitRepo *GitRepoVolumeSource `json:"gitRepo" description:"git repository at a particular revision"` // Secret represents a secret that should populate this volume. @@ -228,9 +228,9 @@ type PersistentVolumeSource struct { // GCEPersistentDisk represents a GCE Disk resource that is attached to a // kubelet's host machine and then exposed to the pod. GCEPersistentDisk *GCEPersistentDiskVolumeSource `json:"gcePersistentDisk" description:"GCE disk resource provisioned by an admin"` - // AWSPersistentDisk represents a AWS Disk resource that is attached to a + // AWSElasticBlockStore represents a AWS Disk resource that is attached to a // kubelet's host machine and then exposed to the pod. - AWSPersistentDisk *AWSPersistentDiskVolumeSource `json:"awsPersistentDisk" description:"AWS disk resource provisioned by an admin"` + AWSElasticBlockStore *AWSElasticBlockStoreVolumeSource `json:"awsElasticBlockStore" description:"AWS disk resource provisioned by an admin"` // HostPath represents a directory on the host. // This is useful for development and testing only. // on-host storage is not supported in any way. @@ -406,12 +406,12 @@ type GCEPersistentDiskVolumeSource struct { ReadOnly bool `json:"readOnly,omitempty" description:"read-only if true, read-write otherwise (false or unspecified)"` } -// AWSPersistentDiskVolumeSource represents a Persistent Disk resource in AWS. +// AWSElasticBlockStoreVolumeSource represents a Persistent Disk resource in AWS. // // An AWS PD must exist and be formatted before mounting to a container. // The disk must also be in the same AWS zone as the kubelet. // A AWS PD can only be mounted on a single machine. -type AWSPersistentDiskVolumeSource struct { +type AWSElasticBlockStoreVolumeSource struct { // Unique id of the PD resource. Used to identify the disk in AWS VolumeId string `json:"volumeId" description:"unique id of the PD resource in AWS"` // Required: Filesystem type to mount. diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index e75cf039627..ec571073185 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -299,9 +299,9 @@ func validateSource(source *api.VolumeSource) errs.ValidationErrorList { numVolumes++ allErrs = append(allErrs, validateGCEPersistentDiskVolumeSource(source.GCEPersistentDisk).Prefix("persistentDisk")...) } - if source.AWSPersistentDisk != nil { + if source.AWSElasticBlockStore != nil { numVolumes++ - allErrs = append(allErrs, validateAWSPersistentDiskVolumeSource(source.AWSPersistentDisk).Prefix("awsPersistentDisk")...) + allErrs = append(allErrs, validateAWSElasticBlockStoreVolumeSource(source.AWSElasticBlockStore).Prefix("awsElasticBlockStore")...) } if source.Secret != nil { numVolumes++ @@ -372,7 +372,7 @@ func validateGCEPersistentDiskVolumeSource(PD *api.GCEPersistentDiskVolumeSource return allErrs } -func validateAWSPersistentDiskVolumeSource(PD *api.AWSPersistentDiskVolumeSource) errs.ValidationErrorList { +func validateAWSElasticBlockStoreVolumeSource(PD *api.AWSElasticBlockStoreVolumeSource) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} if PD.VolumeId == "" { allErrs = append(allErrs, errs.NewFieldRequired("volumeId")) @@ -444,9 +444,9 @@ func ValidatePersistentVolume(pv *api.PersistentVolume) errs.ValidationErrorList numVolumes++ allErrs = append(allErrs, validateGCEPersistentDiskVolumeSource(pv.Spec.GCEPersistentDisk).Prefix("persistentDisk")...) } - if pv.Spec.AWSPersistentDisk != nil { + if pv.Spec.AWSElasticBlockStore != nil { numVolumes++ - allErrs = append(allErrs, validateAWSPersistentDiskVolumeSource(pv.Spec.AWSPersistentDisk).Prefix("awsPersistentDisk")...) + allErrs = append(allErrs, validateAWSElasticBlockStoreVolumeSource(pv.Spec.AWSElasticBlockStore).Prefix("awsElasticBlockStore")...) } if numVolumes != 1 { allErrs = append(allErrs, errs.NewFieldInvalid("", pv.Spec.PersistentVolumeSource, "exactly 1 volume type is required")) diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index a922befb34f..8eda725f2ba 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -516,7 +516,7 @@ func TestValidateVolumes(t *testing.T) { {Name: "abc-123", VolumeSource: api.VolumeSource{HostPath: &api.HostPathVolumeSource{"/mnt/path3"}}}, {Name: "empty", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}, {Name: "gcepd", VolumeSource: api.VolumeSource{GCEPersistentDisk: &api.GCEPersistentDiskVolumeSource{"my-PD", "ext4", 1, false}}}, - {Name: "awspd", VolumeSource: api.VolumeSource{AWSPersistentDisk: &api.AWSPersistentDiskVolumeSource{"my-PD", "ext4", 1, false}}}, + {Name: "awsebs", VolumeSource: api.VolumeSource{AWSElasticBlockStore: &api.AWSElasticBlockStoreVolumeSource{"my-PD", "ext4", 1, false}}}, {Name: "gitrepo", VolumeSource: api.VolumeSource{GitRepo: &api.GitRepoVolumeSource{"my-repo", "hashstring"}}}, {Name: "iscsidisk", VolumeSource: api.VolumeSource{ISCSI: &api.ISCSIVolumeSource{"127.0.0.1", "iqn.2015-02.example.com:test", 1, "ext4", false}}}, {Name: "secret", VolumeSource: api.VolumeSource{Secret: &api.SecretVolumeSource{"my-secret"}}}, diff --git a/pkg/scheduler/predicates.go b/pkg/scheduler/predicates.go index 3f8cca4a207..2257f63a9f7 100644 --- a/pkg/scheduler/predicates.go +++ b/pkg/scheduler/predicates.go @@ -61,13 +61,13 @@ func isVolumeConflict(volume api.Volume, pod *api.Pod) bool { } } } - if volume.AWSPersistentDisk != nil { - volumeId := volume.AWSPersistentDisk.VolumeId + if volume.AWSElasticBlockStore != nil { + volumeId := volume.AWSElasticBlockStore.VolumeId manifest := &(pod.Spec) for ix := range manifest.Volumes { - if manifest.Volumes[ix].AWSPersistentDisk != nil && - manifest.Volumes[ix].AWSPersistentDisk.VolumeId == volumeId { + if manifest.Volumes[ix].AWSElasticBlockStore != nil && + manifest.Volumes[ix].AWSElasticBlockStore.VolumeId == volumeId { return true } } diff --git a/pkg/scheduler/predicates_test.go b/pkg/scheduler/predicates_test.go index 42a72e126ec..c0fc518014a 100644 --- a/pkg/scheduler/predicates_test.go +++ b/pkg/scheduler/predicates_test.go @@ -326,7 +326,7 @@ func TestAWSDiskConflicts(t *testing.T) { Volumes: []api.Volume{ { VolumeSource: api.VolumeSource{ - AWSPersistentDisk: &api.AWSPersistentDiskVolumeSource{ + AWSElasticBlockStore: &api.AWSElasticBlockStoreVolumeSource{ VolumeId: "foo", }, }, @@ -337,7 +337,7 @@ func TestAWSDiskConflicts(t *testing.T) { Volumes: []api.Volume{ { VolumeSource: api.VolumeSource{ - AWSPersistentDisk: &api.AWSPersistentDiskVolumeSource{ + AWSElasticBlockStore: &api.AWSElasticBlockStoreVolumeSource{ VolumeId: "bar", }, }, diff --git a/pkg/volume/aws_pd/aws_pd.go b/pkg/volume/aws_pd/aws_pd.go index 7e4de7dc957..af46665047d 100644 --- a/pkg/volume/aws_pd/aws_pd.go +++ b/pkg/volume/aws_pd/aws_pd.go @@ -37,55 +37,55 @@ import ( // This is the primary entrypoint for volume plugins. func ProbeVolumePlugins() []volume.VolumePlugin { - return []volume.VolumePlugin{&awsPersistentDiskPlugin{nil}} + return []volume.VolumePlugin{&awsElasticBlockStorePlugin{nil}} } -type awsPersistentDiskPlugin struct { +type awsElasticBlockStorePlugin struct { host volume.VolumeHost } -var _ volume.VolumePlugin = &awsPersistentDiskPlugin{} +var _ volume.VolumePlugin = &awsElasticBlockStorePlugin{} const ( - awsPersistentDiskPluginName = "kubernetes.io/aws-pd" + awsElasticBlockStorePluginName = "kubernetes.io/aws-ebs" ) -func (plugin *awsPersistentDiskPlugin) Init(host volume.VolumeHost) { +func (plugin *awsElasticBlockStorePlugin) Init(host volume.VolumeHost) { plugin.host = host } -func (plugin *awsPersistentDiskPlugin) Name() string { - return awsPersistentDiskPluginName +func (plugin *awsElasticBlockStorePlugin) Name() string { + return awsElasticBlockStorePluginName } -func (plugin *awsPersistentDiskPlugin) CanSupport(spec *api.Volume) bool { - if spec.AWSPersistentDisk != nil { +func (plugin *awsElasticBlockStorePlugin) CanSupport(spec *api.Volume) bool { + if spec.AWSElasticBlockStore != nil { return true } return false } -func (plugin *awsPersistentDiskPlugin) GetAccessModes() []api.AccessModeType { +func (plugin *awsElasticBlockStorePlugin) GetAccessModes() []api.AccessModeType { return []api.AccessModeType{ api.ReadWriteOnce, } } -func (plugin *awsPersistentDiskPlugin) NewBuilder(spec *api.Volume, podRef *api.ObjectReference) (volume.Builder, error) { +func (plugin *awsElasticBlockStorePlugin) NewBuilder(spec *api.Volume, podRef *api.ObjectReference) (volume.Builder, error) { // Inject real implementations here, test through the internal function. return plugin.newBuilderInternal(spec, podRef.UID, &AWSDiskUtil{}, mount.New()) } -func (plugin *awsPersistentDiskPlugin) newBuilderInternal(spec *api.Volume, podUID types.UID, manager pdManager, mounter mount.Interface) (volume.Builder, error) { - volumeId := spec.AWSPersistentDisk.VolumeId - fsType := spec.AWSPersistentDisk.FSType +func (plugin *awsElasticBlockStorePlugin) newBuilderInternal(spec *api.Volume, podUID types.UID, manager pdManager, mounter mount.Interface) (volume.Builder, error) { + volumeId := spec.AWSElasticBlockStore.VolumeId + fsType := spec.AWSElasticBlockStore.FSType partition := "" - if spec.AWSPersistentDisk.Partition != 0 { - partition = strconv.Itoa(spec.AWSPersistentDisk.Partition) + if spec.AWSElasticBlockStore.Partition != 0 { + partition = strconv.Itoa(spec.AWSElasticBlockStore.Partition) } - readOnly := spec.AWSPersistentDisk.ReadOnly + readOnly := spec.AWSElasticBlockStore.ReadOnly - return &awsPersistentDisk{ + return &awsElasticBlockStore{ podUID: podUID, volName: spec.Name, volumeId: volumeId, @@ -99,13 +99,13 @@ func (plugin *awsPersistentDiskPlugin) newBuilderInternal(spec *api.Volume, podU }, nil } -func (plugin *awsPersistentDiskPlugin) NewCleaner(volName string, podUID types.UID) (volume.Cleaner, error) { +func (plugin *awsElasticBlockStorePlugin) NewCleaner(volName string, podUID types.UID) (volume.Cleaner, error) { // Inject real implementations here, test through the internal function. return plugin.newCleanerInternal(volName, podUID, &AWSDiskUtil{}, mount.New()) } -func (plugin *awsPersistentDiskPlugin) newCleanerInternal(volName string, podUID types.UID, manager pdManager, mounter mount.Interface) (volume.Cleaner, error) { - return &awsPersistentDisk{ +func (plugin *awsElasticBlockStorePlugin) newCleanerInternal(volName string, podUID types.UID, manager pdManager, mounter mount.Interface) (volume.Cleaner, error) { + return &awsElasticBlockStore{ podUID: podUID, volName: volName, manager: manager, @@ -118,14 +118,14 @@ func (plugin *awsPersistentDiskPlugin) newCleanerInternal(volName string, podUID // Abstract interface to PD operations. type pdManager interface { // Attaches the disk to the kubelet's host machine. - AttachAndMountDisk(pd *awsPersistentDisk, globalPDPath string) error + AttachAndMountDisk(pd *awsElasticBlockStore, globalPDPath string) error // Detaches the disk from the kubelet's host machine. - DetachDisk(pd *awsPersistentDisk) error + DetachDisk(pd *awsElasticBlockStore) error } -// awsPersistentDisk volumes are disk resources provided by Google Compute Engine +// awsElasticBlockStore volumes are disk resources provided by Google Compute Engine // that are attached to the kubelet's host machine and exposed to the pod. -type awsPersistentDisk struct { +type awsElasticBlockStore struct { volName string podUID types.UID // Unique id of the PD, used to find the disk resource in the provider. @@ -142,10 +142,10 @@ type awsPersistentDisk struct { mounter mount.Interface // diskMounter provides the interface that is used to mount the actual block device. diskMounter mount.Interface - plugin *awsPersistentDiskPlugin + plugin *awsElasticBlockStorePlugin } -func detachDiskLogError(pd *awsPersistentDisk) { +func detachDiskLogError(pd *awsElasticBlockStore) { err := pd.manager.DetachDisk(pd) if err != nil { glog.Warningf("Failed to detach disk: %v (%v)", pd, err) @@ -153,7 +153,7 @@ func detachDiskLogError(pd *awsPersistentDisk) { } // getVolumeProvider returns the AWS Volumes interface -func (pd *awsPersistentDisk) getVolumeProvider() (aws_cloud.Volumes, error) { +func (pd *awsElasticBlockStore) getVolumeProvider() (aws_cloud.Volumes, error) { name := "aws" cloud, err := cloudprovider.GetCloudProvider(name, nil) if err != nil { @@ -167,12 +167,12 @@ func (pd *awsPersistentDisk) getVolumeProvider() (aws_cloud.Volumes, error) { } // SetUp attaches the disk and bind mounts to the volume path. -func (pd *awsPersistentDisk) SetUp() error { +func (pd *awsElasticBlockStore) SetUp() error { return pd.SetUpAt(pd.GetPath()) } // SetUpAt attaches the disk and bind mounts to the volume path. -func (pd *awsPersistentDisk) SetUpAt(dir string) error { +func (pd *awsElasticBlockStore) SetUpAt(dir string) error { // TODO: handle failed mounts here. mountpoint, err := mount.IsMountPoint(dir) glog.V(4).Infof("PersistentDisk set up: %s %v %v", dir, mountpoint, err) @@ -236,11 +236,11 @@ func makeGlobalPDPath(host volume.VolumeHost, volumeId string) string { // Clean up the URI to be more fs-friendly name := volumeId name = strings.Replace(name, "://", "/", -1) - return path.Join(host.GetPluginDir(awsPersistentDiskPluginName), "mounts", name) + return path.Join(host.GetPluginDir(awsElasticBlockStorePluginName), "mounts", name) } func getVolumeIdFromGlobalMount(host volume.VolumeHost, globalPath string) (string, error) { - basePath := path.Join(host.GetPluginDir(awsPersistentDiskPluginName), "mounts") + basePath := path.Join(host.GetPluginDir(awsElasticBlockStorePluginName), "mounts") rel, err := filepath.Rel(basePath, globalPath) if err != nil { return "", err @@ -257,20 +257,20 @@ func getVolumeIdFromGlobalMount(host volume.VolumeHost, globalPath string) (stri return volumeId, nil } -func (pd *awsPersistentDisk) GetPath() string { - name := awsPersistentDiskPluginName +func (pd *awsElasticBlockStore) GetPath() string { + name := awsElasticBlockStorePluginName return pd.plugin.host.GetPodVolumeDir(pd.podUID, util.EscapeQualifiedNameForDisk(name), pd.volName) } // Unmounts the bind mount, and detaches the disk only if the PD // resource was the last reference to that disk on the kubelet. -func (pd *awsPersistentDisk) TearDown() error { +func (pd *awsElasticBlockStore) TearDown() error { return pd.TearDownAt(pd.GetPath()) } // Unmounts the bind mount, and detaches the disk only if the PD // resource was the last reference to that disk on the kubelet. -func (pd *awsPersistentDisk) TearDownAt(dir string) error { +func (pd *awsElasticBlockStore) TearDownAt(dir string) error { mountpoint, err := mount.IsMountPoint(dir) if err != nil { glog.V(2).Info("Error checking if mountpoint ", dir, ": ", err) diff --git a/pkg/volume/aws_pd/aws_pd_test.go b/pkg/volume/aws_pd/aws_pd_test.go index e5aee4ef7d6..2bf59e471b9 100644 --- a/pkg/volume/aws_pd/aws_pd_test.go +++ b/pkg/volume/aws_pd/aws_pd_test.go @@ -30,14 +30,14 @@ func TestCanSupport(t *testing.T) { plugMgr := volume.VolumePluginMgr{} plugMgr.InitPlugins(ProbeVolumePlugins(), volume.NewFakeVolumeHost("/tmp/fake", nil, nil)) - plug, err := plugMgr.FindPluginByName("kubernetes.io/aws-pd") + plug, err := plugMgr.FindPluginByName("kubernetes.io/aws-ebs") if err != nil { t.Errorf("Can't find the plugin by name") } - if plug.Name() != "kubernetes.io/aws-pd" { + if plug.Name() != "kubernetes.io/aws-ebs" { t.Errorf("Wrong name: %s", plug.Name()) } - if !plug.CanSupport(&api.Volume{VolumeSource: api.VolumeSource{AWSPersistentDisk: &api.AWSPersistentDiskVolumeSource{}}}) { + if !plug.CanSupport(&api.Volume{VolumeSource: api.VolumeSource{AWSElasticBlockStore: &api.AWSElasticBlockStoreVolumeSource{}}}) { t.Errorf("Expected true") } } @@ -46,7 +46,7 @@ func TestGetAccessModes(t *testing.T) { plugMgr := volume.VolumePluginMgr{} plugMgr.InitPlugins(ProbeVolumePlugins(), volume.NewFakeVolumeHost("/tmp/fake", nil, nil)) - plug, err := plugMgr.FindPersistentPluginByName("kubernetes.io/aws-pd") + plug, err := plugMgr.FindPersistentPluginByName("kubernetes.io/aws-ebs") if err != nil { t.Errorf("Can't find the plugin by name") } @@ -71,7 +71,7 @@ type fakePDManager struct{} // TODO(jonesdl) To fully test this, we could create a loopback device // and mount that instead. -func (fake *fakePDManager) AttachAndMountDisk(pd *awsPersistentDisk, globalPDPath string) error { +func (fake *fakePDManager) AttachAndMountDisk(pd *awsElasticBlockStore, globalPDPath string) error { globalPath := makeGlobalPDPath(pd.plugin.host, pd.volumeId) err := os.MkdirAll(globalPath, 0750) if err != nil { @@ -80,7 +80,7 @@ func (fake *fakePDManager) AttachAndMountDisk(pd *awsPersistentDisk, globalPDPat return nil } -func (fake *fakePDManager) DetachDisk(pd *awsPersistentDisk) error { +func (fake *fakePDManager) DetachDisk(pd *awsElasticBlockStore) error { globalPath := makeGlobalPDPath(pd.plugin.host, pd.volumeId) err := os.RemoveAll(globalPath) if err != nil { @@ -93,20 +93,20 @@ func TestPlugin(t *testing.T) { plugMgr := volume.VolumePluginMgr{} plugMgr.InitPlugins(ProbeVolumePlugins(), volume.NewFakeVolumeHost("/tmp/fake", nil, nil)) - plug, err := plugMgr.FindPluginByName("kubernetes.io/aws-pd") + plug, err := plugMgr.FindPluginByName("kubernetes.io/aws-ebs") if err != nil { t.Errorf("Can't find the plugin by name") } spec := &api.Volume{ Name: "vol1", VolumeSource: api.VolumeSource{ - AWSPersistentDisk: &api.AWSPersistentDiskVolumeSource{ + AWSElasticBlockStore: &api.AWSElasticBlockStoreVolumeSource{ VolumeId: "pd", FSType: "ext4", }, }, } - builder, err := plug.(*awsPersistentDiskPlugin).newBuilderInternal(spec, types.UID("poduid"), &fakePDManager{}, &mount.FakeMounter{}) + builder, err := plug.(*awsElasticBlockStorePlugin).newBuilderInternal(spec, types.UID("poduid"), &fakePDManager{}, &mount.FakeMounter{}) if err != nil { t.Errorf("Failed to make a new Builder: %v", err) } @@ -115,7 +115,7 @@ func TestPlugin(t *testing.T) { } path := builder.GetPath() - if path != "/tmp/fake/pods/poduid/volumes/kubernetes.io~aws-pd/vol1" { + if path != "/tmp/fake/pods/poduid/volumes/kubernetes.io~aws-ebs/vol1" { t.Errorf("Got unexpected path: %s", path) } @@ -137,7 +137,7 @@ func TestPlugin(t *testing.T) { } } - cleaner, err := plug.(*awsPersistentDiskPlugin).newCleanerInternal("vol1", types.UID("poduid"), &fakePDManager{}, &mount.FakeMounter{}) + cleaner, err := plug.(*awsElasticBlockStorePlugin).newCleanerInternal("vol1", types.UID("poduid"), &fakePDManager{}, &mount.FakeMounter{}) if err != nil { t.Errorf("Failed to make a new Cleaner: %v", err) } diff --git a/pkg/volume/aws_pd/aws_util.go b/pkg/volume/aws_pd/aws_util.go index 3b5e6889604..05831a0b718 100644 --- a/pkg/volume/aws_pd/aws_util.go +++ b/pkg/volume/aws_pd/aws_util.go @@ -29,9 +29,9 @@ import ( type AWSDiskUtil struct{} -// Attaches a disk specified by a volume.AWSPersistentDisk to the current kubelet. +// Attaches a disk specified by a volume.AWSElasticBlockStore to the current kubelet. // Mounts the disk to it's global path. -func (util *AWSDiskUtil) AttachAndMountDisk(pd *awsPersistentDisk, globalPDPath string) error { +func (util *AWSDiskUtil) AttachAndMountDisk(pd *awsElasticBlockStore, globalPDPath string) error { volumes, err := pd.getVolumeProvider() if err != nil { return err @@ -87,7 +87,7 @@ func (util *AWSDiskUtil) AttachAndMountDisk(pd *awsPersistentDisk, globalPDPath } // Unmounts the device and detaches the disk from the kubelet's host machine. -func (util *AWSDiskUtil) DetachDisk(pd *awsPersistentDisk) error { +func (util *AWSDiskUtil) DetachDisk(pd *awsElasticBlockStore) error { // Unmount the global PD mount, which should be the only one. globalPDPath := makeGlobalPDPath(pd.plugin.host, pd.volumeId) if err := pd.mounter.Unmount(globalPDPath, 0); err != nil { diff --git a/test/e2e/pd.go b/test/e2e/pd.go index f712fe1b359..5d6b504cf46 100644 --- a/test/e2e/pd.go +++ b/test/e2e/pd.go @@ -273,7 +273,7 @@ func testPDPod(diskName, targetHost string, readOnly bool) *api.Pod { { Name: "testpd", VolumeSource: api.VolumeSource{ - AWSPersistentDisk: &api.AWSPersistentDiskVolumeSource{ + AWSElasticBlockStore: &api.AWSElasticBlockStoreVolumeSource{ VolumeId: diskName, FSType: "ext4", ReadOnly: readOnly,