-
Notifications
You must be signed in to change notification settings - Fork 1.4k
OCPBUGS-51299: Add default values for validation to kms keys #9781
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
base: main
Are you sure you want to change the base?
Conversation
@barbacbd: This pull request references Jira Issue OCPBUGS-51299, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
Looks good! I have a small question :D And I think unit tests needs fixing (plus fmt/lint issues).
if kmsKeyRef.ProjectID == "" { | ||
logrus.Debugf("kms key project ID missing, using default project: %s", projectID) | ||
projectID = project | ||
} | ||
|
||
location := kmsKeyRef.Location | ||
if location == "" { | ||
logrus.Debugf("kms key location missing, using default region: %s", region) | ||
location = region | ||
} |
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.
Looking at this PR and #9767, I noticed we have other places that need defaulting too.
This needs project and location defaulting:
installer/pkg/asset/machines/gcp/machines.go
Lines 145 to 148 in 7c5b649
Name: mpool.OSDisk.EncryptionKey.KMSKey.Name, | |
KeyRing: mpool.OSDisk.EncryptionKey.KMSKey.KeyRing, | |
ProjectID: mpool.OSDisk.EncryptionKey.KMSKey.ProjectID, | |
Location: mpool.OSDisk.EncryptionKey.KMSKey.Location, |
This needs location defaulting:
installer/pkg/asset/machines/gcp/gcpmachines.go
Lines 29 to 35 in 7c5b649
func generateDiskEncryptionKeyLink(kmsKey *gcptypes.KMSKeyReference, projectID string) string { | |
if kmsKey.ProjectID != "" { | |
projectID = kmsKey.ProjectID | |
} | |
return fmt.Sprintf(kmsKeyNameFmt, projectID, kmsKey.Location, kmsKey.KeyRing, kmsKey.Name) | |
} |
Should we set the defaults somewhere early for this kmsKey field? So that, it is handled at one place.
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 think the default is supposed to be stored in the defaultMachinePlatform
. The reason we have these other validations is that the defaultMachinePlatform
can also be empty.
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 makes sense (good catch @tthvo) but it is strange that the associated bug has been successfully tested.
Because the values (project & region) are already contained in the install config, it should be possible to extend the default function in pkg/types:
defaults.SetInstallConfigDefaults(a.Config) |
That would set the value in the install config, so it would also supersede the changes introduced in #9767. One thing I don't recall is that if the location is empty whether we default to the cluster region or global
, but either case we should be able handle fine in pkg/types.
Alternatively if you wanted to handle this only for machines you could extend the defaultGCPMachinePoolPlatform
function to populate the default values:
installer/pkg/asset/machines/worker.go
Lines 132 to 140 in e6e1537
func defaultGCPMachinePoolPlatform(arch types.Architecture) gcptypes.MachinePool { | |
return gcptypes.MachinePool{ | |
InstanceType: icgcp.DefaultInstanceTypeForArch(arch), | |
OSDisk: gcptypes.OSDisk{ | |
DiskSizeGB: powerOfTwoRootVolumeSize, | |
DiskType: "pd-ssd", | |
}, | |
} | |
} |
I think it is more extensible/future proof to handle this in the first way that was suggested. In which case I think you would ultimately end up extending the SetMachinePoolDefaults function
func SetMachinePoolDefaults(p *types.MachinePool, platform string) { |
The function would need to be revised to pass in the platform
struct that contains the project. You would also need to make sure the defaultMachinePoolPlatform
is populated. It seems like the existing code does not handle that.
if kmsKeyRef.ProjectID == "" { | ||
logrus.Debugf("kms key project ID missing, using default project: %s", projectID) |
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.
if kmsKeyRef.ProjectID == "" { | |
logrus.Debugf("kms key project ID missing, using default project: %s", projectID) | |
if projectID == "" { | |
logrus.Debugf("kms key project ID missing, using default project: %s", project) |
nit: I think we need to use project
variable here. Otherwise, the log will be empty?
DEBUG kms key project ID missing, using default project:
DEBUG kms key location missing, using default region: us-east1
/label qe-approved |
@barbacbd: This pull request references Jira Issue OCPBUGS-51299, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
e26ab80
to
bb64b42
Compare
installconfig/gcp: ** Add default location and project to the kms key validation. The installer does not require these fields to be entered, so the defaults will be selected from the projectID and region fields of the GCP Platform.
bb64b42
to
2365860
Compare
/retest-required |
@barbacbd: The following tests failed, say
Full PR test history. Your PR dashboard. 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-sigs/prow repository. I understand the commands that are listed here. |
installconfig/gcp:
** Add default location and project to the kms key validation. The installer does not require these fields to be entered, so the defaults will be selected from the projectID and region fields of the GCP Platform.