Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

barbacbd
Copy link
Contributor

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.

@openshift-ci-robot openshift-ci-robot added jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jun 12, 2025
@openshift-ci-robot
Copy link
Contributor

@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
  • bug is open, matching expected state (open)
  • bug target version (4.20.0) matches configured target version for branch (4.20.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @jianli-wei

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

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.

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.

Copy link
Contributor

openshift-ci bot commented Jun 12, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign patrickdillon for approval. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Member

@tthvo tthvo left a 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).

Comment on lines 602 to 611
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
}
Copy link
Member

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:

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:

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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:

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.

Comment on lines 602 to 603
if kmsKeyRef.ProjectID == "" {
logrus.Debugf("kms key project ID missing, using default project: %s", projectID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 

@jianli-wei
Copy link
Contributor

/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Jun 13, 2025
@openshift-ci-robot
Copy link
Contributor

@barbacbd: This pull request references Jira Issue OCPBUGS-51299, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.20.0) matches configured target version for branch (4.20.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @jianli-wei

In response to this:

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.

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.

@barbacbd barbacbd requested a review from tthvo June 30, 2025 13:24
@barbacbd barbacbd force-pushed the OCPBUGS-51299-validation branch from e26ab80 to bb64b42 Compare June 30, 2025 14:08
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.
@barbacbd barbacbd force-pushed the OCPBUGS-51299-validation branch from bb64b42 to 2365860 Compare June 30, 2025 18:19
@tthvo
Copy link
Member

tthvo commented Jul 1, 2025

/retest-required

Copy link
Contributor

openshift-ci bot commented Jul 1, 2025

@barbacbd: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-gcp-ovn-byo-vpc 2365860 link false /test e2e-gcp-ovn-byo-vpc
ci/prow/e2e-gcp-ovn-xpn 2365860 link false /test e2e-gcp-ovn-xpn
ci/prow/e2e-vsphere-ovn-multi-network 2365860 link false /test e2e-vsphere-ovn-multi-network
ci/prow/gcp-private 2365860 link false /test gcp-private
ci/prow/e2e-azure-ovn-resourcegroup 2365860 link false /test e2e-azure-ovn-resourcegroup
ci/prow/e2e-vsphere-static-ovn 2365860 link false /test e2e-vsphere-static-ovn
ci/prow/okd-scos-e2e-aws-ovn 2365860 link false /test okd-scos-e2e-aws-ovn
ci/prow/e2e-gcp-default-config 2365860 link false /test e2e-gcp-default-config
ci/prow/e2e-vsphere-externallb-ovn 2365860 link false /test e2e-vsphere-externallb-ovn
ci/prow/e2e-gcp-secureboot 2365860 link false /test e2e-gcp-secureboot

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants