diff options
| author | Per Larsson <[email protected]> | 2021-11-17 20:31:41 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-11-17 20:31:41 +0100 |
| commit | 1b9d83b3fa3a6cc6e2fa0f1af72050de2ccf4ea9 (patch) | |
| tree | 2245b9fb013a716d84f3aa37f4a216996dc7056a | |
| parent | Log upstream HTTP errors as errors. (diff) | |
| download | zen-1b9d83b3fa3a6cc6e2fa0f1af72050de2ccf4ea9.tar.xz zen-1b9d83b3fa3a6cc6e2fa0f1af72050de2ccf4ea9.zip | |
Added health check and return missing error message.
| -rw-r--r-- | zenserver/upstream/upstreamcache.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/zenserver/upstream/upstreamcache.cpp b/zenserver/upstream/upstreamcache.cpp index 726ef331d..065471c07 100644 --- a/zenserver/upstream/upstreamcache.cpp +++ b/zenserver/upstream/upstreamcache.cpp @@ -286,7 +286,12 @@ namespace detail { } } - return {.Bytes = Result.Bytes, .ElapsedSeconds = Result.ElapsedSeconds, .Success = Result.Success}; + m_HealthOk = Result.ErrorCode == 0; + + return {.Reason = std::move(Result.Reason), + .Bytes = Result.Bytes, + .ElapsedSeconds = Result.ElapsedSeconds, + .Success = Result.Success}; } else { @@ -312,6 +317,8 @@ namespace detail { BlobResult = Session.PutCompressedBlob(CacheRecord.PayloadIds[Idx], Payloads[Idx]); } + m_HealthOk = BlobResult.ErrorCode == 0; + if (!BlobResult.Success) { OutReason = "upload payload '{}' FAILED, reason '{}'"_format(PayloadId, BlobResult.Reason); @@ -332,6 +339,8 @@ namespace detail { Session.PutRef(CacheRecord.CacheKey.Bucket, CacheRecord.CacheKey.Hash, RecordValue, ZenContentType::kCbObject); } + m_HealthOk = RefResult.ErrorCode == 0; + if (!RefResult.Success) { return {.Reason = "upload cache record '{}/{}' FAILED, reason '{}'"_format(CacheRecord.CacheKey.Bucket, @@ -351,6 +360,7 @@ namespace detail { const IoHash RefHash = IoHash::HashBuffer(RecordValue); FinalizeRefResult FinalizeResult = Session.FinalizeRef(CacheRecord.CacheKey.Bucket, CacheRecord.CacheKey.Hash, RefHash); + m_HealthOk = FinalizeResult.ErrorCode == 0; if (!FinalizeResult.Success) { @@ -368,6 +378,7 @@ namespace detail { } FinalizeResult = Session.FinalizeRef(CacheRecord.CacheKey.Bucket, CacheRecord.CacheKey.Hash, RefHash); + m_HealthOk = FinalizeResult.ErrorCode == 0; if (!FinalizeResult.Success) { @@ -400,6 +411,7 @@ namespace detail { } catch (std::exception& Err) { + m_HealthOk = false; return {.Reason = std::string(Err.what()), .Success = false}; } } @@ -819,10 +831,10 @@ namespace detail { .ElapsedSeconds = TotalElapsedSeconds, .Success = Result.Success}; } - catch (std::exception& e) + catch (std::exception& Err) { m_HealthOk = false; - return {.Reason = std::string(e.what()), .Success = false}; + return {.Reason = std::string(Err.what()), .Success = false}; } } @@ -1276,12 +1288,12 @@ private: { ProcessCacheRecord(std::move(CacheRecord)); } - catch (std::exception& e) + catch (std::exception& Err) { ZEN_ERROR("upload cache record '{}/{}' FAILED, reason '{}'", CacheRecord.CacheKey.Bucket, CacheRecord.CacheKey.Hash, - e.what()); + Err.what()); } } @@ -1321,9 +1333,9 @@ private: } } } - catch (std::exception& e) + catch (std::exception& Err) { - ZEN_ERROR("check endpoint(s) health FAILED, reason '{}'", e.what()); + ZEN_ERROR("check endpoint(s) health FAILED, reason '{}'", Err.what()); } } } |