-
Notifications
You must be signed in to change notification settings - Fork 202
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
Mvp #17
Conversation
FYI @trawler @ingvagabund |
There was a problem hiding this 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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 != "" { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
@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. |
There was a problem hiding this 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).
[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 |
This PR includes a binary file |
cleaned this up to a mergeable state. Follow ups:
|
apiVersion: "cluster.k8s.io/v1alpha1" | ||
kind: Cluster | ||
metadata: | ||
name: test |
There was a problem hiding this comment.
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
Provides a minimum functional integration for the installer with the machine API and machineSets
See:
openshift/installer#119
enxebre/cluster-api-provider-aws#11