Skip to content

Commit

Permalink
feat: alb supportd health_protocol health_port http_method
Browse files Browse the repository at this point in the history
  • Loading branch information
notone0010 committed Jun 28, 2024
1 parent a95f470 commit 24cd1c0
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

IMPROVEMENTS:

- `ksyun_alb_rule_group` 新增`http_method` 健康检查协议;
- `ksyun_alb_rule_group` 新增`http_method` 健康检查HTTP方法,`health_protocol` 健康检查协议`health_port` 健康检查端口;

## 1.15.6 (May 13, 2024)

Expand Down
17 changes: 17 additions & 0 deletions ksyun/data_source_ksyun_alb_rule_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,23 @@ func dataSourceKsyunAlbRuleGroups() *schema.Resource {
Computed: true,
Description: "The service host name of the health check.",
},
"http_method": {
Type: schema.TypeString,
Description: "The http requests' method.",
Computed: true,
},

"health_port": {
Type: schema.TypeInt,
Description: "The port of connecting for health check.",
Computed: true,
},

"health_protocol": {
Type: schema.TypeString,
Description: "The protocol of connecting for health check.",
Computed: true,
},
"alb_rule_set": {
Type: schema.TypeList,
Computed: true,
Expand Down
24 changes: 22 additions & 2 deletions ksyun/resource_ksyun_alb_rule_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,30 @@ func resourceKsyunAlbRuleGroup() *schema.Resource {
"http_method": {
Type: schema.TypeString,
Optional: true,
Description: "The http requests' method. Valid Value: GET|HEAD.",
Description: "The http requests' method. Valid Value: GET|HEAD. It works, when `health_protocol` is HTTP.",
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"GET", "HEAD"},
false),
Computed: true,
DiffSuppressFunc: AlbRuleGroupSyncOffDiffSuppressFunc,
},

"health_port": {
Type: schema.TypeInt,
Optional: true,
Description: "The port of connecting for health check. It works, when `listener_sync` is off.",
Computed: true,
ValidateFunc: validation.IntBetween(1, 65535),
DiffSuppressFunc: AlbRuleGroupSyncOffDiffSuppressFunc,
},

"health_protocol": {
Type: schema.TypeString,
Optional: true,
Description: "The protocol of connecting for health check. It works, when `listener_sync` is off.",
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"HTTP", "TCP"},
false),
DiffSuppressFunc: AlbRuleGroupSyncOffDiffSuppressFunc,
},

"interval": {
Expand Down
17 changes: 17 additions & 0 deletions ksyun/service_ksyun_alb_rule_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,23 @@ func (s *AlbRuleGroup) modifyRuleGroupCall(d *schema.ResourceData, r *schema.Res
}
}
}

if d.HasChange("health_protocol"); d.Get("health_protocol") == "HTTP" {
transform["url_path"] = SdkReqTransform{
forceUpdateParam: true,
}

transform["http_method"] = SdkReqTransform{
forceUpdateParam: true,
ValueFunc: func(data *schema.ResourceData) (interface{}, bool) {
methodValue, ok := data.GetOk("http_method")
if !ok {
return "HEAD", true
}
return methodValue, true
},
}
}
}

switch d.Get("type") {
Expand Down
13 changes: 12 additions & 1 deletion ksyun/utils_ksyun_diff_suppress_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,18 @@ func AlbRuleGroupSyncOffDiffSuppressFunc(k, old, new string, d *schema.ResourceD
if n := d.Get("session_state"); n == "start" {
return false
}
case "interval", "timeout", "healthy_threshold", "unhealthy_threshold", "url_path", "host_name":

// health check
case "interval", "timeout", "healthy_threshold", "unhealthy_threshold",
"health_protocol", "health_port", "http_method", "url_path", "host_name":
if n := d.Get("health_check_state"); n == "start" {
switch k {
case "http_method", "url_path", "host_name":
if d.Get("health_protocol") == "HTTP" {
return false
}
return true
}
return false
}
case "cookie_name":
Expand All @@ -205,6 +215,7 @@ func AlbRuleGroupSyncOffDiffSuppressFunc(k, old, new string, d *schema.ResourceD

case "session_state", "health_check_state":
return false

}

return true
Expand Down
3 changes: 3 additions & 0 deletions website/docs/d/alb_rule_groups.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ In addition to all arguments above, the following attributes are exported:
* `cookie_name` - The name of cookie.
* `cookie_type` - The type of cookie.
* `health_check_state` - Status maintained by health examination.
* `health_port` - The port of connecting for health check.
* `health_protocol` - The protocol of connecting for health check.
* `healthy_threshold` - Health threshold.
* `host_name` - The service host name of the health check.
* `http_method` - The http requests' method.
* `id` - ID of the ALB Rule Group.
* `interval` - Interval of health examination.
* `listener_sync` - Whether to synchronize the health check, session persistence, and load balancing algorithm of the listener.
Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/alb_rule_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ The following arguments are supported:
* `cookie_type` - (Optional) The type of cookie, valid values: 'ImplantCookie','RewriteCookie'.
* `fixed_response_config` - (Optional) The config of fixed response. Conflict with 'backend_server_group_id' and 'fixed_response_config'.
* `health_check_state` - (Optional) Status maintained by health examination.Valid Values:'start', 'stop'. Should set it value, when `listener_sync` is off.
* `health_port` - (Optional) The port of connecting for health check. It works, when `listener_sync` is off.
* `health_protocol` - (Optional) The protocol of connecting for health check. It works, when `listener_sync` is off.
* `healthy_threshold` - (Optional) Health threshold.Valid Values:1-10. Should set it value, when `listener_sync` is off.
* `host_name` - (Optional) The service host name of the health check, which is available only for the HTTP or HTTPS health check. Should set it value, when `listener_sync` is off.
* `http_method` - (Optional) The http requests' method. Valid Value: GET|HEAD.
* `http_method` - (Optional) The http requests' method. Valid Value: GET|HEAD. It works, when `health_protocol` is HTTP.
* `interval` - (Optional) Interval of health examination.Valid Values:1-3600. Should set it value, when `listener_sync` is off.
* `method` - (Optional) Forwarding mode of listener. Valid Values:'RoundRobin', 'LeastConnections'.
* `redirect_alb_listener_id` - (Optional) The id of redirect alb listener. Conflict with 'backend_server_group_id' and 'fixed_response_config'.
Expand Down

0 comments on commit 24cd1c0

Please sign in to comment.