Skip to content

Commit

Permalink
filter: aws drop unused 'new_keys' from ctx
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Warzyński <mateusz@warzynski.pro>
  • Loading branch information
mwarzynski authored and PettitWesley committed May 3, 2024
1 parent be44ed2 commit ece3450
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
17 changes: 0 additions & 17 deletions plugins/filter_aws/aws.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,6 @@ static int get_ec2_metadata_base(struct flb_filter_aws *ctx)

ctx->metadata_groups[FLB_FILTER_AWS_METADATA_GROUP_BASE].last_execution = time(NULL);

/* TODO: check this during review, I added this line -- I think it makes it more correct. */
/* it also might be fine to just delete new_keys as it's not really used anywhere */
ctx->new_keys = 0;
if (ctx->instance_id_include && !ctx->instance_id) {
ret = flb_aws_imds_request(ctx->client_imds, FLB_AWS_IMDS_INSTANCE_ID_PATH,
&ctx->instance_id,
Expand All @@ -631,7 +628,6 @@ static int get_ec2_metadata_base(struct flb_filter_aws *ctx)
flb_plg_error(ctx->ins, "Failed to get instance ID");
return -1;
}
ctx->new_keys++;
}

if (ctx->availability_zone_include && !ctx->availability_zone) {
Expand All @@ -643,7 +639,6 @@ static int get_ec2_metadata_base(struct flb_filter_aws *ctx)
flb_plg_error(ctx->ins, "Failed to get instance AZ");
return -1;
}
ctx->new_keys++;
}

if (ctx->instance_type_include && !ctx->instance_type) {
Expand All @@ -654,7 +649,6 @@ static int get_ec2_metadata_base(struct flb_filter_aws *ctx)
flb_plg_error(ctx->ins, "Failed to get instance type");
return -1;
}
ctx->new_keys++;
}

if (ctx->private_ip_include && !ctx->private_ip) {
Expand All @@ -665,7 +659,6 @@ static int get_ec2_metadata_base(struct flb_filter_aws *ctx)
flb_plg_error(ctx->ins, "Failed to get instance private IP");
return -1;
}
ctx->new_keys++;
}

if (ctx->vpc_id_include && !ctx->vpc_id) {
Expand All @@ -675,7 +668,6 @@ static int get_ec2_metadata_base(struct flb_filter_aws *ctx)
flb_plg_error(ctx->ins, "Failed to get instance VPC ID");
return -1;
}
ctx->new_keys++;
}

if (ctx->ami_id_include && !ctx->ami_id) {
Expand All @@ -686,7 +678,6 @@ static int get_ec2_metadata_base(struct flb_filter_aws *ctx)
flb_plg_error(ctx->ins, "Failed to get AMI ID");
return -1;
}
ctx->new_keys++;
}

if (ctx->account_id_include && !ctx->account_id) {
Expand All @@ -698,7 +689,6 @@ static int get_ec2_metadata_base(struct flb_filter_aws *ctx)
flb_plg_error(ctx->ins, "Failed to get Account ID");
return -1;
}
ctx->new_keys++;
}

if (ctx->hostname_include && !ctx->hostname) {
Expand All @@ -709,7 +699,6 @@ static int get_ec2_metadata_base(struct flb_filter_aws *ctx)
flb_plg_error(ctx->ins, "Failed to get Hostname");
return -1;
}
ctx->new_keys++;
}

return 0;
Expand All @@ -718,7 +707,6 @@ static int get_ec2_metadata_base(struct flb_filter_aws *ctx)
static int get_ec2_metadata_tags(struct flb_filter_aws *ctx)
{
int ret;
int i;

ctx->metadata_groups[FLB_FILTER_AWS_METADATA_GROUP_TAGS].last_execution = time(NULL);

Expand All @@ -728,11 +716,6 @@ static int get_ec2_metadata_tags(struct flb_filter_aws *ctx)
flb_plg_error(ctx->ins, "Failed to get instance EC2 Tags");
return ret;
}
for (i = 0; i < ctx->tags_count; i++) {
if (ctx->tag_is_enabled[i] == FLB_TRUE) {
ctx->new_keys++;
}
}
}

return 0;
Expand Down
3 changes: 0 additions & 3 deletions plugins/filter_aws/aws.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ struct flb_filter_aws {
/* e.g.: if tag_is_enabled[0] = FALSE, then filter aws should not inject first tag */
int *tag_is_enabled;

/* number of new keys added by this plugin */
int new_keys;

/* metadata groups contains information for potential retries and
* if group was already fetched successfully */
struct flb_filter_aws_metadata_group metadata_groups[FLB_FILTER_AWS_METADATA_GROUP_NUM];
Expand Down

0 comments on commit ece3450

Please sign in to comment.