Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added support for getting container ids from ECS metadata API #2292

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

jsumners-nr
Copy link
Contributor

This PR resolves #2276.

@jsumners-nr jsumners-nr marked this pull request as ready for review June 25, 2024 14:30
Copy link
Member

@bizob2828 bizob2828 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny little suggestion on the checking for the ECS env vars but up to you if you want to address it

Comment on lines +106 to +109
if (process.env.ECS_CONTAINER_METADATA_URI_V4 != null) {
return true
}
return process.env.ECS_CONTAINER_METADATA_URI != null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (process.env.ECS_CONTAINER_METADATA_URI_V4 != null) {
return true
}
return process.env.ECS_CONTAINER_METADATA_URI != null
return process.env.ECS_CONTAINER_METADATA_URI_V4 != null || process.env.ECS_CONTAINER_METADATA_URI != null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, it's clearer as it is written that we are preferring the V4 version and then falling back to the other.


module.exports.getVendorInfo = fetchDockerVendorInfo
module.exports.clearVendorCache = function clearDockerVendorCache() {
vendorInfo = null
}

module.exports.getBootId = function getBootId(agent, callback) {
module.exports.getBootId = function getBootId(agent, callback, logger = log) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's fine but seems like a lot of signature updates to inject a logger. if you look through our unit tests we use proxyquire to inject mock loggers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think being able to inject the parameter is a lot cleaner than using proxyquire. We don't need to couple the implementation of the whole module to the tests (the tests needing to know how the logger is imported and used in the code).

fs_access: fs.access,
os_platform: os.platform
}
fs.access = (file, mode, cb) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is purely informational but a lot of our tests use sinon for mocking.

sinon.stub(fs, 'access').yields(Error('no proc file'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add support for fetching container identifier in ECS Fargate
3 participants