Skip to content

Commit 0e853c3

Browse files
authored
Merge branch 'master' into adtls
2 parents 0996087 + b4fdcea commit 0e853c3

9 files changed

Lines changed: 56 additions & 8 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ FEATURES:
44

55
* **New Argument:** `rancher2_auth_config_keycloak.entity_id` - (Optional/Computed) KeyCloak Client ID field (string)
66
* **New Argument:** `rancher2_auth_config_activedirectory.start_tls` - (Optional/Computed) Enable start TLS connection (bool)
7+
* **New Argument:** `rancher2_node_pool.drain_before_delete` - (Optional) Drain nodes before delete (bool)
78

89
ENHANCEMENTS:
910

@@ -12,6 +13,7 @@ ENHANCEMENTS:
1213
* Updated `rancher2_cluster.rke_config.cloud_provider.name` argument from `Optional/Computed` to `Optional`
1314
* Updated `rancher2_cluster` resource to replace RKE cluster API info instead of update, if `rancher2_cluster.rke_config` has been updated
1415
* Updated `rancher2_project` resource to replace project API info instead of update
16+
* Updated `rancher2_node_template.engine_install_url` argument to be `computed`
1517

1618
BUG FIXES:
1719

docs/resources/node_pool.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ The following arguments are supported:
6565
* `hostname_prefix` - (Required) The prefix for created nodes of the Node Pool (string)
6666
* `node_template_id` - (Required) The Node Template ID to use for node creation (string)
6767
* `delete_not_ready_after_secs` - (Optional) Delete not ready node after secs. For Rancher v2.3.3 or above. Default `0` (int)
68+
* `drain_before_delete` - (Optional) Drain nodes before delete. Default: `false` (bool)
6869
* `node_taints` - (Required) Node taints. For Rancher v2.3.3 or above (List)
6970
* `control_plane` - (Optional) RKE control plane role for created nodes (bool)
7071
* `etcd` - (Optional) RKE etcd role for created nodes (bool)

docs/resources/node_template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ The following arguments are supported:
9696
* `driver_id` - (Optional/Computed) The node driver id used by the node template. It's required if the node driver isn't built in Rancher (string)
9797
* `engine_env` - (Optional) Engine environment for the node template (string)
9898
* `engine_insecure_registry` - (Optional) Insecure registry for the node template (list)
99-
* `engine_install_url` - (Optional) Docker engine install URL for the node template. Default `https://releases.rancher.com/install-docker/18.09.sh`. Available install docker versions at `https://github.com/rancher/install-docker` (string)
99+
* `engine_install_url` - (Optional/Computed) Docker engine install URL for the node template. Available install docker versions at `https://github.com/rancher/install-docker` (string)
100100
* `engine_label` - (Optional) Engine label for the node template (string)
101101
* `engine_opt` - (Optional) Engine options for the node template (map)
102102
* `engine_registry_mirror` - (Optional) Engine registry mirror for the node template (list)
@@ -110,7 +110,7 @@ The following arguments are supported:
110110
* `annotations` - (Optional) Annotations for Node Template object (map)
111111
* `labels` - (Optional/Computed) Labels for Node Template object (map)
112112

113-
**Note** `annotations`, `labels` and `node_taints` will be applied to nodes deployed using the Node Template
113+
**Note** `labels` and `node_taints` will be applied to nodes deployed using the Node Template
114114

115115
## Attributes Reference
116116

rancher2/resource_rancher2_node_pool.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ func resourceRancher2NodePoolUpdate(d *schema.ResourceData, meta interface{}) er
102102
update := map[string]interface{}{
103103
"hostnamePrefix": d.Get("hostname_prefix").(string),
104104
"deleteNotReadyAfterSecs": int64(d.Get("delete_not_ready_after_secs").(int)),
105+
"drainBeforeDelete": d.Get("drain_before_delete").(bool),
105106
"nodeTemplateId": d.Get("node_template_id").(string),
106107
"nodeTaints": expandTaints(d.Get("node_taints").([]interface{})),
107108
"quantity": int64(d.Get("quantity").(int)),

rancher2/schema_common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func commonAnnotationLabelFields() map[string]*schema.Schema {
2222
Description: "Annotations of the resource",
2323
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
2424
// Supressing diff for annotations containing cattle.io/
25-
if (strings.Contains(k, commonAnnotationLabelCattle) || strings.Contains(k, commonAnnotationLabelRancher)) && old != "" && new == "" {
25+
if (strings.Contains(k, commonAnnotationLabelCattle) || strings.Contains(k, commonAnnotationLabelRancher)) && new == "" {
2626
return true
2727
}
2828
return false
@@ -35,7 +35,7 @@ func commonAnnotationLabelFields() map[string]*schema.Schema {
3535
Description: "Labels of the resource",
3636
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
3737
// Supressing diff for labels containing cattle.io/
38-
if (strings.Contains(k, commonAnnotationLabelCattle) || strings.Contains(k, commonAnnotationLabelRancher)) && old != "" && new == "" {
38+
if (strings.Contains(k, commonAnnotationLabelCattle) || strings.Contains(k, commonAnnotationLabelRancher)) && new == "" {
3939
return true
4040
}
4141
return false

rancher2/schema_node_pool.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ func nodePoolFields() map[string]*schema.Schema {
4040
Default: 0,
4141
ValidateFunc: validation.IntAtLeast(0),
4242
},
43+
"drain_before_delete": {
44+
Type: schema.TypeBool,
45+
Optional: true,
46+
},
4347
"control_plane": {
4448
Type: schema.TypeBool,
4549
Optional: true,

rancher2/schema_node_template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func nodeTemplateFields() map[string]*schema.Schema {
9595
"engine_install_url": {
9696
Type: schema.TypeString,
9797
Optional: true,
98-
Default: "https://releases.rancher.com/install-docker/18.09.sh",
98+
Computed: true,
9999
},
100100
"engine_label": {
101101
Type: schema.TypeMap,

rancher2/structure_node_pool.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func flattenNodePool(d *schema.ResourceData, in *managementClient.NodePool) erro
1616
d.Set("cluster_id", in.ClusterID)
1717
d.Set("name", in.Name)
1818
d.Set("delete_not_ready_after_secs", int(in.DeleteNotReadyAfterSecs))
19+
d.Set("drain_before_delete", in.DrainBeforeDelete)
1920
d.Set("hostname_prefix", in.HostnamePrefix)
2021
d.Set("node_template_id", in.NodeTemplateID)
2122

@@ -56,6 +57,7 @@ func expandNodePool(in *schema.ResourceData) *managementClient.NodePool {
5657
obj.ClusterID = in.Get("cluster_id").(string)
5758
obj.Name = in.Get("name").(string)
5859
obj.DeleteNotReadyAfterSecs = int64(in.Get("delete_not_ready_after_secs").(int))
60+
obj.DrainBeforeDelete = in.Get("drain_before_delete").(bool)
5961
obj.HostnamePrefix = in.Get("hostname_prefix").(string)
6062
obj.NodeTemplateID = in.Get("node_template_id").(string)
6163

rancher2/structure_node_pool_test.go

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,70 @@ import (
99
)
1010

1111
var (
12-
testNodePoolConf *managementClient.NodePool
13-
testNodePoolInterface map[string]interface{}
12+
testNodePoolNodeTaintsConf []managementClient.Taint
13+
testNodePoolNodeTaintsInterface []interface{}
14+
testNodePoolConf *managementClient.NodePool
15+
testNodePoolInterface map[string]interface{}
1416
)
1517

1618
func init() {
19+
testNodePoolNodeTaintsConf = []managementClient.Taint{
20+
{
21+
Key: "key",
22+
Value: "value",
23+
Effect: "recipient",
24+
TimeAdded: "time_added",
25+
},
26+
}
27+
testNodePoolNodeTaintsInterface = []interface{}{
28+
map[string]interface{}{
29+
"key": "key",
30+
"value": "value",
31+
"effect": "recipient",
32+
"time_added": "time_added",
33+
},
34+
}
1735
testNodePoolConf = &managementClient.NodePool{
1836
ClusterID: "cluster-test",
1937
Name: "test",
2038
DeleteNotReadyAfterSecs: 0,
39+
DrainBeforeDelete: true,
2140
HostnamePrefix: "terraform-test",
41+
NodeTaints: testNodePoolNodeTaintsConf,
2242
NodeTemplateID: "node-test",
2343
Quantity: 3,
2444
ControlPlane: true,
2545
Etcd: true,
2646
Worker: true,
47+
Annotations: map[string]string{
48+
"one": "one",
49+
"two": "two",
50+
},
51+
Labels: map[string]string{
52+
"option1": "value1",
53+
"option2": "value2",
54+
},
2755
}
2856
testNodePoolInterface = map[string]interface{}{
2957
"cluster_id": "cluster-test",
3058
"name": "test",
3159
"delete_not_ready_after_secs": 0,
60+
"drain_before_delete": true,
3261
"hostname_prefix": "terraform-test",
62+
"node_taints": testNodePoolNodeTaintsInterface,
3363
"node_template_id": "node-test",
3464
"quantity": 3,
3565
"control_plane": true,
3666
"etcd": true,
3767
"worker": true,
68+
"annotations": map[string]interface{}{
69+
"one": "one",
70+
"two": "two",
71+
},
72+
"labels": map[string]interface{}{
73+
"option1": "value1",
74+
"option2": "value2",
75+
},
3876
}
3977
}
4078

@@ -62,7 +100,7 @@ func TestFlattenNodePool(t *testing.T) {
62100
}
63101
if !reflect.DeepEqual(expectedOutput, tc.ExpectedOutput) {
64102
t.Fatalf("Unexpected output from flattener.\nExpected: %#v\nGiven: %#v",
65-
expectedOutput, output)
103+
expectedOutput, tc.ExpectedOutput)
66104
}
67105
}
68106
}

0 commit comments

Comments
 (0)