Skip to content

SAN-5848 - Stream logs from s3 to the frontend - #1906

Merged
Myztiq merged 22 commits into
masterfrom
SAN-5848-log-streaming
Mar 11, 2017
Merged

SAN-5848 - Stream logs from s3 to the frontend#1906
Myztiq merged 22 commits into
masterfrom
SAN-5848-log-streaming

Conversation

@Myztiq

@MyztiqMyztiq commented Mar 2, 2017

Copy link
Copy Markdown
Contributor

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

runnabot commented Mar 7, 2017

Copy link
Copy Markdown

Comment threadlib/socket/common-s3.js Outdated
log.trace('called')

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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.

Comment threadlib/socket/common-s3.js Outdated
log.trace('called')

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

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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

Comment threadlib/socket/common-s3.js Outdated

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

Copy link
Copy Markdown
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,

Comment threadlib/socket/common-s3.js Outdated
}

module.exports = {
pipeLogsToClient: pipeLogsToClient

Copy link
Copy Markdown
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

@Myztiq

Copy link
Copy Markdown
ContributorAuthor

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

@Myztiq
Myztiq merged commit 5d4104a into masterMar 11, 2017
@Myztiq
Myztiq deleted the SAN-5848-log-streaming branch March 11, 2017 01:52
Sign up for freeto 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.

5 participants

@Myztiq@runnabot@podviaznikov@thejsj@anandkumarpatel