Skip to content

GCP: populate encryption values into tf and machines#4397

Merged
openshift-merge-robot merged 3 commits intoopenshift:masterfrom
mgugino-upstream-stage:gcp-encrypt2
Dec 7, 2020
Merged

GCP: populate encryption values into tf and machines#4397
openshift-merge-robot merged 3 commits intoopenshift:masterfrom
mgugino-upstream-stage:gcp-encrypt2

Conversation

@michaelgugino
Copy link
Contributor

This commit ensures encryption values are properly
populated into terraform and machines/machinesets.


var encryptionKey *gcpprovider.GCPEncryptionKeyReference

if mpool.OSDisk.EncryptionKey != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a reason that OSDisk.EncryptionKey can't just be an imported type from the GCP provider? That should allow us to a do a straight assignment here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. OSDisk.EncryptionKey is defined in the types package, which represents the installer API, so we try to keep it free of external dependencies considering other projects import the types package.

"github.com/openshift/installer/pkg/types"
)

const (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe this belongs in GCP provider in a util package?

return json.MarshalIndent(cfg, "", " ")
}

func generateDiskEncryptionKeyLink(keyRef *gcpprovider.GCPEncryptionKeyReference, projectID string) string {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe this belongs in GCP provider in a util package?

Copy link
Contributor

Choose a reason for hiding this comment

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

To echo our conversation on slack, I would handle this in terraform:

  1. create a type for the key similar to Auth in TFVars and pass the values in that way
  2. conditionally create the self link variable (or null value therein) with logic similar to BYO networking: https://github.com/openshift/installer/blob/master/data/data/gcp/network/common.tf

I'm also fine with this approach and think it's OK to have this logic live here.

Copy link
Contributor

@staebler staebler 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

} else {
encryptionKey = nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The else block is unnecessary.

root_volume_type = var.gcp_master_root_volume_type
root_volume_size = var.gcp_master_root_volume_size
root_volume_type = var.gcp_master_root_volume_type
root_volume_kms_key_link = var.gcp_root_volume_kms_key_link
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that not done as the change in data/data/gcp/bootstrap/main.tf, or does that need to go into data/data/bootstrap somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

In /data/data/gcp/main.tf as linked above. It is currently only passing the variable from main to master, but needs to do the same for bootstrap.

Copy link
Contributor

@patrickdillon patrickdillon left a comment

Choose a reason for hiding this comment

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

Left a few comments, but this looks really good to me.

KMSKeyServiceAccount: mpool.OSDisk.EncryptionKey.KMSKeyServiceAccount,
}
} else {
encryptionKey = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: not sure this is necessary (should already be nil). if you want to leave it in, moving it out of else and before if would be more concise.

Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be needed as var encryptionKey *gcpprovider.GCPEncryptionKeyReference above the if makes it a nil anyway


variable "root_volume_kms_key_link" {
type = string
description = "The GCP self link of KMS key to encrypt the volume"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: missing period.


variable "root_volume_kms_key_link" {
type = string
description = "The GCP self link of KMS key to encrypt the volume"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: missing period


variable "gcp_root_volume_kms_key_link" {
type = string
description = "The GCP self link of KMS key to encrypt the volume"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: missing period

return json.MarshalIndent(cfg, "", " ")
}

func generateDiskEncryptionKeyLink(keyRef *gcpprovider.GCPEncryptionKeyReference, projectID string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

To echo our conversation on slack, I would handle this in terraform:

  1. create a type for the key similar to Auth in TFVars and pass the values in that way
  2. conditionally create the self link variable (or null value therein) with logic similar to BYO networking: https://github.com/openshift/installer/blob/master/data/data/gcp/network/common.tf

I'm also fine with this approach and think it's OK to have this logic live here.

@patrickdillon
Copy link
Contributor

/test e2e-gcp

variable "root_volume_kms_key_link" {
type = string
description = "The GCP self link of KMS key to encrypt the volume"
default = null
Copy link
Contributor

Choose a reason for hiding this comment

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

column alignment is off and causing tf-fmt to fail

variable "gcp_root_volume_kms_key_link" {
type = string
description = "The GCP self link of KMS key to encrypt the volume"
default = null
Copy link
Contributor

Choose a reason for hiding this comment

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

column alignment is off and causing tf-fmt to fail

Copy link
Contributor

Choose a reason for hiding this comment

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

column alignment is off and causing tf-fmt to fail

weird, tf-fmt seems to be suggesting different alignment for this file than the other two:
https://storage.googleapis.com/origin-ci-test/pr-logs/pull/openshift_installer/4397/pull-ci-openshift-installer-master-tf-fmt/1329497726143959040/build-log.txt

variable "root_volume_kms_key_link" {
type = string
description = "The GCP self link of KMS key to encrypt the volume"
default = null
Copy link
Contributor

Choose a reason for hiding this comment

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

column alignment is off and causing tf-fmt to fail

@patrickdillon
Copy link
Contributor

I would pull the missing dependencies into this PR in two separate commit: one commit for your changes and a separate one for the vendored files.

@JoelSpeed
Copy link
Contributor

@patrickdillon I've fixed all of the comments that were left (I believe) on this branch master...JoelSpeed:gcp-encrypt

I've also added a commit for the missing dependencies as requested.

I didn't do anything for this one (https://github.com/openshift/installer/pull/4397/files#r527187850) as it seemed there wasn't a strong preference to change it.

Mike is out today and has suggested he will be out all week, I wondered if you could give my branch a check over and, if that's looking good, I could squash my fixups into his commit, open a new PR and we can merge that one while he is out, WDYT? Trying to give this PR as much time to soak in QE as possible

@patrickdillon
Copy link
Contributor

@patrickdillon I've fixed all of the comments that were left (I believe) on this branch master...JoelSpeed:gcp-encrypt

I've also added a commit for the missing dependencies as requested.

I didn't do anything for this one (https://github.com/openshift/installer/pull/4397/files#r527187850) as it seemed there wasn't a strong preference to change it.

Mike is out today and has suggested he will be out all week, I wondered if you could give my branch a check over and, if that's looking good, I could squash my fixups into his commit, open a new PR and we can merge that one while he is out, WDYT? Trying to give this PR as much time to soak in QE as possible

The branch in general looks good. I don't have approval rights at this level, so I can't push this through. @staebler is out until Monday. I would recommend just opening a PR and getting everything to pass so it could be ready to go on Monday.

If you think it's really important to get it in ASAP we can try to coordinate an approve with @sdodson 's help.

@michaelgugino michaelgugino force-pushed the gcp-encrypt2 branch 2 times, most recently from 823aef4 to 11ae34a Compare December 4, 2020 17:29
@michaelgugino
Copy link
Contributor Author

/retest

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 5, 2020
@staebler
Copy link
Contributor

staebler commented Dec 7, 2020

@michaelgugino The dependency mess has finally merged. This PR needs another rebase.

michaelgugino and others added 3 commits December 7, 2020 11:08
This commit ensures encryption values are properly
populated into terraform and machines/machinesets.
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 7, 2020
Copy link
Contributor

@staebler staebler left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
/label tide/merge-method-squash

@openshift-ci-robot openshift-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Dec 7, 2020
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 7, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: staebler

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 7, 2020
@staebler
Copy link
Contributor

staebler commented Dec 7, 2020

/test e2e-gcp

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot
Copy link
Contributor

openshift-merge-robot commented Dec 7, 2020

@michaelgugino: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-metal-ipi a903c53 link /test e2e-metal-ipi
ci/prow/e2e-aws-fips 50d34a0 link /test e2e-aws-fips
ci/prow/e2e-crc 50d34a0 link /test e2e-crc
ci/prow/e2e-libvirt 50d34a0 link /test e2e-libvirt
ci/prow/e2e-aws-workers-rhel7 50d34a0 link /test e2e-aws-workers-rhel7
ci/prow/e2e-metal-ipi-ovn-ipv6 50d34a0 link /test e2e-metal-ipi-ovn-ipv6
ci/prow/e2e-gcp 50d34a0 link /test e2e-gcp
ci/prow/e2e-ovirt 50d34a0 link /test e2e-ovirt

Full PR test history. Your PR dashboard.

Details

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.

@staebler staebler mentioned this pull request Dec 7, 2020
@staebler
Copy link
Contributor

staebler commented Dec 7, 2020

The GCP install succeeded in the latest e2e-gcp test.

@staebler
Copy link
Contributor

staebler commented Dec 7, 2020

All the changes in this PR are in GCP-specific files.

/override ci/prow/e2e-aws

@openshift-ci-robot
Copy link
Contributor

@staebler: Overrode contexts on behalf of staebler: ci/prow/e2e-aws

Details

In response to this:

All the changes in this PR are in GCP-specific files.

/override ci/prow/e2e-aws

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.

@openshift-merge-robot openshift-merge-robot merged commit f7e061d into openshift:master Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants