Skip to content
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

.*: generate and embed Openshift's InstallConfig from Tectonic's Config #205

Merged

Conversation

abhinavdahiya
Copy link
Contributor

embedding the Openshift's InstallConfig in clusters created by tectonic
installer binary allows operators to start building on their config discovery
logic.

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 5, 2018
@abhinavdahiya
Copy link
Contributor Author

/cc @wking @yifan-gu

region: eu-west-1
vpcCIDRBlock: 10.0.0.0/16
vpcID: ""
pullSecret: /path/config.json
Copy link
Member

Choose a reason for hiding this comment

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

This is no longer useful. The config should be updated to take the pull secret as a JSON string, even if users are allowed to provide it via a path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just to clarify, the types.InstallConfig.PullSecret field is a string type that stores the contents of the pull secret file , which is a JSON string?

Copy link
Member

Choose a reason for hiding this comment

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

just to clarify, the types.InstallConfig.PullSecret field is a string type that stores the contents of the pull secret file , which is a JSON string?

That's fine with me. We expect to consume this as an opaque string, right? So we should store it as a string (like the SSH pubkey) instead of parsing it out into a more detailed structure.

t.Errorf("error creating temp file: %v", err)
}
if _, err := tf.Write(pullSecretContents); err != nil {
t.Errorf("error writing to temp file %q: %v", tf.Name(), err)
Copy link
Member

Choose a reason for hiding this comment

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

To clarify my earlier comments, I don't think we want to store the pull secret path at all, and that we should replace PullSecretPath with a PullSecret string in the Cluster type. Then there would be no need for a temporary file here. The only filesystem connection would be on input, where we would provide users with the option to load the pull secret from a file. I set up something similar for SSH pubkeys here. For pull secrets, I expect the logic to be something like:

Pull secret:
Enter your pull secret as a single line of JSON (e.g. '{...}') or as a path to a file containing the pull secret JSON.

Then use an "is this valid JSON?" on the result. If it is, assume it's the pull secret. If not, assume it's the path and try to load valid JSON from the path. If you can't, complain about it and post the prompt again.

We have an existing "does this file contain valid JSON?" check here, but I think you'll want something like this to make it easy to get good invalid-JSON error messages for both strings and files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wking
I'm sure we can change the Cluster type to store the pull secret. But i'm not convinced this the PR to change how we consume the pullsecret in Cluster

Copy link
Member

Choose a reason for hiding this comment

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

I'm sure we can change the Cluster type to store the pull secret. But i'm not convinced this the PR to change how we consume the pullsecret in Cluster

I've filed #208 with the file -> string change. I'm fine landing that PR first and then rebasing this one on top (which would let you drop this temp file, etc.). I'm also fine landing this PR first and rebasing mine on top. Which way do you want to go?

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 can rebase on top of 208

@abhinavdahiya
Copy link
Contributor Author

@wking PTAL updated to use PullSecret string

@@ -95,6 +101,105 @@ func (c *ConfigGenerator) TectonicSystem() (string, error) {
})
}

// InstallConfig returns, if successful, a yaml string for on-disk install-config from 4.0 installer.
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 reword to be more generic (no need to mention disks or 4.0). Maybe something like:

InstallConfig returns a YAML-rendered Kubernetes object with the user-supplied cluster configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

PullSecret: c.PullSecret,
}

ic.Networking.Type = types.NetworkType(string(c.Networking.Type))
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe move this into the ic literal above? Nothing in this line strikes me as something that couldn't happen there (e.g. no returned errors or other conditionals to deal with).

You could also move the podCIDR, serviceCIDR, and other setup to the top of this function, and then have a single:

return &types.InstallConfig{
  ...
}, nil

at the end if they all succeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

embedding the Openshift's InstallConfig in clusters created by tectonic
installer binary allows operators to start building on their config discovery
logic.
@wking
Copy link
Member

wking commented Sep 6, 2018

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, wking

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [abhinavdahiya,wking]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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.

4 participants