From 66d208bfc3966bad022c2a895c3c6ea65e162475 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Wed, 25 Apr 2018 15:05:42 +0200 Subject: [PATCH] add buildid logging to help with debugging Signed-off-by: Tobias Ulmer --- local/chroot.lua | 2 ++ local/cscache.lua | 10 ++++++++++ local/e2tool.lua | 6 ++++-- local/environment.lua | 11 ++++++++++- local/licence.lua | 2 ++ local/policy.lua | 2 ++ local/project.lua | 1 + local/result.lua | 2 ++ plugins/collect_project.lua | 2 ++ plugins/cvs.lua | 3 +++ plugins/files.lua | 2 ++ plugins/git.lua | 3 +++ plugins/gitrepo.lua | 4 ++++ plugins/licencesrc.lua | 2 ++ plugins/svn.lua | 3 +++ 15 files changed, 52 insertions(+), 3 deletions(-) diff --git a/local/chroot.lua b/local/chroot.lua index d1ae964..1084374 100644 --- a/local/chroot.lua +++ b/local/chroot.lua @@ -135,6 +135,8 @@ function chroot.chroot:chrootgroupid() end self._chrootgroupid = hash.hash_finish(hc) + e2lib.logf(4, "BUILDID: name=%q chrootgroupid=%s", + self._name, self._chrootgroupid) return self._chrootgroupid end --- @section end diff --git a/local/cscache.lua b/local/cscache.lua index 95e3407..301ed05 100644 --- a/local/cscache.lua +++ b/local/cscache.lua @@ -96,6 +96,12 @@ function cs_cache_class:lookup(filename, digest_type) hce.use = os.time() + if not hce.logged then + e2lib.logf(4, "BUILDID: file %q cached SHA1=%s SHA256=%s", filename, + tostring(hce.sha1), tostring(hce.sha256)) + hce.logged = true + end + return cs end @@ -131,6 +137,9 @@ function cs_cache_class:insert(filename, checksum, digest_type) sha256 = checksum end + e2lib.logf(4, "BUILDID: file %q SHA1=%s SHA256=%s", filename, + tostring(sha1), tostring(sha256)) + if not e2lib.exists(filename, false) then return end @@ -153,6 +162,7 @@ function cs_cache_class:insert(filename, checksum, digest_type) dev = sb.dev, ino = sb.ino, use = 0, + logged = true, -- limit buildid logging to once per file } end diff --git a/local/e2tool.lua b/local/e2tool.lua index 9cd587c..fda1dcb 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -333,7 +333,7 @@ end -- @return FileID string: hash value, or false on error. -- @return an error object on failure function e2tool.file_class:fileid() - local rc, re, e, hc, cs + local rc, re, e, hc, cs, fid local cs_done = false e = err.new("error calculating file id for file: %s", self:servloc()) @@ -397,7 +397,9 @@ function e2tool.file_class:fileid() hash.hash_append(hc, self._copy) end - return hash.hash_finish(hc) + fid = hash.hash_finish(hc) + e2lib.logf(4, "BUILDID: %s fileid=%s", self:servloc(), fid) + return fid end --- Verify file addressed by server name and location matches configured diff --git a/local/environment.lua b/local/environment.lua index f23b634..f321f7d 100644 --- a/local/environment.lua +++ b/local/environment.lua @@ -25,12 +25,18 @@ local err = require("err") local hash = require("hash") local strict = require("strict") +-- Sequential ID for debugging. +-- Keeps track of various env tables between runs. +local environment_seqid = 1 + --- create new environment -- @return environment function environment.new() local env = {} local meta = { __index = environment } setmetatable(env, meta) + env.seqid = environment_seqid + environment_seqid = environment_seqid + 1 env.dict = {} env.sorted = {} return env @@ -57,11 +63,14 @@ end function environment.envid(env) assertIsTable(env) assertIsTable(env.sorted) + local eid local hc = hash.hash_start() for var, val in env:iter() do hash.hash_append(hc, var..val) end - return hash.hash_finish(hc) + eid = hash.hash_finish(hc) + e2lib.logf(4, "BUILDID: seqid=%d envid=%s", env.seqid, eid) + return eid end --- merge environment from merge into env. diff --git a/local/licence.lua b/local/licence.lua index 53fc01b..8c3224f 100644 --- a/local/licence.lua +++ b/local/licence.lua @@ -110,6 +110,8 @@ function licence.licence:licenceid() return false, e:cat(re) end + e2lib.logf(4, "BUILDID: name=%s licenceid=%s", self._name, self._licenceid) + return self._licenceid end --- @section end diff --git a/local/policy.lua b/local/policy.lua index e61a6a6..6ff17be 100644 --- a/local/policy.lua +++ b/local/policy.lua @@ -138,6 +138,8 @@ local function buildid_scratch(buildid) newbuildid = "scratch-" .. newbuildid buildid_scratch_cache[buildid] = newbuildid + e2lib.logf(4, "BUILDID: buildid=%s buildid_scratch=%s", buildid, newbuildid) + return buildid_scratch_cache[buildid] end diff --git a/local/project.lua b/local/project.lua index 4dfb1af..bb13438 100644 --- a/local/project.lua +++ b/local/project.lua @@ -355,6 +355,7 @@ function project.projid() end _projid_cache = hash.hash_finish(hc) + e2lib.logf(4, "BUILDID: projid=%s", _projid_cache) return _projid_cache end diff --git a/local/result.lua b/local/result.lua index d0ee445..d082211 100644 --- a/local/result.lua +++ b/local/result.lua @@ -531,6 +531,8 @@ function result.result_class:buildid() self._buildid = hash.hash_finish(hc) + e2lib.logf(4, "BUILDID: result=%s buildid=%s", self._name, self._buildid) + return build_mode.buildid(self._buildid) end diff --git a/plugins/collect_project.lua b/plugins/collect_project.lua index 74cfe93..aa51e77 100644 --- a/plugins/collect_project.lua +++ b/plugins/collect_project.lua @@ -488,6 +488,8 @@ function collect_project_class:buildid() assertIsStringN(bid) + e2lib.logf(4, "BUILDID: cp result=%s buildid=%s", self._name, bid) + return bid end diff --git a/plugins/cvs.lua b/plugins/cvs.lua index 0157ce1..91b3ea7 100644 --- a/plugins/cvs.lua +++ b/plugins/cvs.lua @@ -260,6 +260,9 @@ function cvs.cvs_source:sourceid(sourceset) self._sourceids[sourceset] = hash.hash_finish(hc) + e2lib.logf(4, "BUILDID: source=%s sourceset=%s sourceid=%s", + self._name, sourceset, self._sourceids[sourceset]) + return self._sourceids[sourceset] end diff --git a/plugins/files.lua b/plugins/files.lua index e30c488..19e419d 100644 --- a/plugins/files.lua +++ b/plugins/files.lua @@ -381,6 +381,8 @@ function files.files_source:sourceid(sourceset) self._sourceid = hash.hash_finish(hc) + e2lib.logf(4, "BUILDID: source=%s sourceid=%s", self._name, self._sourceid) + return self._sourceid end diff --git a/plugins/git.lua b/plugins/git.lua index 6cba144..b13f684 100644 --- a/plugins/git.lua +++ b/plugins/git.lua @@ -245,6 +245,9 @@ function git.git_source:sourceid(sourceset) self._commitids[sourceset] = id self._sourceids[sourceset] = hash.hash_finish(hc) + e2lib.logf(4, "BUILDID: source=%s sourceset=%s sourceid=%s", + self._name, sourceset, self._sourceids[sourceset]) + return self._sourceids[sourceset] end diff --git a/plugins/gitrepo.lua b/plugins/gitrepo.lua index bc3eb0d..2e17755 100644 --- a/plugins/gitrepo.lua +++ b/plugins/gitrepo.lua @@ -193,6 +193,10 @@ function gitrepo_source:sourceid(sourceset) hash.hash_append(hc, out) self._sourceids[sourceset] = hash.hash_finish(hc) + + e2lib.logf(4, "BUILDID: source=%s sourceset=%s sourceid=%s", + self._name, sourceset, self._sourceids[sourceset]) + return self._sourceids[sourceset] end diff --git a/plugins/licencesrc.lua b/plugins/licencesrc.lua index 30cd3d5..6734bdd 100644 --- a/plugins/licencesrc.lua +++ b/plugins/licencesrc.lua @@ -175,6 +175,8 @@ function licence_source:sourceid(sourceset) self._sourceid = hash.hash_finish(hc) + e2lib.logf(4, "BUILDID: source=%s sourceid=%s", self._name, self._sourceid) + return self._sourceid end diff --git a/plugins/svn.lua b/plugins/svn.lua index 92475ba..94c739c 100644 --- a/plugins/svn.lua +++ b/plugins/svn.lua @@ -306,6 +306,9 @@ function svn.svn_source:sourceid(sourceset) self._sourceids[sourceset] = hash.hash_finish(hc) + e2lib.logf(4, "BUILDID: source=%s sourceset=%s sourceid=%s", + self._name, sourceset, self._sourceids[sourceset]) + return self._sourceids[sourceset] end -- 2.39.5