diff --git a/config/helm/aws-node-termination-handler/README.md b/config/helm/aws-node-termination-handler/README.md index 406c73ee..e2e3f704 100644 --- a/config/helm/aws-node-termination-handler/README.md +++ b/config/helm/aws-node-termination-handler/README.md @@ -64,7 +64,7 @@ Parameter | Description | Default `webhookURLSecretName` | Pass Webhook URL as a secret. Secret Key: `webhookurl`, Value: `` | None `webhookProxy` | Uses the specified HTTP(S) proxy for sending webhooks | `` `webhookHeaders` | Replaces the default webhook headers. | `{"Content-type":"application/json"}` -`webhookTemplate` | Replaces the default webhook message template. | `{"text":"[NTH][Instance Interruption] EventID: {{ .EventID }} - Kind: {{ .Kind }} - Instance: {{ .InstanceID }} - Description: {{ .Description }} - Start Time: {{ .StartTime }}"}` +`webhookTemplate` | Replaces the default webhook message template. | `{"text":"[NTH][Instance Interruption] EventID: {{ .EventID }} - Kind: {{ .Kind }} - Instance: {{ .InstanceID }} - Node: {{ .NodeName }} - Description: {{ .Description }} - Start Time: {{ .StartTime }}"}` `webhookTemplateConfigMapName` | Pass Webhook template file as configmap | None `webhookTemplateConfigMapKey` | Name of the template file stored in the configmap| None `metadataTries` | The number of times to try requesting metadata. If you would like 2 retries, set metadata-tries to 3. | `3` diff --git a/pkg/config/config.go b/pkg/config/config.go index bd2d400f..8f9e7b79 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -47,7 +47,7 @@ const ( webhookHeadersDefault = `{"Content-type":"application/json"}` webhookTemplateConfigKey = "WEBHOOK_TEMPLATE" webhookTemplateFileConfigKey = "WEBHOOK_TEMPLATE_FILE" - webhookTemplateDefault = `{"text":"[NTH][Instance Interruption] EventID: {{ .EventID }} - Kind: {{ .Kind }} - Instance: {{ .InstanceID }} - Description: {{ .Description }} - Start Time: {{ .StartTime }}"}` + webhookTemplateDefault = `{"text":"[NTH][Instance Interruption] EventID: {{ .EventID }} - Kind: {{ .Kind }} - Instance: {{ .InstanceID }} - Node: {{ .NodeName }} - Description: {{ .Description }} - Start Time: {{ .StartTime }}"}` enableScheduledEventDrainingConfigKey = "ENABLE_SCHEDULED_EVENT_DRAINING" enableScheduledEventDrainingDefault = false enableSpotInterruptionDrainingConfigKey = "ENABLE_SPOT_INTERRUPTION_DRAINING" diff --git a/pkg/webhook/webhook_test.go b/pkg/webhook/webhook_test.go index 03864c6e..5c5076f2 100644 --- a/pkg/webhook/webhook_test.go +++ b/pkg/webhook/webhook_test.go @@ -35,7 +35,7 @@ import ( const ( testDateFormat = "02 Jan 2006 15:04:05 GMT" testWebhookHeaders = `{"Content-type":"application/json"}` - testWebhookTemplate = `{"text":"[NTH][Instance Interruption] EventID: {{ .EventID }} - Kind: {{ .Kind }} - Description: {{ .Description }} - Start Time: {{ .StartTime }}"}` + testWebhookTemplate = `{"text":"[NTH][Instance Interruption] EventID: {{ .EventID }} - Kind: {{ .Kind }} - Node: {{ .NodeName }} - Description: {{ .Description }} - Start Time: {{ .StartTime }}"}` ) func parseScheduledEventTime(inputTime string) time.Time { @@ -71,6 +71,7 @@ func TestPostSuccess(t *testing.T) { State: "active", StartTime: parseScheduledEventTime("21 Jan 2019 09:00:43 GMT"), EndTime: parseScheduledEventTime("21 Jan 2019 09:17:23 GMT"), + NodeName: "e2e-test-abcd", } server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { diff --git a/test/e2e/webhook-http-proxy-test b/test/e2e/webhook-http-proxy-test index 86fc0ff9..951f9d94 100755 --- a/test/e2e/webhook-http-proxy-test +++ b/test/e2e/webhook-http-proxy-test @@ -129,7 +129,7 @@ anth_helm_args=( --set enableSpotInterruptionDraining="true" --set enableScheduledEventDraining="true" --set webhookURL="$WEBHOOK_URL" - --set webhookTemplate="\{\"Content\":\"[NTH][Instance Interruption] InstanceId: \{\{ \.InstanceID \}\} - InstanceType: \{\{ \.InstanceType \}\} - Kind: \{\{ \.Kind \}\} - Start Time: \{\{ \.StartTime \}\}\"\}" + --set webhookTemplate="\{\"Content\":\"[NTH][Instance Interruption] InstanceId: \{\{ \.InstanceID \}\} - Node: \{\{ \.NodeName \}\} - InstanceType: \{\{ \.InstanceType \}\} - Kind: \{\{ \.Kind \}\} - Start Time: \{\{ \.StartTime \}\}\"\}" --set webhookProxy="$SQUID_URL" ) [[ -n "${NODE_TERMINATION_HANDLER_DOCKER_PULL_POLICY-}" ]] && diff --git a/test/e2e/webhook-secret-test b/test/e2e/webhook-secret-test index afda095f..9c62df5c 100755 --- a/test/e2e/webhook-secret-test +++ b/test/e2e/webhook-secret-test @@ -78,7 +78,7 @@ anth_helm_args=( --set enableSpotInterruptionDraining="true" --set enableScheduledEventDraining="true" --set webhookURLSecretName=webhooksecret \ - --set webhookTemplate="\{\"Content\":\"[NTH][Instance Interruption] InstanceId: \{\{ \.InstanceID \}\} - InstanceType: \{\{ \.InstanceType \}\} - Kind: \{\{ \.Kind \}\} - Start Time: \{\{ \.StartTime \}\}\"\}" + --set webhookTemplate="\{\"Content\":\"[NTH][Instance Interruption] InstanceId: \{\{ \.InstanceID \}\} - Node: \{\{ \.NodeName \}\} - InstanceType: \{\{ \.InstanceType \}\} - Kind: \{\{ \.Kind \}\} - Start Time: \{\{ \.StartTime \}\}\"\}" ) [[ -n "${NODE_TERMINATION_HANDLER_DOCKER_PULL_POLICY-}" ]] && anth_helm_args+=(--set image.pullPolicy="$NODE_TERMINATION_HANDLER_DOCKER_PULL_POLICY") diff --git a/test/e2e/webhook-test b/test/e2e/webhook-test index 789f4c81..911d13bf 100755 --- a/test/e2e/webhook-test +++ b/test/e2e/webhook-test @@ -37,7 +37,7 @@ anth_helm_args=( --set image.repository="$NODE_TERMINATION_HANDLER_DOCKER_REPO" --set image.tag="$NODE_TERMINATION_HANDLER_DOCKER_TAG" --set webhookURL="${WEBHOOK_URL}" - --set webhookTemplate="\{\"Content\":\"[NTH][Instance Interruption] InstanceId: \{\{ \.InstanceID \}\} - InstanceType: \{\{ \.InstanceType \}\} - AvailabilityZone: \{\{ \.AvailabilityZone \}\} - Kind: \{\{ \.Kind \}\} - Start Time: \{\{ \.StartTime \}\}\"\}" + --set webhookTemplate="\{\"Content\":\"[NTH][Instance Interruption] InstanceId: \{\{ \.InstanceID \}\} - Node: \{\{ \.NodeName \}\} - InstanceType: \{\{ \.InstanceType \}\} - AvailabilityZone: \{\{ \.AvailabilityZone \}\} - Kind: \{\{ \.Kind \}\} - Start Time: \{\{ \.StartTime \}\}\"\}" --set enableSpotInterruptionDraining="true" --set enableScheduledEventDraining="true" --set tolerations=""