Skip to content

Conversation

@Myztiq
Copy link
Contributor

@Myztiq Myztiq commented Mar 2, 2017

We now stream logs to the frontend from s3 buckets. Decision for the architecture can be documented here: https://runnable.atlassian.net/browse/SAN-5848

@runnabot
Copy link

runnabot commented Mar 7, 2017

Deployed api/SAN-5848-log-streaming. View on Runnable.
From Runnable

log.trace('called')

const s3Object = s3.getObject({
Bucket: `${process.env.NODE_ENV}.container-logs`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make this whole thing an env. It will help during on-prem installation so we know this is a bucket.
process.env.CONTAINER_LOGS_S3_BUCKET

log.trace({error}, 'Error while fetching logs from s3')
cb(error)
})
.on('end', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need to close createReadStream here? it might be automatic but just making sure no call is needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, the stream is closed when end is called on it already.

}
rabbitMQ.publishLogStreamConnected(eventData)
return commonStream.pipeLogsToClient(destLogStream, baseDataName, tags, data.containerId, { tailLimit })
let streamPromise
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: seems like isolated logic, mind moving it to helper function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Specifically the check if the container is running? Or the method to pipe logs to a client? I'm unsure if its needed to be separated.

},
container: {
dockerContainer: ctx.data.containerId
dockerContainer: ctx.data.containerId,
Copy link
Contributor

Choose a reason for hiding this comment

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

does unit test cover both cases? where Running is true and false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, just when running is true

Copy link
Contributor

Choose a reason for hiding this comment

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

can you make test for both cases. and the fallback case? we dont know it works unless its tested :)

})
}

module.exports = {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we have ES6 now, you can make this a class if you want 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ehh, a little late to the party for streaming.

log.trace('called')

const s3Object = s3.getObject({
Bucket: `${process.env.NODE_ENV}.container-logs`,
Copy link
Member

Choose a reason for hiding this comment

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

Can we change this into a variable? The bucket name should really live in devops-scripts through an ENV so that devop-scripts knows about all S3 buckets created.

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 put it in the .env's


const pipeLogsToClient = (targetStream, containerId) => {
const log = logger.child({
container: containerId,
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Maybe container: containerId, to containerId,

}

module.exports = {
pipeLogsToClient: pipeLogsToClient
Copy link
Member

Choose a reason for hiding this comment

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

Nit: pipeLogsToClient: pipeLogsToClient -> pipeLogsToClient

# Conflicts:
#	configs/.env.test
@Myztiq
Copy link
Contributor Author

Myztiq commented Mar 11, 2017

screen shot 2017-03-10 at 5 48 27 pm

@Myztiq Myztiq merged commit 5d4104a into master Mar 11, 2017
@Myztiq Myztiq deleted the SAN-5848-log-streaming branch March 11, 2017 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants