mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 00:07:50 +00:00
Merge pull request #21738 from jsafrane/devel/fix-admission
Hot-fix admission of volumes that are being provisioned.
This commit is contained in:
commit
658f7ef397
@ -439,7 +439,7 @@ func (c *awsElasticBlockStoreProvisioner) NewPersistentVolumeTemplate() (*api.Pe
|
|||||||
},
|
},
|
||||||
PersistentVolumeSource: api.PersistentVolumeSource{
|
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||||
AWSElasticBlockStore: &api.AWSElasticBlockStoreVolumeSource{
|
AWSElasticBlockStore: &api.AWSElasticBlockStoreVolumeSource{
|
||||||
VolumeID: "dummy",
|
VolumeID: volume.ProvisionedVolumeName,
|
||||||
FSType: "ext4",
|
FSType: "ext4",
|
||||||
Partition: 0,
|
Partition: 0,
|
||||||
ReadOnly: false,
|
ReadOnly: false,
|
||||||
|
@ -445,7 +445,7 @@ func (c *cinderVolumeProvisioner) NewPersistentVolumeTemplate() (*api.Persistent
|
|||||||
},
|
},
|
||||||
PersistentVolumeSource: api.PersistentVolumeSource{
|
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||||
Cinder: &api.CinderVolumeSource{
|
Cinder: &api.CinderVolumeSource{
|
||||||
VolumeID: "dummy",
|
VolumeID: volume.ProvisionedVolumeName,
|
||||||
FSType: "ext4",
|
FSType: "ext4",
|
||||||
ReadOnly: false,
|
ReadOnly: false,
|
||||||
},
|
},
|
||||||
|
@ -401,7 +401,7 @@ func (c *gcePersistentDiskProvisioner) NewPersistentVolumeTemplate() (*api.Persi
|
|||||||
},
|
},
|
||||||
PersistentVolumeSource: api.PersistentVolumeSource{
|
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||||
GCEPersistentDisk: &api.GCEPersistentDiskVolumeSource{
|
GCEPersistentDisk: &api.GCEPersistentDiskVolumeSource{
|
||||||
PDName: "dummy",
|
PDName: volume.ProvisionedVolumeName,
|
||||||
FSType: "ext4",
|
FSType: "ext4",
|
||||||
Partition: 0,
|
Partition: 0,
|
||||||
ReadOnly: false,
|
ReadOnly: false,
|
||||||
|
@ -113,6 +113,12 @@ type DeletableVolumePlugin interface {
|
|||||||
NewDeleter(spec *Spec) (Deleter, error)
|
NewDeleter(spec *Spec) (Deleter, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Name of a volume in external cloud that is being provisioned and thus
|
||||||
|
// should be ignored by rest of Kubernetes.
|
||||||
|
ProvisionedVolumeName = "placeholder-for-provisioning"
|
||||||
|
)
|
||||||
|
|
||||||
// ProvisionableVolumePlugin is an extended interface of VolumePlugin and is used to create volumes for the cluster.
|
// ProvisionableVolumePlugin is an extended interface of VolumePlugin and is used to create volumes for the cluster.
|
||||||
type ProvisionableVolumePlugin interface {
|
type ProvisionableVolumePlugin interface {
|
||||||
VolumePlugin
|
VolumePlugin
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
"k8s.io/kubernetes/pkg/cloudprovider"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/aws"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/aws"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce"
|
||||||
|
vol "k8s.io/kubernetes/pkg/volume"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -102,6 +103,10 @@ func (l *persistentVolumeLabel) Admit(a admission.Attributes) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *persistentVolumeLabel) findAWSEBSLabels(volume *api.PersistentVolume) (map[string]string, error) {
|
func (l *persistentVolumeLabel) findAWSEBSLabels(volume *api.PersistentVolume) (map[string]string, error) {
|
||||||
|
// Ignore any volumes that are being provisioned
|
||||||
|
if volume.Spec.AWSElasticBlockStore.VolumeID == vol.ProvisionedVolumeName {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
ebsVolumes, err := l.getEBSVolumes()
|
ebsVolumes, err := l.getEBSVolumes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -141,6 +146,11 @@ func (l *persistentVolumeLabel) getEBSVolumes() (aws.Volumes, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *persistentVolumeLabel) findGCEPDLabels(volume *api.PersistentVolume) (map[string]string, error) {
|
func (l *persistentVolumeLabel) findGCEPDLabels(volume *api.PersistentVolume) (map[string]string, error) {
|
||||||
|
// Ignore any volumes that are being provisioned
|
||||||
|
if volume.Spec.GCEPersistentDisk.PDName == vol.ProvisionedVolumeName {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
provider, err := l.getGCECloudProvider()
|
provider, err := l.getGCECloudProvider()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user