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

Mvp #17

Merged
merged 7 commits into from
Aug 17, 2018
Merged

Mvp #17

merged 7 commits into from
Aug 17, 2018

Conversation

enxebre
Copy link
Member

@enxebre enxebre commented Aug 10, 2018

Provides a minimum functional integration for the installer with the machine API and machineSets

  • Adds operator Config
  • Adds hack to deploy machineSet object (We need to discuss which operator owns this object. machineConfig? here? its custom operator?)

See:
openshift/installer#119
enxebre/cluster-api-provider-aws#11

@enxebre enxebre added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Aug 10, 2018
@openshift-ci-robot openshift-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 10, 2018
@enxebre
Copy link
Member Author

enxebre commented Aug 10, 2018

FYI @trawler @ingvagabund

Copy link
Member

@ingvagabund ingvagabund left a comment

Choose a reason for hiding this comment

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

I commented on the individual commits so some comments may no longer apply or need to be moved a few lines down/up.

version= "v6.0.0"
[[override]]
name = "k8s.io/apimachinery"
version = "kubernetes-1.9.0"
Copy link
Member

Choose a reason for hiding this comment

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

We should fix the sigs.k8s.io/cluster-api to the latest release once there is reasonable one available. Meantime, we should fix the revision. The latest one is fbc85d97affbf5c9ad97054c66b23ad2bc0ca097. We want to be as close to the upstream as possible even though we use only the machine types (or more than just those types?). Upstream docs [1] says we can use the revision keyword:

[[constraint]]
  # Required: the root import path of the project being constrained.
  name = "github.com/user/project"
  # Recommended: the version constraint to enforce for the project.
  # Note that only one of "branch", "version" or "revision" can be specified.
  version = "1.0.0"
  branch = "master"
  revision = "abc123"

[1] https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md

cmd/main.go Outdated

go func() {
for {
// Cluster API client
Copy link
Member

Choose a reason for hiding this comment

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

Given all the variables are local to the for inner block, it would make sense to put the entire block into a named function (for better readability).

cmd/main.go Outdated
// Cluster API client
var config *rest.Config
var err error
if kubeconfig != "" {
Copy link
Member

Choose a reason for hiding this comment

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

func getConfig(kubeconfig string) (*rest.Config, error) {
	if kubeconfig != "" {
		glog.V(4).Infof("Loading kube client config from path %q", kubeconfig)
 		return clientcmd.BuildConfigFromFlags("", kubeconfig)
 	} else {
 		glog.V(4).Infof("Using in-cluster kube client config")
 		return rest.InClusterConfig()
 	}
}

and then:

config, err := getConfig(kubeconfig)

Copy link
Member

Choose a reason for hiding this comment

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

Do you need to create the config every single loop? Given the kubeconfig is not likely to be changed within the container running the machine api operator.

cmd/main.go Outdated
decode := scheme.Codecs.UniversalDeserializer().Decode

// Create Cluster object
clusterSpec, err := ioutil.ReadFile("examples/cluster.yaml") // just pass the file name
Copy link
Member

Choose a reason for hiding this comment

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

If this is going to be part of the production deployment, I would s/examples/manifests/. It looks more enterprise :). Plus, the content of the examples directory can change over time without any constraints. The manifests is more like Hey, these files might be actually used somewhere in the production code.

cmd/main.go Outdated

cluster := obj.(*clusterv1.Cluster)
_, err = client.ClusterV1alpha1().Clusters("test").Create(cluster)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

v1alphaClient := client.ClusterV1alpha1()
if _, err := v1alphaClient.Clusters("test").Create(cluster); err != nil {
	fmt.Printf("Cannot create cluster, retrying in 5 secs: %v", err)
} else {
	fmt.Printf("Created Cluster object")
}

cmd/main.go Outdated
}

// Create Machine object
machineSpec, err := ioutil.ReadFile("examples/machine.yaml") // just pass the file name
Copy link
Member

Choose a reason for hiding this comment

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

The same here: s/examples/manifests/

cmd/main.go Outdated
}

machine := obj.(*clusterv1.Machine)
_, err = client.ClusterV1alpha1().Machines("test").Create(machine)
Copy link
Member

Choose a reason for hiding this comment

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

if _, err = v1alphaClient.Machines("test").Create(machine); err != nil {
	fmt.Printf("Cannot create machine, retrying in 5 secs: %v", err)
} else {
	fmt.Printf("Created Machine object")
}

cmd/main.go Outdated
fmt.Printf("Created Machine object")
return
}
time.Sleep(5 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

maybe:

...
const retryPeriod = 5 * time.Second
...
time.Sleep(retryPeriod)

@@ -45,5 +119,9 @@ func main() {
// rendererFromFile reads the config object on demand from the path and then passes it to the
// renderer.
func rendererFromFile() []xotypes.UpgradeSpec {
return render.MakeRenderer(&render.OperatorConfig{}, manifestDir)()
config, err := render.Config(configPath)
Copy link
Member

Choose a reason for hiding this comment

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

Does it build at all? The config variable is not used anywhere in the function's body.

Copy link
Member Author

Choose a reason for hiding this comment

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

line 68

cmd/main.go Outdated
operatorConfig, err := render.Config(configPath)
fmt.Printf("configPath %#v", configPath)
if err != nil {
glog.Exitf("Error reading machine-api-operator config: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

  • Exitf logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. (see [1])
  • Fatalf logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(255). Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. (see [2]).

No matter what I still prefer the stack trace to be present. And frankly, this is the first time i see the glog.Exitf function to be used :).

[1] https://godoc.org/github.com/golang/glog#Exitf
[2] https://godoc.org/github.com/golang/glog#Fatalf

@enxebre
Copy link
Member Author

enxebre commented Aug 13, 2018

@ingvagabund thanks for having a look! To clarify, as stated in the description the way this PR deploys the machineSet it's just a dirty hack for having something to deploy the object and being able to put an e2e working PR against the installer.
We need to discuss which operator properly owns and manage the lifecycle of this object: this operator? machine config operator? needs a custom dedicated operator?)

Copy link
Contributor

@trawler trawler left a comment

Choose a reason for hiding this comment

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

cmd/cmd should be added to .gitignore so we don't push binaries into the repo.
same for anything in bin (if it doesn't already exist).

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enxebre

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:

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 Aug 14, 2018
@enxebre enxebre removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 14, 2018
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 14, 2018
@enxebre enxebre removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 14, 2018
@paulfantom
Copy link
Contributor

This PR includes a binary file cmd/cmd, @enxebre please remove it and maybe add exlusion rule to .gitconfig

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 15, 2018
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 17, 2018
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 17, 2018
@enxebre
Copy link
Member Author

enxebre commented Aug 17, 2018

cleaned this up to a mergeable state. Follow ups:

apiVersion: "cluster.k8s.io/v1alpha1"
kind: Cluster
metadata:
name: test
Copy link
Member Author

Choose a reason for hiding this comment

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

name and namespaces need to be consolidated as part of CLOUD-80

@enxebre enxebre merged commit 363ab9e into openshift:master Aug 17, 2018
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. do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants