Skip to content

Conversation

@crawford
Copy link
Contributor

This adds support for reading user prompts from the environment. This
will allow CI to test the installer without needing expect or a
similar utility. It can be used like the following:

OPENSHIFT_INSTALL_CLUSTER_NAME=crawford
OPENSHIFT_INSTALL_PLATFORM=libvirt
openshift-install cluster

This adds support for reading user prompts from the environment. This
will allow CI to test the installer without needing `expect` or a
similar utility. It can be used like the following:

    OPENSHIFT_INSTALL_CLUSTER_NAME=crawford
    OPENSHIFT_INSTALL_PLATFORM=libvirt
    openshift-install cluster
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 25, 2018
Message: "Platform",
Options: validPlatforms,
}, &platform, nil)
func (a *Platform) queryUserForPlatform() (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe rename this to queryUserOrGetEnvForPlatform

Copy link
Member

Choose a reason for hiding this comment

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

maybe rename this to queryUserOrGetEnvForPlatform

I'm fine with the old name. Environment variables are just another channel for the user to answer these queries.

Copy link
Contributor

Choose a reason for hiding this comment

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

So you'd rather double-check each function where it gets the input from instead of having the information readily available in the name?

Copy link
Member

Choose a reason for hiding this comment

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

So you'd rather double-check each function where it gets the input from...

Yeah. The caller just needs to care that the input is gotten. The source location is an implementation detail.

Default: "qemu+tcp://192.168.122.1/system",
}, &uri, nil)
prompt := asset.UserProvided{
Prompt: &survey.Input{
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you forget to use &survey.Select here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. This is a free-form field.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do I understand correctly that due to https://github.com/openshift/installer/pull/320/files#diff-042a71691f31141034ea54bae5b36b06R26 this is settable via environment variable and will only ask interactively if it's not present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.


// Generate generates the SSH public key asset.
func (a *sshPublicKey) Generate(map[asset.Asset]*asset.State) (state *asset.State, err error) {
if value, ok := os.LookupEnv("OPENSHIFT_INSTALL_SSH_PUB_KEY"); ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd consider to also ask for the SSH key if not provided, or are there use-cases where one wouldn't want one set?

Copy link
Member

Choose a reason for hiding this comment

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

I'd consider to also ask for the SSH key if not provided, or are there use-cases where one wouldn't want one set?

I'm fine allowing folks to not set one (e.g. if they trust us to set up a working cluster for them so they won't have to poke around ;). So I think we want to allow empty OPENSHIFT_INSTALL_SSH_PUB_KEY to mean "I don't want to set this, don't ask me". Alternatively, we could have a --batch flag or some such to mean "anything I haven't passed to you (via environment variables or otherwise) is not coming, so don't ask."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting OPENSHIFT_INSTALL_SSH_PUB_KEY to an empty string effectively boots without any keys. There is an empty key, but that's okay.

Copy link
Contributor

@steveej steveej Sep 25, 2018

Choose a reason for hiding this comment

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

Alternatively, we could have a --batch flag or some such to mean "anything I haven't passed to you (via environment variables or otherwise) is not coming, so don't ask."

That sounds useful. If someone goes through it the first time interactively they might forget or not be aware of this setting and later have to restart when they find themselves unable to login.

Copy link
Member

Choose a reason for hiding this comment

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

If someone goes through it the first time interactively they might forget or not be aware of this setting and later have to restart when they find themselves unable to login.

The long-term plan is to have one of the operators (the machine-config operator?) managing authorized SSH keys over the life of the cluster. So you should (eventually) be able to recover even if you launch a cluster without this.

@steveej
Copy link
Contributor

steveej commented Sep 25, 2018

/hold
/approve

Please feel free to release the old after considering the following UX features

@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 Sep 25, 2018
@crawford
Copy link
Contributor Author

I'm holding off on documentation for now. I've got a large rewrite in the works. As for the --batch flag, maybe in the future we can add that.

@crawford
Copy link
Contributor Author

/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 Sep 25, 2018
@crawford
Copy link
Contributor Author

@wking Did you have any final comments?

@wking
Copy link
Member

wking commented Sep 25, 2018

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 25, 2018
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: crawford, steveeJ, 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:
  • OWNERS [crawford,steveeJ,wking]

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 238a0ed into openshift:master Sep 25, 2018
@crawford crawford deleted the env branch September 25, 2018 19:09
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants