client: Add AWS EC2 instance-life-cycle from metadata to client fingerprint (#12371)

This commit is contained in:
Hunter Morris 2022-03-25 15:50:52 +00:00 committed by GitHub
parent 848a3b271f
commit dcaf99dcc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 0 deletions

3
.changelog/12371.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
client: fingerprint AWS instance life cycle option
```

View File

@ -91,6 +91,7 @@ func (f *EnvAWSFingerprint) Fingerprint(request *FingerprintRequest, response *F
"ami-id": false, "ami-id": false,
"hostname": true, "hostname": true,
"instance-id": true, "instance-id": true,
"instance-life-cycle": false,
"instance-type": false, "instance-type": false,
"local-hostname": true, "local-hostname": true,
"local-ipv4": true, "local-ipv4": true,

View File

@ -52,6 +52,7 @@ func TestEnvAWSFingerprint_aws(t *testing.T) {
"platform.aws.ami-id", "platform.aws.ami-id",
"unique.platform.aws.hostname", "unique.platform.aws.hostname",
"unique.platform.aws.instance-id", "unique.platform.aws.instance-id",
"platform.aws.instance-life-cycle",
"platform.aws.instance-type", "platform.aws.instance-type",
"unique.platform.aws.local-hostname", "unique.platform.aws.local-hostname",
"unique.platform.aws.local-ipv4", "unique.platform.aws.local-ipv4",
@ -334,6 +335,11 @@ var awsStubs = []endpoint{
ContentType: "text/plain", ContentType: "text/plain",
Body: "i-b3ba3875", Body: "i-b3ba3875",
}, },
{
Uri: "/latest/meta-data/instance-life-cycle",
ContentType: "text/plain",
Body: "on-demand",
},
{ {
Uri: "/latest/meta-data/instance-type", Uri: "/latest/meta-data/instance-type",
ContentType: "text/plain", ContentType: "text/plain",
@ -387,6 +393,11 @@ var unknownInstanceType = []endpoint{
ContentType: "text/plain", ContentType: "text/plain",
Body: "i-b3ba3875", Body: "i-b3ba3875",
}, },
{
Uri: "/latest/meta-data/instance-life-cycle",
ContentType: "text/plain",
Body: "on-demand",
},
{ {
Uri: "/latest/meta-data/instance-type", Uri: "/latest/meta-data/instance-type",
ContentType: "text/plain", ContentType: "text/plain",
@ -417,6 +428,11 @@ var noNetworkAWSStubs = []endpoint{
ContentType: "text/plain", ContentType: "text/plain",
Body: "i-b3ba3875", Body: "i-b3ba3875",
}, },
{
Uri: "/latest/meta-data/instance-life-cycle",
ContentType: "text/plain",
Body: "on-demand",
},
{ {
Uri: "/latest/meta-data/instance-type", Uri: "/latest/meta-data/instance-type",
ContentType: "text/plain", ContentType: "text/plain",

View File

@ -235,6 +235,12 @@ Below is a table documenting common node properties:
</td> </td>
<td>AMI ID of the client (if on AWS EC2)</td> <td>AMI ID of the client (if on AWS EC2)</td>
</tr> </tr>
<tr>
<td>
<code>{'${attr.platform.aws.instance-life-cycle}'}</code>
</td>
<td>Instance lifecycle (e.g. spot, on-demand) of the client (if on AWS EC2)</td>
</tr>
<tr> <tr>
<td> <td>
<code>{'${attr.platform.aws.instance-type}'}</code> <code>{'${attr.platform.aws.instance-type}'}</code>