Report all logs from a container's runtime

We add a database table, which holds information about the last
timestamp of a log successfully reported to a backend (local or remote).
We then use this value to calculate from which point in time to start
reporting logs from the container. If this is the first time we've seen
a container, we get all logs, and for every log reported we save the
timestamp. If it is not the first time we've seen a container, we
request all logs since the last reported time, ensuring no interruption
of service.

Change-type: minor
Closes: #937
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver
2019-04-01 15:55:15 +01:00
parent 25fd11bed3
commit e148ce0529
6 changed files with 64 additions and 8 deletions

10
src/migrations/M00004.js Normal file
View File

@ -0,0 +1,10 @@
exports.up = function(knex) {
return knex.schema.createTable('containerLogs', table => {
table.string('containerId');
table.integer('lastSentTimestamp');
});
};
exports.down = function(knex, Promise) {
return Promise.reject(new Error('Not Implemented'));
};