-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
ScaleIO - Ability to specify Secret's name and namespace #54013
ScaleIO - Ability to specify Secret's name and namespace #54013
Conversation
Hi @vladimirvivien. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/assign @liggitt |
pkg/api/validation/validation.go
Outdated
if sio.SecretRef.Name == "" { | ||
allErrs = append(allErrs, field.Required(fldPath.Child("secretRef.Name"), "")) | ||
} | ||
if sio.SecretRef.Namespace == "" { |
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.
can't make this required, existing objects do not have a namespace
pkg/api/validation/validation.go
Outdated
allErrs = append(allErrs, field.Required(fldPath.Child("volumeName"), "")) | ||
} | ||
if sio.SecretRef != nil { | ||
if sio.SecretRef.Name == "" { |
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.
can't tighten validation to make this required without breaking update of existing objects that didn't require this
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.
still outstanding, should not tighten validation on existing objects. basically, the validation for this new object has to be identical to the existing validation on ScaleIOVolumeSource
cc @kubernetes/sig-storage-api-reviews |
@vladimirvivien no generated files? |
/ok-to-test |
@rootfs this is still WIP, needs generated files and volume plugin updates |
pkg/api/persistentvolume/util.go
Outdated
if source.ScaleIO.SecretRef != nil && len(source.ScaleIO.SecretRef.Namespace) > 0 { | ||
ns = source.ScaleIO.SecretRef.Namespace | ||
} | ||
if !visitor(ns, source.ScaleIO.SecretRef.Name) { |
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.
Keep this inside a if source.ScaleIO.SecretRef != nil
check
pkg/api/validation/validation.go
Outdated
@@ -1231,6 +1231,30 @@ func validateScaleIOVolumeSource(sio *api.ScaleIOVolumeSource, fldPath *field.Pa | |||
if sio.VolumeName == "" { | |||
allErrs = append(allErrs, field.Required(fldPath.Child("volumeName"), "")) | |||
} | |||
if sio.SecretRef != nil { | |||
if sio.SecretRef.Name == "" { |
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.
Same here, this is tightening validation of existing objects, which isn’t allowed
sdcGuid string | ||
}{ | ||
gateway: "gateway", | ||
sslEnabled: "sslEnabled", | ||
secretRef: "secretRef", | ||
secretName: "secretRef", |
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.
+1 for keeping the same config key for compatibility
pkg/volume/scaleio/sio_volume.go
Outdated
@@ -448,19 +452,20 @@ func (v *sioVolume) setSioMgrFromConfig() error { | |||
if v.sioMgr == nil { | |||
configData := v.configData | |||
applyConfigDefaults(configData) | |||
|
|||
configData[confKey.volSpecName] = v.volSpecName |
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.
is there a reason this isn't setting these:
configData[confKey.secretName] = v.secretName
configData[confKey.secretNamespace] = v.secretNamespace
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.
@liggitt yes, secret and namespace comes from options.Prameters=v.configData
during NewProvisioner
. But, will change code to make that clearer.
|
@@ -1375,6 +1375,42 @@ type ScaleIOVolumeSource struct { | |||
ReadOnly bool `json:"readOnly,omitempty" protobuf:"varint,10,opt,name=readOnly"` | |||
} | |||
|
|||
// ScaleIOPersistentVolumeSource represents a persistent ScaleIO volume that can be defined | |||
// by a an admin via a storage class, for instance. | |||
type ScaleIOPersistentVolumeSource struct { |
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 should be an exact copy of v1.ScaleIOVolumeSource with SecretRef
changed to *SecretReference
. That will pick up all the json/protobuf tags verbatim:
// ScaleIOPersistentVolumeSource represents a persistent ScaleIO volume
type ScaleIOPersistentVolumeSource struct {
// The host address of the ScaleIO API Gateway.
Gateway string `json:"gateway" protobuf:"bytes,1,opt,name=gateway"`
// The name of the storage system as configured in ScaleIO.
System string `json:"system" protobuf:"bytes,2,opt,name=system"`
// SecretRef references to the secret for ScaleIO user and other
// sensitive information. If this is not provided, Login operation will fail.
SecretRef *SecretReference `json:"secretRef" protobuf:"bytes,3,opt,name=secretRef"`
// Flag to enable/disable SSL communication with Gateway, default false
// +optional
SSLEnabled bool `json:"sslEnabled,omitempty" protobuf:"varint,4,opt,name=sslEnabled"`
// The name of the Protection Domain for the configured storage (defaults to "default").
// +optional
ProtectionDomain string `json:"protectionDomain,omitempty" protobuf:"bytes,5,opt,name=protectionDomain"`
// The Storage Pool associated with the protection domain (defaults to "default").
// +optional
StoragePool string `json:"storagePool,omitempty" protobuf:"bytes,6,opt,name=storagePool"`
// Indicates whether the storage for a volume should be thick or thin (defaults to "thin").
// +optional
StorageMode string `json:"storageMode,omitempty" protobuf:"bytes,7,opt,name=storageMode"`
// The name of a volume already created in the ScaleIO system
// that is associated with this volume source.
VolumeName string `json:"volumeName,omitempty" protobuf:"bytes,8,opt,name=volumeName"`
// Filesystem type to mount.
// Must be a filesystem type supported by the host operating system.
// Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.
// +optional
FSType string `json:"fsType,omitempty" protobuf:"bytes,9,opt,name=fsType"`
// Defaults to false (read/write). ReadOnly here will force
// the ReadOnly setting in VolumeMounts.
// +optional
ReadOnly bool `json:"readOnly,omitempty" protobuf:"varint,10,opt,name=readOnly"`
}
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.
@liggitt ok, thanks. I think I only changed SecretRef
's type in ScaleIOPersistentVolumeSource
. I will make sure they are the same in both ScaleIOVolumeSource
as well. Thanks.
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.
I re-read your comment. Ok, I will ensure the types are the same in staging and v1.
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.
yeah, leave ScaleIOVolumeSource
as is
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.
@liggitt
I got confused because your comment above has ScaleIOVolumeSource
using SecretReference
. Please confirm:
XXXVolumeSource
->LocalObjectReference
(in pkg/v1 and staging/v1)XXXPersistentVolumeSource
->SecretReference
(in pkg/v1 and staging/v1)
The above is how I see other types are done, but confirm anyway.
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.
Oops, fixed.
pkg/api/v1/zz_generated.defaults.go
Outdated
@@ -145,9 +145,6 @@ func SetObjectDefaults_PersistentVolume(in *v1.PersistentVolume) { | |||
if in.Spec.PersistentVolumeSource.AzureDisk != nil { | |||
SetDefaults_AzureDiskVolumeSource(in.Spec.PersistentVolumeSource.AzureDisk) | |||
} | |||
if in.Spec.PersistentVolumeSource.ScaleIO != nil { | |||
SetDefaults_ScaleIOVolumeSource(in.Spec.PersistentVolumeSource.ScaleIO) |
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.
need to copy SetDefaults_ScaleIOVolumeSource
to SetDefaults_ScaleIOPersistentVolumeSource
(changing the types), which will regenerate this to call a defaulting function
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.
which also means copying the registered fuzzing function in pkg/api/fuzzer/fuzzer.go
for func(sio *api.ScaleIOVolumeSource, c fuzz.Continue)
for ScaleIOPersistentVolumeSource
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.
ok will do.
sio.StoragePool = "default" | ||
sio.FSType = c.RandString() | ||
if sio.FSType == "" { | ||
sio.FSType = "xfs" | ||
} |
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.
why did ProtectionDomain and StoragePool defaults get dropped? should be present in both fuzzing funcs for ScaleIOVolumeSource and ScaleIOPersistentVolumeSource, right?
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.
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.
hmm, ok. changing defaults is typically considered a breaking API change, but if the defaults caused the object to never work, that doesn't seem good either.
would like agreement from @kubernetes/sig-storage-api-reviews on the removal of the defaulting behavior on those fields, and if agreed on, remove the (defaults to "default")
godoc from those fields and add a description of the default change to the release note.
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.
@liggitt thank you. Basically this is taking care of a bug in the API validation. If those values are applied by default as default
, chances are they would break storage operations since, most likely, these values will not match values on the backing storage system.
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.
Ok. Validation doesn't require those values to be set (and can't, without breaking existing API create calls), so with defaulting removed, if someone leaves them empty, they will just be unset now. Is that acceptable?
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.
@liggitt Yes. That is acceptable.
if obj.StoragePool == "" { | ||
obj.StoragePool = "default" | ||
if obj.FSType == "" { | ||
obj.FSType = "xfs" | ||
} |
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.
restore these defaults to both SetDefaults_ScaleIOVolumeSource
and SetDefaults_ScaleIOPersistentVolumeSource
?
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.
See comment above. Thanks!
a couple last changes, then LGTM
|
/test pull-kubernetes-bazel-test |
|
@vladimirvivien: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
This commit tracks all human-generated code for API source updates.
@liggitt |
/lgtm |
/approve |
1 similar comment
/approve |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: childsb, liggitt, rootfs, vladimirvivien Assign the PR to them by writing Associated issue: 53619 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
changes under federation/ are generated files only, tagging |
Automatic merge from submit-queue (batch tested with PRs 49865, 53731, 54013, 54513, 51502). If you want to cherry-pick this change to another branch, please follow the instructions here. |
…f-#54013-upstream-release-1.8 Automatic merge from submit-queue. Automated cherry pick of #54013 Cherry pick of #54013 on release-1.8. #54013: ScaleIO - API source code update ```release-note ScaleIO persistent volumes now support referencing a secret in a namespace other than the bound persistent volume claim's namespace; this is controlled during provisioning with the `secretNamespace` storage class parameter; StoragePool and ProtectionDomain attributes no longer defaults to the value `default` ```
What this PR does / why we need it:
This PR is to decouple the ScaleIO secret from the same namespace as that of the StorageClass/PVC/PV that uses it (#53619). Currently, authorized non-admin k8s user, who creates volumes, may end up having unauthorized access to ScaleIO secret information. This PR introduces secret parameter that allows specification of secret's namespace.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #53619Release note: