-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 the ability to configure disk size and type for GCP clusters (Kube Deploy 638) #77
Conversation
Hi @spew. Thanks for your PR. I'm waiting for a kubernetes or kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
/test all |
Rebased on top of the latest. |
/retest |
/test all |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: spew Assign the PR to them by writing 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 |
cloud/google/machineactuator.go
Outdated
for idx, disk := range config.Disks { | ||
diskSizeGb := disk.InitializeParams.DiskSizeGb | ||
if diskSizeGb < minDiskSizeGb { | ||
diskSizeGb = minDiskSizeGb |
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.
Might want to spit out a warning log that the configuration is bad and you are defaulting to the min.
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.
Yes, will do.
} | ||
return c.mockZoneOperationsGet(project, zone, operation) | ||
} | ||
|
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 would suggest creating the cluster and machine in the code instead of parsing yaml files. Parsing is the CLI tool's job and not the machine actuator's job. Plus, it is easier to test more dynamic scenarios when the objects are not hardcoded in a file somewhere.
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.
There's some complexity here in that "machineactuator.go" expects to decode() the raw bytes of machine.Spec.ProviderConfig. For that reason I was trying to use yaml to setup various scenarios as it requires less changes.
I'm experimenting with some other ideas where the decoding() is decoupled from machineactuator.go. I will likely update the PR with a different approach.
cloud/google/machineactuator_test.go
Outdated
return c.mockZoneOperationsGet(project, zone, operation) | ||
} | ||
|
||
func TestOneDisk(t *testing.T) { |
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 may have just not seen it but is there a test for your logic which will set the min disk size if the given disk size is too small?
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.
Yeah, we should add this test. I will do so. Note that this is pre-existing behavior as of a few days ago where another commit effectively set the disk size to 30GB at all times.
@@ -30,4 +30,15 @@ type GCEProviderConfig struct { | |||
|
|||
// The name of the OS to be installed on the machine. | |||
OS string `json:"os"` | |||
Image string `json:"image"` |
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 OS is what eventually maps to the OS Image. Why is this field being introduced in this PR?
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 was added as an error with resolving a merge conflict. Removing.
Disks []Disk `json:"disks"` | ||
} | ||
|
||
type Disk struct { |
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.
Since you are modifying the the gce provider config, remember to bump all relevant images after merge. eg. the gce-machine-actuator image.
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.
Thanks for the reminder -- I was not aware of this.
@@ -183,3 +185,16 @@ func (MachineSchemeFns) DefaultingFunction(o interface{}) { | |||
// set default field values here | |||
log.Printf("Defaulting fields for Machine %s\n", obj.Name) | |||
} | |||
|
|||
func ParseMachineYaml(file string) (*Machine, error) { |
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 seems awfully specific to the machine actuator tests.
It is assuming that the file contains only one machine object and no other objects. Perhaps it is better to co-locate such logic with the tests and then promote to a common location if other code actually uses it?
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 will be removed in a future revision of this PR.
After revisiting things to rebase on top of latest as well as attempt to use test fixtures / objects for machine/cluster instead of YAML I reworked things quite a bit. I have a prerequisite commit / PR open here: Until that is through, please ignore this PR: |
PR 130 is through and committed, so I rebased this commit on top of the latest and it is ready for review again. |
aae9762
to
0b4e29e
Compare
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 (allowing krousey to provide backslash)
cloud/google/machineactuator.go
Outdated
for idx, disk := range config.Disks { | ||
diskSizeGb := disk.InitializeParams.DiskSizeGb | ||
if diskSizeGb < minDiskSizeGb { | ||
glog.Info("increasing disk size to %$v gb, the supplied disk size of %v gb is below the minimum", minDiskSizeGb, diskSizeGb) |
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.
Is the %$v intentional?
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.
(nit)
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.
Not a nit -- definitely a mistake. Will correct as well as rebase on top of the latest changes (they look significant).
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.
Ah. In that case, I will withdraw my approval so the PR dashboard will tell me to take a look after the rebase.
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.
Ah. In that case, I will withdraw my approval so the PR dashboard will tell me to take a look after the rebase.
PR is rebased onto the tip of 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.
lgtm (allowing krousey to provide backslash)
@krousey Have you had a chance to look at this before I click merge? |
@spew I've been out for a bit. Looking now. Do no click merge. |
} | ||
|
||
type Disk struct { | ||
InitializeParams DiskInitializeParams `json:"initializeParams"` |
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.
Why add this level of indirection? Wouldn't
disks:
- diskSizeGb: 30
diskType: "pd-standard"
- diskSizeGb: 50
diskType: "pd-standard"
work?
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.
It would be then it would not match the GCE API / structure which is I thought what we wanted to do. It has the InitializeParams structure.
https://cloud.google.com/compute/docs/reference/rest/beta/instances/insert
Do agree what you are proposing is fine too -- let me know if you want to move to that structure.
cloud/google/machineactuator.go
Outdated
AutoDelete: true, | ||
Boot: idx == 0, | ||
InitializeParams: &compute.AttachedDiskInitializeParams{ | ||
SourceImage: imagePath, |
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 think image path is only for the boot disk.
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.
While all disks can have an image, this is a good catch in that the intention of this change was not to put the image on disks other than the boot disk! I'll change this and add a test for this scenario.
return &codec, nil | ||
} | ||
|
||
func (codec *GCEProviderConfigCodec) DecodeFromProviderConfig(providerConfig clusterv1.ProviderConfig) (*GCEProviderConfig, error) { |
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.
cc @mkjelland
I think we're going to move to where we have separate config for clusters and machines, and also we're going to have provider status for both of them too. Would it be possible for this API to take a runtime.Object
to decode into instead of returning a specific type?
Also, could EncodeToProviderConfig
take a runtime.Object
as well?
This probably doesn't need to be done in this PR.
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.
Happy to take that up in a follow up, more targetted PR.
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 can take care of this in my PR to create the separate config types. I was thinking it might be nicer to have 2 methods, that way they can return the correct type. Otherwise the caller has to cast the return value to the type they want, right? Or did you have something else in ming @krousey?
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 was thinking of just having an output parameter of type runtime.Object
. That way you could do something like
func (codec *GCEProviderConfigCodec) DecodeProviderConfigInto(providerConfig runtime.RawExtension, out runtime.Object) error {...}
var blah GCEProviderConfig
err := c.DecodeProviderConfigInto(m.Spec.ProviderConfig.Value, &blah)
@@ -719,6 +705,28 @@ func (gce *GCEClient) getImagePath(img string) (imagePath string) { | |||
return defaultImg | |||
} | |||
|
|||
func newDisks(config *gceconfigv1.GCEProviderConfig, zone string, imagePath string, minDiskSizeGb int64) []*compute.AttachedDisk { |
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 min size should eventually be a validation error
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.
Yeah, min size was brought in recent time when we bumped up the min to 30 for custom images, and now for any image (as of a PR a few weeks ago). I was just trying to keep it as it was. I wonder if it should just be removed all together?
cloud/google/machineactuator_test.go
Outdated
checkDiskValues(t, receivedInstance.Disks[1], false, 45, "pd-standard") | ||
} | ||
|
||
func checkInstanceValues(t *testing.T, instance *compute.Instance, diskCount int) { |
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.
Perhaps make use of https://golang.org/pkg/testing/#T.Helper
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.
Nice, that is really useful.
This change adds the ability for GCP clusters to have custom sized disks and types.
Updated post @krousey 's feedback. Noteably:
|
/lgtm |
…ker-build Add verify-docker-build to pre-submit tests
Verify manifests script
Clusterctl create cluster was not able to properly create the target cluster. It would sit in an infinite loop, attempting to clone the VM template. The fix was to not use annotations for task ref and vm ref during create. Instead, use provider status. Once this fix was in, the Target cluster would then sit in an infinite loop, attempting to clone the VM template. The fix was to check for nodeRef in the actuator's Exists() function. In addition, moved utils from provisioner/common to provisioner/govmomi as it's only ever used by the govmomi actuator. Fixes kubernetes-sigs#70
What this PR does / why we need it:
This PR enables administrators using gcp-deployer to customize the size and types of the disks in their clusters.
Special notes for your reviewer:
Please ignore the first commit, a5bcde4 (Refactor GCEClient: wrap compute.Service in an interface for mocking GCP compute), it is a prerequisite commit and has its own PR open here: #73.
Release note:
@kubernetes/kube-deploy-reviewers