-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
add an API for machinepool -> machinesets #573
add an API for machinepool -> machinesets #573
Conversation
@dgoodwin if hive wants to create new machinsets/machines, later on, this API requires defaulting for that to be handled explicitly. I don't think installer's defaults make sense then? |
The problem is Hive would expose an API with fields that are optional and would need defaults, we would convert to InstallConfig and pass to you, but we have no way to know what defaults were applied. As the cluster lives on and we maintain machine sets, we're still just operating off that config the user specified which may not have all fields set. Is there a reason this API can't apply the same defaults as it did during install? Or do we need shared APIs to calculate defaults and apply to an install config? |
Thinking about this some more, the AMI specifically can't be a live lookup, it would change over time which we don't want. I think we may need to have Hive explicitly apply defaults that match yours? |
Can you use sentinel values for "I don't care, let the installer choose"? Then just leave those unset in your install-config (related: #263), and we'll fill in our defaults for the unset fields. I'm not sure if we do that at the moment, but it shouldn't be too hard. |
we already default.
@dgoodwin installer cannot choose sane default after installation. hive will have to create its own merge/update logic.
thinking hive as an operator; you should fetch the live machineset, use this api with values to create expected state and then merge them based on some logic... |
Yes talking about this with @csrwng I think we're going to want to apply our own defaults, possibly with re-used code between our two projects again. The AMI specifically can't change so we can't hand off to have a default reapplied. |
18423f2
to
a07e0c2
Compare
so this is good to go as-is ? |
I think so yes, thanks. |
an |
@@ -49,6 +49,17 @@ ignored = ["github.com/openshift/installer/tests*"] | |||
name = "k8s.io/client-go" | |||
version = "6.0.0" | |||
|
|||
[[constraint]] | |||
name = "sigs.k8s.io/cluster-api" | |||
branch = "master" |
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 we really want these floating with master? Can we pin to their current tips and then manually bump when they make changes?
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.
master
is fine
pkg/asset/machines/aws/master.go
Outdated
}, | ||
Versions: clusterapi.MachineVersionInfo{ | ||
Kubelet: "", | ||
ControlPlane: "", |
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'd still rather leave Versions
unset and file issues or set a FIXME about these two parameters. Setting them to empty strings doesn't make sense to me.
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.
This is explicitly saying don't care about version for these, we have different mechanism for controlling them.
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.
This is explicitly saying don't care about version for these we have diff mechanism for controlling them.
But you can use zero-values for that, no?
$ cat test.go
package main
import (
"fmt"
clusterapi "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
)
func main() {
spec := clusterapi.MachineSpec{}
fmt.Printf("%q %t\n", spec.Versions.Kubelet, spec.Versions.Kubelet == "")
}
$ go run test.go
"" true
Sorry @abhinavdahiya didn't know we could, or should, be lgtm'ing in your repo. Going to hold off now though and let @wking |
a07e0c2
to
39f31cb
Compare
@wking wants the api to move to this: $ godoc ./pkg/asset/machines/aws
PACKAGE DOCUMENTATION
package aws
import "./pkg/asset/machines/aws"
Package aws generates Machine objects for aws.
FUNCTIONS
func AvailabilityZones(region string) ([]string, error)
AvailabilityZones retrieves a list of availability zones for the given
region.
func MachineSets(config *types.InstallConfig, pool *types.MachinePool, role, userDataSecret string) ([]clusterapi.MachineSet, error)
MachineSets returns a list of machinesets for a machinepool.
func Machines(config *types.InstallConfig, pool *types.MachinePool, role, userDataSecret string) ([]clusterapi.Machine, error)
Machines returns a list of machines for a machinepool.
$ godoc ./pkg/asset/machines/libvirt
PACKAGE DOCUMENTATION
package libvirt
import "./pkg/asset/machines/libvirt"
Package libvirt generates Machine objects for libvirt.
FUNCTIONS
func MachineSets(config *types.InstallConfig, pool *types.MachinePool, role, userDataSecret string) ([]clusterapi.MachineSet, error)
MachineSets returns a list of machinesets for a machinepool.
func Machines(config *types.InstallConfig, pool *types.MachinePool, role, userDataSecret string) ([]clusterapi.Machine, error)
Machines returns a list of machines for a machinepool. pushed commits to match that. |
39f31cb
to
be2edc9
Compare
pkg/asset/machines/aws/machines.go
Outdated
ProviderConfig: clusterapi.ProviderConfig{ | ||
Value: &runtime.RawExtension{Object: &provider}, | ||
}, | ||
Versions: clusterapi.MachineVersionInfo{ |
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.
Did you not find my zero-value demonstration convincing? ;)
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.
these values have a meaning upstream, but set them to ""
so anybody that sees this code understands that these values to set to ""
because we have different mechanics to control them.
From the consumer end it makes no difference.
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.
... anybody that sees this code understands that these values to set to "" because we have different mechanics to control them...
This is not obvious to me from reading the code ;). How about:
Spec: clusterapi.MachineSpec{
ProviderConfig: clusterapi.ProviderConfig{
Value: &runtime.RawExtension{Object: &provider},
},
// we don't need to set Versions, because we control those via {reference our different mechanism}
}
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.
This is not obvious to me from reading the code ;).
Well in that case, hopefully // we don't need to set Versions, because we control those via {reference our different mechanism}
does the job
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.
be2edc9
to
501d59f
Compare
k8s.io/utils/pointer provider various type to *type converts which are helpful
501d59f
to
d562522
Compare
Currently the Machine and MachineSet objects are go templates. Moving them to vendored code allows other consumers like openshift/hive to use these public helpers effectively. openstack platform still uses go templates because of vendoring problems.
d562522
to
476be07
Compare
@wking tests are green :) |
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.
/lgtm
[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:
Approvers can indicate their approval by writing |
Empty machinepool is a valid for libvirt because we don't use it. Fixes the error ```console FATAL Error executing openshift-install: non-Libvirt machine-pool: "" `` introduced in openshift#573
openshift#573 had wrong calculation for machine objects in AWS.
…orm}.Name The old *PlatformType are from cccbb37 (Generate installation assets via a dependency graph, 2018-08-10, openshift#120), but since 476be07 (pkg/asset: use vendored cluster-api instead of go templates, 2018-10-30, openshift#573), we've had variables for the name strings in the more central pkg/types. With this commit, we drop the more peripheral forms. I've also pushed the types.PlatformName{Platform} variables down into types.{platform}.Name at Ahbinav's suggestion [1]. I've added a unit test to enforce sorting in PlatformNames, because the order is required by sort.SearchStrings in queryUserForPlatform. [1]: openshift#659 (comment)
https://github.com/openshift/hive/ recommended that installer expose some api so that the machine and machineset generation for machinepool can be reused.
/cc @dgoodwin @rajatchopra
@dgoodwin
builds on #567