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

Containerservices addonprofile #1502

Closed
wants to merge 24 commits into from

Conversation

lfshr
Copy link
Contributor

@lfshr lfshr commented Jul 5, 2018

Added addon_profile functionality to kubernetes clusters

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 @lfshr

Thanks for this PR - I've taken a look through and left some comments in-line but this mostly LGTM; if we can fix up the comments then we should be able to run the tests and get this merged

Thanks!

addonProfile := map[string]interface{}{
"name": k,
"enabled": *v.Enabled,
"config": flattenAzureRmKubernetesClusterAddonProfileConfig(v.Config),
Copy link
Contributor

Choose a reason for hiding this comment

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

minor we can just inline this method; e.g.

addonProfile := map[string]interface{}{ ... }

config := make(map[string]string, 0)
for k, v := range v.Config {
  config[k] = v
}
addonProfile["config"] = config

for k, v := range profile {
addonProfile := map[string]interface{}{
"name": k,
"enabled": *v.Enabled,
Copy link
Contributor

Choose a reason for hiding this comment

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

there's a potential crash if this isn't returned, can we nil-check this? e.g.

addonProfile := map[string]interface{}{ ... }
if enabled := v.Enabled; enabled != nil {
  addonProfile["enabled"] = *enabled
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that still the case on a Required field, should I do some kind of error handling here if it's nil or is the nil check all that's needed? Good spot. I totally missed that.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is the response coming back from the API, which can be nil due to bugs in the API / changes in the schema over time (this is something we've learnt over time, unfortunately) - so we need to check it either way unfortunately

configValue := make(map[string]*string)
for k, v := range addonConfig {
configEntry := v.(string)
configValue[k] = &configEntry
Copy link
Contributor

Choose a reason for hiding this comment

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

minor we can combine these to make: utils.String(v.(string))

@@ -209,6 +209,33 @@ func resourceArmKubernetesCluster() *schema.Resource {
Set: resourceAzureRMKubernetesClusterServicePrincipalProfileHash,
},

"addon_profile": {
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 document these new fields in the docs? this file's located at ./website/docs/r/kubernetes_cluster.html

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 also add an acceptance test covering these new fields?

@lfshr
Copy link
Contributor Author

lfshr commented Jul 6, 2018

@tombuildsstuff Code updated to reflect your comments. This PR should be good to go.

@lfshr
Copy link
Contributor Author

lfshr commented Jul 10, 2018

@tombuildsstuff following further on our discussion, the lack of documentation on addonProfiles is due to a known issue. Do I take what I know at face value for the minute, and revisit the schema after the documentation is finished, or do you want to hold off until then?

MicrosoftDocs/azure-docs#11090

@lfshr
Copy link
Contributor Author

lfshr commented Jul 26, 2018

@tombuildsstuff now that advanced networking is done I'm turning my attention to this. Can you have a look at the latest commits (cea7faa and 1217732) and tell me if that's more what you're looking for? Only have HttpApplicationRouting enabled at the moment.

I'm going on holiday on Saturday for two weeks. I'll try my best to finish this but if I fail, feel free to continue.

@tombuildsstuff tombuildsstuff self-assigned this Aug 2, 2018
@metacpp metacpp self-requested a review August 3, 2018 00:53
@tombuildsstuff tombuildsstuff removed the request for review from metacpp August 8, 2018 16:34
@tombuildsstuff
Copy link
Contributor

hey @lfshr

Sorry for the delayed re-review here - I've taken a look into this and merged master into this branch / have resolved the merge conflicts by adding the changes from this PR back in. Since I don't have permission to push to your fork - I've had to push to this repo and have opened #1751 which includes your original commits plus the updates required to get this merged - I hope you don't mind!

Thanks!

@lfshr
Copy link
Contributor Author

lfshr commented Aug 10, 2018

@tombuildsstuff no problem at all. Thanks very much for continuing this. I ran out of time before my holiday I'm afraid 😞

Arrived back last night so let me know if there's anything else you need me to do.

@tombuildsstuff
Copy link
Contributor

@lfshr all good - apologies for the delay getting this merged; we've been heads-down trying to work through some larger cross-provider items (e.g. #1746 / #1728) over the past couple of weeks

tombuildsstuff added a commit that referenced this pull request Aug 14, 2018
* Added kubernetes_cluster advanced network creation

* Changed network_profile from TypeSet to TypeList

* Added kubernetes_cluster advanced network creation

* Changed network_profile from TypeSet to TypeList

* Updated ForceNew attributes on kubernetes_cluster.network_profile params

* Added advanced network read functionality

* Added tests for kubernetes_cluster.network_profile

* Fixed indentations

* Fixed function name in tests

* Fixed property name in test

* Fixed variable name

* working on data source for kubernetes cluster

* Fixed issue with datasource not working

* Added network_policy and fixed read

* Removed network_policy as unsupported

* Added example of advanced networking

* Added test for data_source

* Made address space more sensible

* Removing kubenet test.
This is default when network_profile is not specified.
We already test this.

* Made network_plugin a mandatory field.
Better to make this explicit.

* Updated documentation to include network_profile

* Fixing the build

* Added ForceNew to network_profile

* Made the docs a little clearer

* Documenting a required field

* Rephrasing the data sources

* Making the `network_profile` block computed

Tests pass:

```
$ acctests azurerm TestAccAzureRMKubernetesCluster_basic
=== RUN   TestAccAzureRMKubernetesCluster_basic
--- PASS: TestAccAzureRMKubernetesCluster_basic (1329.57s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm	1329.613s
```

* Fixing the field we're asserting on

* Conditionally expanding the network_profile block.

The ip fields are now Computed too

* Validation to ensure that a Subnet ID is assigned to the cluster when the network_profile blocks specified

Example:

```

Error: Error running plan: 1 error(s) occurred:

* azurerm_kubernetes_cluster.test: 1 error(s) occurred:

* azurerm_kubernetes_cluster.test: If a `network_profile` block is specified, the Agent Pools must be attached to a Subnet

```

* Updating the documentation to mention the new behaviour

* Adding independent tests for Kubenet and Azure networking profiles

* Conditional validation of the `docker_bridge_cidr`, `dns_service_ip` and `service_cidr` fields.

* Updating the docs

* Fixing the tests

* Adding back in the changes from PR #1502 since they were lost in the merge

* Renaming the methods to `addonProfiles` to match the sdk

* fixing the quotes
@lfshr lfshr deleted the containerservices-addonprofile branch August 14, 2018 12:51
@ghost
Copy link

ghost commented Mar 30, 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 Mar 30, 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.

2 participants