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

Spot Priority support for AKS #7145

Closed
wants to merge 1 commit into from
Closed

Conversation

pbrit
Copy link

@pbrit pbrit commented May 31, 2020

  • Support of Spot Priority for azurerm_kubernetes_cluster_node_pool
  • node_taints and node_labels were marked as computed and they must force a pool recreation.

The initial work was started as #6231

Fixes #6086

Co-Authored-By: Alok Kumar [email protected]

TODO

  • Add test coverage
  • Update documentation
  • Rename spot_price to max_bid_price

@pbrit
Copy link
Author

pbrit commented May 31, 2020

@tombuildsstuff Although I'm still working on the remaining items, I'd like to know your opinion regarding the implementation. Thank you.

* Support of Spot Priority for `azurerm_kubernetes_cluster_node_pool`
* `node_taints` and `node_labels` were marked as *computed* and they must force a new pool resource
* Add `max_bid_price` validation for `windows_virtual_machine_scale_set`
   and `linux_virtual_machine_scale_set`

The initial work was started as hashicorp#6231

Fixes hashicorp#6086

Co-Authored-By: Alok Kumar <[email protected]>
@pbrit
Copy link
Author

pbrit commented Jun 4, 2020

@tombuildsstuff, @jackofallops, @katbyte As far as I'm concerned the implementation is ready. Please let me know what I can do to make it merged.

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @pbrit

Thanks for this PR - apologies for the delayed review here!

Since there's a number of other Pull Requests currently open for AKS - to be able to merge all of these without them all conflicting, I've first reviewed each PR - and then worked to pull these into a single branch locally (before making any necessary fixes from the comments).

Taking a look through this PR is looking pretty good and I've left some comments inline - however we need to take a slightly different approach for a few of the fields (e.g. making the node labels/taints fields non-computed, and remove the customizeDiff).

I've spent some time trying to integrate these commits into the "consolidation" branch I've got locally and unfortunately had issues doing so. As such to be able to ship support for this with these changes, I've ended up having to re-implement these changes atop this branch. Whilst I appreciate that isn't ideal (and we'd like to retain authorship information for both yourself and @rajalokan) - that does allow these changes to ship.

As such, whilst I'd like to thank you for opening this Pull Request, I'm going to close this in favour of #7233 which adds support for both these changes (and the other open AKS PR's - and includes some of the other open Feature Requests).

Thanks!


"spot_price": {
Type: schema.TypeFloat,
Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is a Data Source these fields are read-only - as such can we make this:

Suggested change
Optional: true,
Computed: true,


"eviction_policy": {
Type: schema.TypeString,
Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is a Data Source these fields are read-only - as such can we make this:

Suggested change
Optional: true,
Computed: true,


"priority": {
Type: schema.TypeString,
Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is a Data Source these fields are read-only - as such can we make this:

Suggested change
Optional: true,
Computed: true,

@@ -113,15 +113,16 @@ func resourceArmKubernetesClusterNodePool() *schema.Resource {
"node_labels": {
Type: schema.TypeMap,
Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

per the documentation users should expect a label of kubernetes.azure.com/scalesetpriority:spot when provisioning - as such I think we can remove Computed here since users should have to specify this - instead we can document this in the examples

Suggested change
Computed: true,

},

"node_taints": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

(same here) with the taint kubernetes.azure.com/scalesetpriority=spot:NoSchedule

Suggested change
Computed: true,

Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: string(containerservice.Delete),
Copy link
Contributor

Choose a reason for hiding this comment

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

since this default value is only applicable when using Spot instances (and this field is Optional) - can we remove this?

Suggested change
Default: string(containerservice.Delete),

Elem: &schema.Schema{
Type: schema.TypeString,
},
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

(as above) we want to remove Computed here

Suggested change
Computed: true,

Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

(as above) we want to remove Computed here:

Suggested change
Computed: true,


if fractionalPart > 0 {
errors = append(errors, fmt.Errorf("%q can only include up to 5 digits after the radix point, got %g", key, v))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this'll work when a users input 0.000001 - but won't work for 0.000010 which the API will reject; as such unfortunately I think we need to make this:

	// either -1 (the current VM price)
	if v == -1.0 {
		return
	}

	// at least 0.00001
	if v < 0.00001 {
		errors = append(errors, fmt.Errorf("expected %q to be > 0.00001 but got %.5f", k, v))
		return
	}

for it to be consistent

@@ -39,6 +40,8 @@ func resourceArmKubernetesClusterNodePool() *schema.Resource {
Delete: schema.DefaultTimeout(60 * time.Minute),
},

CustomizeDiff: customizeDiff,
Copy link
Contributor

Choose a reason for hiding this comment

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

can we remove the customizeDiff here? unfortunately this is broken when a field is interpolated (most of the time)

@ghost
Copy link

ghost commented Jul 5, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Jul 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for spot node pool in azurerm_kubernetes_cluster
3 participants