Skip to content

config/v1/types_infrastructure: Add AWS Region#300

Merged
openshift-merge-robot merged 2 commits intoopenshift:masterfrom
wking:record-aws-region
May 7, 2019
Merged

config/v1/types_infrastructure: Add AWS Region#300
openshift-merge-robot merged 2 commits intoopenshift:masterfrom
wking:record-aws-region

Conversation

@wking
Copy link
Copy Markdown
Member

@wking wking commented Apr 26, 2019

The image registry needs this so it can figure out where to create an S3 bucket for installs with cluster-provisioned infrastructure. We need the registry to be happy after:

$ openshift-install create cluster

so we don't want to rely on the installer pushing this config in as a day-2 operation. You can extract "what AWS region am I in?" from the cloud provider, but the registry operator is not authorized to do so. With this addition, we provide a way for the cluster creator to declare a default region for new infrastructure.

This field is in Status and not Spec, because we're not going to support transitioning clusters between regions by reconciling this. The cluster admin can write it once (in the manifest that goes up with the bootstrap Ignition config), and then it's read-only reality forever.

The field is optional [edit: not anymore], because you only need to set it if you want the cluster to provision resources for you. For user-provided infrastructure flows, you can leave this unset. However, the registry needs the region for its S3 client, even if it's just to manage data in a user-provided bucket. So folks who leave the property off will have an Available:false registry until they set region or regionEndpoint via the configs.imageregistry.operator.openshift.io custom resource.

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 26, 2019
@wking wking force-pushed the record-aws-region branch from 40e05ca to 532e4df Compare April 26, 2019 19:59
Comment thread config/v1/types_infrastructure.go Outdated
Comment thread config/v1/types_infrastructure.go
@wking wking force-pushed the record-aws-region branch 3 times, most recently from 1c8501c to c832814 Compare April 26, 2019 21:27
Comment thread config/v1/types_infrastructure.go Outdated
@wking wking force-pushed the record-aws-region branch from c832814 to 30a6215 Compare April 27, 2019 02:28
@adambkaplan
Copy link
Copy Markdown
Contributor

/cc @deads2k regarding pointer discussion

@openshift-ci-robot
Copy link
Copy Markdown

@adambkaplan: GitHub didn't allow me to request PR reviews from the following users: regarding, pointer, discussion.

Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

/cc @deads2k regarding pointer discussion

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.

@coreydaley
Copy link
Copy Markdown

@openshift/api-reviewers ptal at the above conversation and weigh in.

@adambkaplan
Copy link
Copy Markdown
Contributor

ping @deads2k @derekwaynecarr

Copy link
Copy Markdown
Contributor

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

I'm reverting my position and am OK with pointers.

Comment thread config/v1/types_infrastructure.go
Comment thread config/v1/types_infrastructure.go Outdated
@wking wking force-pushed the record-aws-region branch from 30a6215 to a1f3bdc Compare May 2, 2019 21:48
wking added a commit to wking/openshift-api that referenced this pull request May 2, 2019
The image registry needs this so it can figure out where to create an
S3 bucket for installs with cluster-provisioned infrastructure [1].
We need the registry to be happy after:

  $ openshift-install create cluster

so we don't want to rely on the installer pushing this config in as a
day-2 operation.  You can extract "what AWS region am I in?" from the
cloud provider, but the registry operator is not authorized to do so.
With this addition, we provide a way for the cluster creator to
declare a default region for new infrastructure.

This field is in Status and not Spec, because we're not going to
support transitioning clusters between regions by reconciling this.
The cluster admin can write it once (in the manifest that goes up with
the bootstrap Ignition config), and then it's read-only reality
forever.

I'd prefer an +optional Region property, because you only need to set
it if you want the cluster to provision resources for you.  For
user-provided infrastructure flows, you could leave this unset.
However, the registry needs the region for its S3 client [2], even if
it's just to manage data in a user-provided bucket.  So folks who
leave the property off will have an Available:false registry until
they set region or regionEndpoint via the
configs.imageregistry.operator.openshift.io custom resource [3,4].
But Adam wanted it required [5], and going from required -> optional
later is a non-breaking change while optional -> required would be
breaking, so it's required with this commit.

[1]: https://github.com/openshift/cluster-image-registry-operator/blob/670539cda460d97e0a3e23f077fdf9dd00d2ccdc/pkg/clusterconfig/clusterconfig.go#L44
[2]: https://github.com/openshift/cluster-image-registry-operator/blob/670539cda460d97e0a3e23f077fdf9dd00d2ccdc/pkg/storage/s3/s3.go#L53-L65
[3]: https://github.com/openshift/cluster-image-registry-operator/blob/670539cda460d97e0a3e23f077fdf9dd00d2ccdc/manifests/00-crd.yaml
[4]: https://github.com/openshift/cluster-image-registry-operator/blob/670539cda460d97e0a3e23f077fdf9dd00d2ccdc/pkg/apis/imageregistry/v1/types.go#L179-L184
[5]: openshift#300 (comment)
Copy link
Copy Markdown
Contributor

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 3, 2019
@coreydaley
Copy link
Copy Markdown

@openshift/api-approvers ptal

// PlatformStatus holds the current status specific to the underlying infrastructure provider
// of the current cluster. Since these are used at status-level for the underlying cluster, it
// is supposed that only one of the status structs is set.
type PlatformStatus struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This needs a discriminator field which indicates which one of the many values is going to be set. CRD discriminators are assumed to be in the same struct as the subfields I think. @sttts

Copy link
Copy Markdown
Contributor

@sttts sttts May 3, 2019

Choose a reason for hiding this comment

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

in the CRD it must be in the same JSON object (which in case of struct embedding might differ from "same struct"). Generators like crd-gen from controller-tools will probably require the same struct.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So bring

Platform PlatformType `json:"platform,omitempty"`
down into here? And deprecate the old property?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

...deprecate for removal in v2 in four years ;)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and that's not only a restriction for CRDs, but will be for native types as well.

Copy link
Copy Markdown
Contributor

@deads2k deads2k May 3, 2019

Choose a reason for hiding this comment

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

...deprecate for removal in v2 in four years ;)

I think you're left with no other choice. Duplicate the value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if native API adds discriminators like
https://godoc.org/k8s.io/api/core/v1#VolumeSource

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, pushed the discriminator down into platformStatus deprecating the old property with a1f3bdc -> 81ef6b4.

@bparees
Copy link
Copy Markdown
Contributor

bparees commented May 3, 2019

/approve

@bparees
Copy link
Copy Markdown
Contributor

bparees commented May 3, 2019

/hold

should this be going into master-next?

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 3, 2019
@bparees
Copy link
Copy Markdown
Contributor

bparees commented May 3, 2019

(apparently i'm not an approver yet. working on that: #307)

@bparees
Copy link
Copy Markdown
Contributor

bparees commented May 3, 2019

holding for clarity on whether this should be/needs to be going into 4.1 or not.

@wking wking force-pushed the record-aws-region branch from a1f3bdc to 81ef6b4 Compare May 3, 2019 18:57
@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 3, 2019
@wking
Copy link
Copy Markdown
Member Author

wking commented May 3, 2019

holding for clarity on whether this should be/needs to be going into 4.1 or not.

Motivation here. Dropping cluster-config-v1 in favor of Infrastructure simplifies user-facing docs because all you need to tear down an AWS cluster is the kubernetes.io/cluster/{infrastructureName}: owned tag (and not also the deprecated openshiftClusterID tag). That's tied up in the 4.1-targetted rhbz#1685089. There may be some slush about delivering that bug, although at one point it was a beta-blocker.

@wking
Copy link
Copy Markdown
Member Author

wking commented May 3, 2019

I guess if you wanted to punt on this but still address rhbz#1685089 for 4.1, you could have the registry operator pull both Infrastructure (for InfrastructureName) and cluster-config-v1 (for the default region). Seems easier to land this backwards compatible change though ;). Or just decide that rhbz#1685089 can slip to 4.2 and we'll accept more-complicated tagging docs in the meantime.

@bparees
Copy link
Copy Markdown
Contributor

bparees commented May 3, 2019

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 3, 2019
@adambkaplan
Copy link
Copy Markdown
Contributor

@wking needs a rebase, which will wipe out any lgtm.

wking added 2 commits May 7, 2019 10:40
The image registry needs this so it can figure out where to create an
S3 bucket for installs with cluster-provisioned infrastructure [1].
We need the registry to be happy after:

  $ openshift-install create cluster

so we don't want to rely on the installer pushing this config in as a
day-2 operation.  You can extract "what AWS region am I in?" from the
cloud provider, but the registry operator is not authorized to do so.
With this addition, we provide a way for the cluster creator to
declare a default region for new infrastructure.

This field is in Status and not Spec, because we're not going to
support transitioning clusters between regions by reconciling this.
The cluster admin can write it once (in the manifest that goes up with
the bootstrap Ignition config), and then it's read-only reality
forever.

I'd prefer an +optional Region property, because you only need to set
it if you want the cluster to provision resources for you.  For
user-provided infrastructure flows, you could leave this unset.
However, the registry needs the region for its S3 client [2], even if
it's just to manage data in a user-provided bucket.  So folks who
leave the property off will have an Available:false registry until
they set region or regionEndpoint via the
configs.imageregistry.operator.openshift.io custom resource [3,4].
But Adam wanted it required [5], and going from required -> optional
later is a non-breaking change while optional -> required would be
breaking, so it's required with this commit.

I've pushed the type specifier down into platformStatus, deprecating
the old property, because discriminator fields need to live inside the
struct whose properties they discriminate [6].  It would be nice to be
able to drop the old type property and rename platformStatus to
platform, but it's too close to API freeze to be able to do that, so
we're stuck with the old name.  We'll drop the old type in v2, if we
ever have a v2 of this type.

[1]: https://github.com/openshift/cluster-image-registry-operator/blob/670539cda460d97e0a3e23f077fdf9dd00d2ccdc/pkg/clusterconfig/clusterconfig.go#L44
[2]: https://github.com/openshift/cluster-image-registry-operator/blob/670539cda460d97e0a3e23f077fdf9dd00d2ccdc/pkg/storage/s3/s3.go#L53-L65
[3]: https://github.com/openshift/cluster-image-registry-operator/blob/670539cda460d97e0a3e23f077fdf9dd00d2ccdc/manifests/00-crd.yaml
[4]: https://github.com/openshift/cluster-image-registry-operator/blob/670539cda460d97e0a3e23f077fdf9dd00d2ccdc/pkg/apis/imageregistry/v1/types.go#L179-L184
[5]: openshift#300 (comment)
[6]: openshift#300 (comment)
With:

  $ make generate
@wking wking force-pushed the record-aws-region branch from 81ef6b4 to 78e39eb Compare May 7, 2019 17:42
@wking
Copy link
Copy Markdown
Member Author

wking commented May 7, 2019

Rebased around #308 with 81ef6b4 -> 78e39eb.

Copy link
Copy Markdown
Contributor

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

/lgtm

/assign @deads2k @sttts

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 7, 2019
@bparees bparees added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 7, 2019
@openshift-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: adambkaplan, bparees, wking

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-merge-robot openshift-merge-robot merged commit 8c71d43 into openshift:master May 7, 2019
wking added a commit to wking/openshift-installer that referenced this pull request May 8, 2019
Pulling in openshift/api@dedfb47b1f (config/v1/types_infrastructure:
Add AWS Region, 2019-04-26, openshift/api#300).

Generated with:

  $ dep ensure -update github.com/openshift/api

using:

  $ dep version
  dep:
   version     : v0.5.1
   build date  : 2019-03-20
   git hash    : faa61893
   go version  : go1.10.3
   go compiler : gc
   platform    : linux/amd64
   features    : ImportDuringSolve=false
abhinavdahiya pushed a commit to abhinavdahiya/installer that referenced this pull request Jul 2, 2019
@wking wking deleted the record-aws-region branch September 25, 2019 21:51
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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants