mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #6849 from overleaf/msm-git-bridge-log-level
[git-bridge] review logging levels GitOrigin-RevId: beb6ce89ccdee7c60c4439d7a5252d7858956a9a
This commit is contained in:
parent
9702346edc
commit
fe35372d27
29 changed files with 68 additions and 68 deletions
|
@ -270,7 +270,7 @@ public class Bridge {
|
||||||
if (!rootDirectory.exists()) {
|
if (!rootDirectory.exists()) {
|
||||||
throw new Exception("bad filesystem state, root directory does not exist");
|
throw new Exception("bad filesystem state, root directory does not exist");
|
||||||
}
|
}
|
||||||
Log.info("[HealthCheck] passed");
|
Log.debug("[HealthCheck] passed");
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.error("[HealthCheck] FAILED!", e);
|
Log.error("[HealthCheck] FAILED!", e);
|
||||||
|
@ -332,7 +332,7 @@ public class Bridge {
|
||||||
throw new RepositoryNotFoundException(projectName);
|
throw new RepositoryNotFoundException(projectName);
|
||||||
}
|
}
|
||||||
GetDocResult doc = maybeDoc.get();
|
GetDocResult doc = maybeDoc.get();
|
||||||
Log.info("[{}] Updating repository", projectName);
|
Log.debug("[{}] Updating repository", projectName);
|
||||||
return getUpdatedRepoCritical(oauth2, projectName, doc);
|
return getUpdatedRepoCritical(oauth2, projectName, doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -539,13 +539,13 @@ public class Bridge {
|
||||||
if (maxFileNum.isPresent()) {
|
if (maxFileNum.isPresent()) {
|
||||||
long maxFileNum_ = maxFileNum.get();
|
long maxFileNum_ = maxFileNum.get();
|
||||||
if (directoryContents.getFileTable().size() > maxFileNum_) {
|
if (directoryContents.getFileTable().size() > maxFileNum_) {
|
||||||
Log.debug("[{}] Too many files: {}/{}", projectName, directoryContents.getFileTable().size(), maxFileNum_);
|
Log.warn("[{}] Too many files: {}/{}", projectName, directoryContents.getFileTable().size(), maxFileNum_);
|
||||||
throw new FileLimitExceededException(directoryContents.getFileTable().size(), maxFileNum_);
|
throw new FileLimitExceededException(directoryContents.getFileTable().size(), maxFileNum_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.info("[{}] Pushing files ({} new, {} old)", projectName, directoryContents.getFileTable().size(), oldDirectoryContents.getFileTable().size());
|
Log.debug("[{}] Pushing files ({} new, {} old)", projectName, directoryContents.getFileTable().size(), oldDirectoryContents.getFileTable().size());
|
||||||
String postbackKey = postbackManager.makeKeyForProject(projectName);
|
String postbackKey = postbackManager.makeKeyForProject(projectName);
|
||||||
Log.info(
|
Log.debug(
|
||||||
"[{}] Created postback key: {}",
|
"[{}] Created postback key: {}",
|
||||||
projectName,
|
projectName,
|
||||||
postbackKey
|
postbackKey
|
||||||
|
@ -557,7 +557,7 @@ public class Bridge {
|
||||||
oldDirectoryContents
|
oldDirectoryContents
|
||||||
);
|
);
|
||||||
) {
|
) {
|
||||||
Log.info(
|
Log.debug(
|
||||||
"[{}] Candidate snapshot created: {}",
|
"[{}] Candidate snapshot created: {}",
|
||||||
projectName,
|
projectName,
|
||||||
candidate
|
candidate
|
||||||
|
@ -565,20 +565,20 @@ public class Bridge {
|
||||||
PushResult result
|
PushResult result
|
||||||
= snapshotAPI.push(oauth2, candidate, postbackKey);
|
= snapshotAPI.push(oauth2, candidate, postbackKey);
|
||||||
if (result.wasSuccessful()) {
|
if (result.wasSuccessful()) {
|
||||||
Log.info(
|
Log.debug(
|
||||||
"[{}] Push to Overleaf successful",
|
"[{}] Push to Overleaf successful",
|
||||||
projectName
|
projectName
|
||||||
);
|
);
|
||||||
Log.info("[{}] Waiting for postback...", projectName);
|
Log.debug("[{}] Waiting for postback...", projectName);
|
||||||
int versionID =
|
int versionID =
|
||||||
postbackManager.waitForVersionIdOrThrow(projectName);
|
postbackManager.waitForVersionIdOrThrow(projectName);
|
||||||
Log.info(
|
Log.debug(
|
||||||
"[{}] Got version ID for push: {}",
|
"[{}] Got version ID for push: {}",
|
||||||
projectName,
|
projectName,
|
||||||
versionID
|
versionID
|
||||||
);
|
);
|
||||||
approveSnapshot(versionID, candidate);
|
approveSnapshot(versionID, candidate);
|
||||||
Log.info(
|
Log.debug(
|
||||||
"[{}] Approved version ID: {}",
|
"[{}] Approved version ID: {}",
|
||||||
projectName,
|
projectName,
|
||||||
versionID
|
versionID
|
||||||
|
@ -636,7 +636,7 @@ public class Bridge {
|
||||||
String postbackKey,
|
String postbackKey,
|
||||||
int versionID
|
int versionID
|
||||||
) throws UnexpectedPostbackException {
|
) throws UnexpectedPostbackException {
|
||||||
Log.info(
|
Log.debug(
|
||||||
"[{}]" +
|
"[{}]" +
|
||||||
" Postback received by postback thread, version: {}",
|
" Postback received by postback thread, version: {}",
|
||||||
projectName,
|
projectName,
|
||||||
|
@ -762,7 +762,7 @@ public class Bridge {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Log.info(
|
Log.debug(
|
||||||
"[{}] Committing version ID: {}",
|
"[{}] Committing version ID: {}",
|
||||||
name,
|
name,
|
||||||
snapshot.getVersionID()
|
snapshot.getVersionID()
|
||||||
|
|
|
@ -117,14 +117,14 @@ public class GcJobImpl implements GcJob {
|
||||||
it.remove(), ++numGcs
|
it.remove(), ++numGcs
|
||||||
) {
|
) {
|
||||||
String proj = it.next();
|
String proj = it.next();
|
||||||
Log.info("[{}] Running GC job on project", proj);
|
Log.debug("[{}] Running GC job on project", proj);
|
||||||
try (LockGuard __ = locks.lockGuard(proj)) {
|
try (LockGuard __ = locks.lockGuard(proj)) {
|
||||||
try {
|
try {
|
||||||
ProjectRepo repo = repoStore.getExistingRepo(proj);
|
ProjectRepo repo = repoStore.getExistingRepo(proj);
|
||||||
repo.runGC();
|
repo.runGC();
|
||||||
repo.deleteIncomingPacks();
|
repo.deleteIncomingPacks();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.info("[{}] Failed to GC project", proj);
|
Log.warn("[{}] Failed to GC project", proj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class FSGitRepoStore implements RepoStore {
|
||||||
String repoRoot = getRepoStorePath();
|
String repoRoot = getRepoStorePath();
|
||||||
String sourcePath = repoRoot + "/" + fromProject;
|
String sourcePath = repoRoot + "/" + fromProject;
|
||||||
String destinationPath = repoRoot + "/" + project;
|
String destinationPath = repoRoot + "/" + project;
|
||||||
Log.info("[{}] Init repo by copying data from: {}, to: {}",
|
Log.debug("[{}] Init repo by copying data from: {}, to: {}",
|
||||||
project,
|
project,
|
||||||
sourcePath,
|
sourcePath,
|
||||||
destinationPath
|
destinationPath
|
||||||
|
@ -136,7 +136,7 @@ public class FSGitRepoStore implements RepoStore {
|
||||||
long[] sizePtr
|
long[] sizePtr
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
Project.checkValidProjectName(projectName);
|
Project.checkValidProjectName(projectName);
|
||||||
Log.info("[{}] bzip2 project", projectName);
|
Log.debug("[{}] bzip2 project", projectName);
|
||||||
return Tar.bz2.zip(getDotGitForProject(projectName), sizePtr);
|
return Tar.bz2.zip(getDotGitForProject(projectName), sizePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ public class FSGitRepoStore implements RepoStore {
|
||||||
long[] sizePtr
|
long[] sizePtr
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
Project.checkValidProjectName(projectName);
|
Project.checkValidProjectName(projectName);
|
||||||
Log.info("[{}] gzip project", projectName);
|
Log.debug("[{}] gzip project", projectName);
|
||||||
return Tar.gzip.zip(getDotGitForProject(projectName), sizePtr);
|
return Tar.gzip.zip(getDotGitForProject(projectName), sizePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ public class FSGitRepoStore implements RepoStore {
|
||||||
"evicted project already exist",
|
"evicted project already exist",
|
||||||
projectName
|
projectName
|
||||||
);
|
);
|
||||||
Log.info("[{}] un-bzip2 project", projectName);
|
Log.debug("[{}] un-bzip2 project", projectName);
|
||||||
Tar.bz2.unzip(dataStream, getDirForProject(projectName));
|
Tar.bz2.unzip(dataStream, getDirForProject(projectName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ public class FSGitRepoStore implements RepoStore {
|
||||||
"evicted project already exist",
|
"evicted project already exist",
|
||||||
projectName
|
projectName
|
||||||
);
|
);
|
||||||
Log.info("[{}] un-gzip project", projectName);
|
Log.debug("[{}] un-gzip project", projectName);
|
||||||
Tar.gzip.unzip(dataStream, getDirForProject(projectName));
|
Tar.gzip.unzip(dataStream, getDirForProject(projectName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,14 +116,14 @@ public class GitProjectRepo implements ProjectRepo {
|
||||||
);
|
);
|
||||||
File dir = getProjectDir();
|
File dir = getProjectDir();
|
||||||
Preconditions.checkState(dir.isDirectory());
|
Preconditions.checkState(dir.isDirectory());
|
||||||
Log.info("[{}] Running git gc", projectName);
|
Log.debug("[{}] Running git gc", projectName);
|
||||||
Process proc = new ProcessBuilder(
|
Process proc = new ProcessBuilder(
|
||||||
"git", "gc"
|
"git", "gc"
|
||||||
).directory(dir).start();
|
).directory(dir).start();
|
||||||
int exitCode;
|
int exitCode;
|
||||||
try {
|
try {
|
||||||
exitCode = proc.waitFor();
|
exitCode = proc.waitFor();
|
||||||
Log.info("Exit: {}", exitCode);
|
Log.debug("Exit: {}", exitCode);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -139,12 +139,12 @@ public class GitProjectRepo implements ProjectRepo {
|
||||||
));
|
));
|
||||||
throw new IOException("git gc error");
|
throw new IOException("git gc error");
|
||||||
}
|
}
|
||||||
Log.info("[{}] git gc successful", projectName);
|
Log.debug("[{}] git gc successful", projectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteIncomingPacks() throws IOException {
|
public void deleteIncomingPacks() throws IOException {
|
||||||
Log.info(
|
Log.debug(
|
||||||
"[{}] Checking for garbage `incoming` files",
|
"[{}] Checking for garbage `incoming` files",
|
||||||
projectName
|
projectName
|
||||||
);
|
);
|
||||||
|
@ -165,7 +165,7 @@ public class GitProjectRepo implements ProjectRepo {
|
||||||
File file_ = file.toFile();
|
File file_ = file.toFile();
|
||||||
String name = file_.getName();
|
String name = file_.getName();
|
||||||
if (name.startsWith("incoming_") && name.endsWith(".pack")) {
|
if (name.startsWith("incoming_") && name.endsWith(".pack")) {
|
||||||
Log.info("Deleting garbage `incoming` file: {}", file_);
|
Log.debug("Deleting garbage `incoming` file: {}", file_);
|
||||||
Preconditions.checkState(file_.delete());
|
Preconditions.checkState(file_.delete());
|
||||||
}
|
}
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
|
@ -242,21 +242,21 @@ public class GitProjectRepo implements ProjectRepo {
|
||||||
Repository repo = getJGitRepository();
|
Repository repo = getJGitRepository();
|
||||||
resetHard();
|
resetHard();
|
||||||
String name = getProjectName();
|
String name = getProjectName();
|
||||||
Log.info("[{}] Writing commit", name);
|
Log.debug("[{}] Writing commit", name);
|
||||||
contents.write();
|
contents.write();
|
||||||
Git git = new Git(getJGitRepository());
|
Git git = new Git(getJGitRepository());
|
||||||
Log.info("[{}] Getting missing files", name);
|
Log.debug("[{}] Getting missing files", name);
|
||||||
Set<String> missingFiles = git.status().call().getMissing();
|
Set<String> missingFiles = git.status().call().getMissing();
|
||||||
for (String missing : missingFiles) {
|
for (String missing : missingFiles) {
|
||||||
Log.info("[{}] Git rm {}", name, missing);
|
Log.debug("[{}] Git rm {}", name, missing);
|
||||||
git.rm().setCached(true).addFilepattern(missing).call();
|
git.rm().setCached(true).addFilepattern(missing).call();
|
||||||
}
|
}
|
||||||
Log.info("[{}] Calling Git add", name);
|
Log.debug("[{}] Calling Git add", name);
|
||||||
git.add(
|
git.add(
|
||||||
).setWorkingTreeIterator(
|
).setWorkingTreeIterator(
|
||||||
new NoGitignoreIterator(repo)
|
new NoGitignoreIterator(repo)
|
||||||
).addFilepattern(".").call();
|
).addFilepattern(".").call();
|
||||||
Log.info("[{}] Calling Git commit", name);
|
Log.debug("[{}] Calling Git commit", name);
|
||||||
git.commit(
|
git.commit(
|
||||||
).setAuthor(
|
).setAuthor(
|
||||||
new PersonIdent(
|
new PersonIdent(
|
||||||
|
@ -268,7 +268,7 @@ public class GitProjectRepo implements ProjectRepo {
|
||||||
).setMessage(
|
).setMessage(
|
||||||
contents.getCommitMessage()
|
contents.getCommitMessage()
|
||||||
).call();
|
).call();
|
||||||
Log.info(
|
Log.debug(
|
||||||
"[{}] Deleting files in directory: {}",
|
"[{}] Deleting files in directory: {}",
|
||||||
name,
|
name,
|
||||||
contents.getDirectory().getAbsolutePath()
|
contents.getDirectory().getAbsolutePath()
|
||||||
|
|
|
@ -50,8 +50,8 @@ public class UrlResourceCache implements ResourceCache {
|
||||||
contents = fetch(projectName, url, path, maxFileSize);
|
contents = fetch(projectName, url, path, maxFileSize);
|
||||||
fetchedUrls.put(url, contents);
|
fetchedUrls.put(url, contents);
|
||||||
} else {
|
} else {
|
||||||
Log.info("Found (" + projectName + "): " + url);
|
Log.debug("Found (" + projectName + "): " + url);
|
||||||
Log.info("At (" + projectName + "): " + path);
|
Log.debug("At (" + projectName + "): " + path);
|
||||||
contents = fetchedUrls.get(url);
|
contents = fetchedUrls.get(url);
|
||||||
if (contents == null) {
|
if (contents == null) {
|
||||||
RawFile rawFile = fileTable.get(path);
|
RawFile rawFile = fileTable.get(path);
|
||||||
|
@ -79,7 +79,7 @@ public class UrlResourceCache implements ResourceCache {
|
||||||
Optional<Long> maxFileSize
|
Optional<Long> maxFileSize
|
||||||
) throws FailedConnectionException, SizeLimitExceededException {
|
) throws FailedConnectionException, SizeLimitExceededException {
|
||||||
byte[] contents;
|
byte[] contents;
|
||||||
Log.info("GET -> " + url);
|
Log.debug("GET -> " + url);
|
||||||
try {
|
try {
|
||||||
contents = http.get(url, hs -> {
|
contents = http.get(url, hs -> {
|
||||||
List<String> contentLengths = hs.getAll("Content-Length");
|
List<String> contentLengths = hs.getAll("Content-Length");
|
||||||
|
|
|
@ -112,11 +112,11 @@ public class SwapJobImpl implements SwapJob {
|
||||||
private void doSwap_() {
|
private void doSwap_() {
|
||||||
ArrayList<String> exceptionProjectNames = new ArrayList<String>();
|
ArrayList<String> exceptionProjectNames = new ArrayList<String>();
|
||||||
|
|
||||||
Log.info("Running swap number {}", swaps.get() + 1);
|
Log.debug("Running swap number {}", swaps.get() + 1);
|
||||||
long totalSize = repoStore.totalSize();
|
long totalSize = repoStore.totalSize();
|
||||||
Log.info("Size is {}/{} (high)", totalSize, highWatermarkBytes);
|
Log.debug("Size is {}/{} (high)", totalSize, highWatermarkBytes);
|
||||||
if (totalSize < highWatermarkBytes) {
|
if (totalSize < highWatermarkBytes) {
|
||||||
Log.info("No need to swap.");
|
Log.debug("No need to swap.");
|
||||||
swaps.incrementAndGet();
|
swaps.incrementAndGet();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ public class SwapJobImpl implements SwapJob {
|
||||||
"Finished swapping, but total size is still too high."
|
"Finished swapping, but total size is still too high."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Log.info(
|
Log.debug(
|
||||||
"Size: {}/{} (low), " +
|
"Size: {}/{} (low), " +
|
||||||
"{} (high), " +
|
"{} (high), " +
|
||||||
"projects on disk: {}/{}, " +
|
"projects on disk: {}/{}, " +
|
||||||
|
|
|
@ -30,7 +30,7 @@ public abstract class RawFile {
|
||||||
OutputStream out = new FileOutputStream(file);
|
OutputStream out = new FileOutputStream(file);
|
||||||
out.write(getContents());
|
out.write(getContents());
|
||||||
out.close();
|
out.close();
|
||||||
Log.info("Wrote file: {}", file.getAbsolutePath());
|
Log.debug("Wrote file: {}", file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class WLReceivePackFactory
|
||||||
HttpServletRequest httpServletRequest,
|
HttpServletRequest httpServletRequest,
|
||||||
Repository repository
|
Repository repository
|
||||||
) {
|
) {
|
||||||
Log.info(
|
Log.debug(
|
||||||
"[{}] Creating receive-pack",
|
"[{}] Creating receive-pack",
|
||||||
repository.getWorkTree().getName()
|
repository.getWorkTree().getName()
|
||||||
);
|
);
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class WLRepositoryResolver
|
||||||
) throws RepositoryNotFoundException,
|
) throws RepositoryNotFoundException,
|
||||||
ServiceNotAuthorizedException,
|
ServiceNotAuthorizedException,
|
||||||
ServiceMayNotContinueException {
|
ServiceMayNotContinueException {
|
||||||
Log.info("[{}] Request to open git repo", name);
|
Log.debug("[{}] Request to open git repo", name);
|
||||||
Optional<Credential> oauth2 = Optional.ofNullable(
|
Optional<Credential> oauth2 = Optional.ofNullable(
|
||||||
(Credential) httpServletRequest.getAttribute(
|
(Credential) httpServletRequest.getAttribute(
|
||||||
Oauth2Filter.ATTRIBUTE_KEY));
|
Oauth2Filter.ATTRIBUTE_KEY));
|
||||||
|
@ -90,7 +90,7 @@ public class WLRepositoryResolver
|
||||||
try {
|
try {
|
||||||
return bridge.getUpdatedRepo(oauth2, projName).getJGitRepository();
|
return bridge.getUpdatedRepo(oauth2, projName).getJGitRepository();
|
||||||
} catch (RepositoryNotFoundException e) {
|
} catch (RepositoryNotFoundException e) {
|
||||||
Log.info("Repository not found: " + name);
|
Log.warn("Repository not found: " + name);
|
||||||
throw e;
|
throw e;
|
||||||
/*
|
/*
|
||||||
} catch (ServiceNotAuthorizedException e) {
|
} catch (ServiceNotAuthorizedException e) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class WLUploadPackFactory
|
||||||
HttpServletRequest __,
|
HttpServletRequest __,
|
||||||
Repository repository
|
Repository repository
|
||||||
) {
|
) {
|
||||||
Log.info(
|
Log.debug(
|
||||||
"[{}] Creating upload-pack",
|
"[{}] Creating upload-pack",
|
||||||
repository.getWorkTree().getName()
|
repository.getWorkTree().getName()
|
||||||
);
|
);
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class NingHttpClient implements NingHttpClientFacade {
|
||||||
}
|
}
|
||||||
byte[] ret = bytes.toByteArray();
|
byte[] ret = bytes.toByteArray();
|
||||||
bytes.close();
|
bytes.close();
|
||||||
log.info(
|
log.debug(
|
||||||
statusCode
|
statusCode
|
||||||
+ " "
|
+ " "
|
||||||
+ response.getStatusText()
|
+ response.getStatusText()
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class DiagnosticsHandler extends AbstractHandler {
|
||||||
) {
|
) {
|
||||||
baseRequest.setHandled(true);
|
baseRequest.setHandled(true);
|
||||||
|
|
||||||
Log.info(method + " <- /diags");
|
Log.debug(method + " <- /diags");
|
||||||
|
|
||||||
String detail;
|
String detail;
|
||||||
String summary;
|
String summary;
|
||||||
|
@ -50,7 +50,7 @@ public class DiagnosticsHandler extends AbstractHandler {
|
||||||
response.setStatus(500);
|
response.setStatus(500);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
response.setContentType("text/plain");
|
response.setContentType("text/plain");
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class FileHandler extends ResourceHandler {
|
||||||
HttpServletResponse response
|
HttpServletResponse response
|
||||||
) throws IOException, ServletException {
|
) throws IOException, ServletException {
|
||||||
if (!"GET".equals(baseRequest.getMethod())) return;
|
if (!"GET".equals(baseRequest.getMethod())) return;
|
||||||
LOG.info("GET <- {}", baseRequest.getRequestURI());
|
LOG.debug("GET <- {}", baseRequest.getRequestURI());
|
||||||
|
|
||||||
Matcher docKeyMatcher = DOC_KEY_PATTERN.matcher(target);
|
Matcher docKeyMatcher = DOC_KEY_PATTERN.matcher(target);
|
||||||
if (!docKeyMatcher.matches()) return;
|
if (!docKeyMatcher.matches()) return;
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class GitLfsHandler extends AbstractHandler {
|
||||||
&& target != null
|
&& target != null
|
||||||
&& target.matches("^/[0-9a-z]+\\.git/info/lfs/objects/batch/?$")
|
&& target.matches("^/[0-9a-z]+\\.git/info/lfs/objects/batch/?$")
|
||||||
) {
|
) {
|
||||||
Log.info(method + " <- /<project>.git/info/lfs/objects/batch");
|
Log.debug(method + " <- /<project>.git/info/lfs/objects/batch");
|
||||||
response.setContentType("application/vnd.git-lfs+json");
|
response.setContentType("application/vnd.git-lfs+json");
|
||||||
response.setStatus(422);
|
response.setStatus(422);
|
||||||
response.getWriter().println("{\"message\": \"ERROR: Git LFS is not supported on Overleaf\"}");
|
response.getWriter().println("{\"message\": \"ERROR: Git LFS is not supported on Overleaf\"}");
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class HealthCheckHandler extends AbstractHandler {
|
||||||
&& target != null
|
&& target != null
|
||||||
&& target.matches("^/health_check/?$")
|
&& target.matches("^/health_check/?$")
|
||||||
) {
|
) {
|
||||||
Log.info(method + " <- /health_check");
|
Log.debug(method + " <- /health_check");
|
||||||
baseRequest.setHandled(true);
|
baseRequest.setHandled(true);
|
||||||
response.setContentType("text/plain");
|
response.setContentType("text/plain");
|
||||||
if (bridge.healthCheck()) {
|
if (bridge.healthCheck()) {
|
||||||
|
|
|
@ -97,14 +97,14 @@ public class Oauth2Filter implements Filter {
|
||||||
));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.info("[{}] Checking if auth needed", project);
|
Log.debug("[{}] Checking if auth needed", project);
|
||||||
GetDocRequest doc = new GetDocRequest(project);
|
GetDocRequest doc = new GetDocRequest(project);
|
||||||
doc.request();
|
doc.request();
|
||||||
try {
|
try {
|
||||||
SnapshotApi.getResult(
|
SnapshotApi.getResult(
|
||||||
snapshotApi.getDoc(Optional.empty(), project));
|
snapshotApi.getDoc(Optional.empty(), project));
|
||||||
} catch (ForbiddenException e) {
|
} catch (ForbiddenException e) {
|
||||||
Log.info("[{}] Auth needed", project);
|
Log.debug("[{}] Auth needed", project);
|
||||||
getAndInjectCredentials(
|
getAndInjectCredentials(
|
||||||
project,
|
project,
|
||||||
servletRequest,
|
servletRequest,
|
||||||
|
@ -115,7 +115,7 @@ public class Oauth2Filter implements Filter {
|
||||||
} catch (MissingRepositoryException e) {
|
} catch (MissingRepositoryException e) {
|
||||||
handleMissingRepository(project, e, (HttpServletResponse) servletResponse);
|
handleMissingRepository(project, e, (HttpServletResponse) servletResponse);
|
||||||
}
|
}
|
||||||
Log.info("[{}] Auth not needed", project);
|
Log.debug("[{}] Auth not needed", project);
|
||||||
filterChain.doFilter(servletRequest, servletResponse);
|
filterChain.doFilter(servletRequest, servletResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ public class Oauth2Filter implements Filter {
|
||||||
if (clientIp == null) {
|
if (clientIp == null) {
|
||||||
clientIp = request.getRemoteAddr();
|
clientIp = request.getRemoteAddr();
|
||||||
}
|
}
|
||||||
Log.info("[{}] Authorization header present", clientIp);
|
Log.debug("[{}] Authorization header present", clientIp);
|
||||||
StringTokenizer st = new StringTokenizer(authHeader);
|
StringTokenizer st = new StringTokenizer(authHeader);
|
||||||
if (st.hasMoreTokens()) {
|
if (st.hasMoreTokens()) {
|
||||||
String basic = st.nextToken();
|
String basic = st.nextToken();
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class PostbackHandler extends AbstractHandler {
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response
|
HttpServletResponse response
|
||||||
) throws IOException, ServletException {
|
) throws IOException, ServletException {
|
||||||
Log.info(
|
Log.debug(
|
||||||
"PostbackHandler: " + baseRequest.getMethod()
|
"PostbackHandler: " + baseRequest.getMethod()
|
||||||
+ " <- "
|
+ " <- "
|
||||||
+ baseRequest.getHttpURI()
|
+ baseRequest.getHttpURI()
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class PrometheusHandler extends AbstractHandler {
|
||||||
&& target != null
|
&& target != null
|
||||||
&& target.matches("^/metrics/?$")
|
&& target.matches("^/metrics/?$")
|
||||||
) {
|
) {
|
||||||
Log.info(method + " <- /metrics");
|
Log.debug(method + " <- /metrics");
|
||||||
this.printMetrics(request, response);
|
this.printMetrics(request, response);
|
||||||
baseRequest.setHandled(true);
|
baseRequest.setHandled(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class StatusHandler extends AbstractHandler {
|
||||||
&& target != null
|
&& target != null
|
||||||
&& target.matches("^/status/?$")
|
&& target.matches("^/status/?$")
|
||||||
) {
|
) {
|
||||||
Log.info(method + " <- /status");
|
Log.debug(method + " <- /status");
|
||||||
baseRequest.setHandled(true);
|
baseRequest.setHandled(true);
|
||||||
response.setContentType("text/plain");
|
response.setContentType("text/plain");
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
|
|
|
@ -56,7 +56,7 @@ public abstract class Request<T extends Result> {
|
||||||
private T getResult() throws MissingRepositoryException, FailedConnectionException, ForbiddenException {
|
private T getResult() throws MissingRepositoryException, FailedConnectionException, ForbiddenException {
|
||||||
try {
|
try {
|
||||||
HttpResponse response = future.get();
|
HttpResponse response = future.get();
|
||||||
Log.info(
|
Log.debug(
|
||||||
"{} {} ({}B) -> " + url,
|
"{} {} ({}B) -> " + url,
|
||||||
response.getStatusCode(),
|
response.getStatusCode(),
|
||||||
response.getStatusMessage(),
|
response.getStatusMessage(),
|
||||||
|
@ -140,7 +140,7 @@ public abstract class Request<T extends Result> {
|
||||||
throw new FailedConnectionException(cause);
|
throw new FailedConnectionException(cause);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.error("Failed to parse JSON.", e);
|
Log.warn("Failed to parse JSON.", e);
|
||||||
throw new FailedConnectionException();
|
throw new FailedConnectionException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ public abstract class Request<T extends Result> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performGetRequest() {
|
private void performGetRequest() {
|
||||||
Log.info("GET -> " + url);
|
Log.debug("GET -> " + url);
|
||||||
try {
|
try {
|
||||||
HttpRequest request = Instance.httpRequestFactory.buildGetRequest(
|
HttpRequest request = Instance.httpRequestFactory.buildGetRequest(
|
||||||
new GenericUrl(url)
|
new GenericUrl(url)
|
||||||
|
@ -173,7 +173,7 @@ public abstract class Request<T extends Result> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performPostRequest() {
|
private void performPostRequest() {
|
||||||
Log.info("POST -> " + url);
|
Log.debug("POST -> " + url);
|
||||||
try {
|
try {
|
||||||
HttpRequest request = Instance.httpRequestFactory.buildPostRequest(
|
HttpRequest request = Instance.httpRequestFactory.buildPostRequest(
|
||||||
new GenericUrl(url),
|
new GenericUrl(url),
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class GetDocRequest extends SnapshotAPIRequest<GetDocResult> {
|
||||||
|
|
||||||
public GetDocRequest(Credential oauth2, String projectName) {
|
public GetDocRequest(Credential oauth2, String projectName) {
|
||||||
super(projectName, API_CALL, oauth2);
|
super(projectName, API_CALL, oauth2);
|
||||||
Log.info(
|
Log.debug(
|
||||||
"GetDocRequest({}, {})",
|
"GetDocRequest({}, {})",
|
||||||
"oauth2: <oauth2>",
|
"oauth2: <oauth2>",
|
||||||
"projectName: " + projectName
|
"projectName: " + projectName
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class GetDocResult extends Result {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromJSON(JsonElement json) {
|
public void fromJSON(JsonElement json) {
|
||||||
Log.info("GetDocResult: " + json);
|
Log.debug("GetDocResult: " + json);
|
||||||
JsonObject jsonObject = json.getAsJsonObject();
|
JsonObject jsonObject = json.getAsJsonObject();
|
||||||
if (jsonObject.has("status")) {
|
if (jsonObject.has("status")) {
|
||||||
switch (jsonObject.get("status").getAsInt()) {
|
switch (jsonObject.get("status").getAsInt()) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class GetForVersionRequest
|
||||||
) {
|
) {
|
||||||
super(projectName, API_CALL + "/" + versionID, oauth2);
|
super(projectName, API_CALL + "/" + versionID, oauth2);
|
||||||
this.versionID = versionID;
|
this.versionID = versionID;
|
||||||
Log.info(
|
Log.debug(
|
||||||
"GetForVersionRequest({}, {}, {})",
|
"GetForVersionRequest({}, {}, {})",
|
||||||
"oauth2: <oauth2>",
|
"oauth2: <oauth2>",
|
||||||
"projectName: " + projectName,
|
"projectName: " + projectName,
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class GetForVersionResult extends Result {
|
||||||
@Override
|
@Override
|
||||||
public void fromJSON(JsonElement json) {
|
public void fromJSON(JsonElement json) {
|
||||||
snapshotData = new SnapshotData(json);
|
snapshotData = new SnapshotData(json);
|
||||||
Log.info("GetForVersionResult({})", snapshotData);
|
Log.debug("GetForVersionResult({})", snapshotData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SnapshotData getSnapshotData() {
|
public SnapshotData getSnapshotData() {
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class GetSavedVersRequest
|
||||||
|
|
||||||
public GetSavedVersRequest(Credential oauth2, String projectName) {
|
public GetSavedVersRequest(Credential oauth2, String projectName) {
|
||||||
super(projectName, API_CALL, oauth2);
|
super(projectName, API_CALL, oauth2);
|
||||||
Log.info(
|
Log.debug(
|
||||||
"GetSavedVersRequest({}, {})",
|
"GetSavedVersRequest({}, {})",
|
||||||
"oauth2: <oauth2>",
|
"oauth2: <oauth2>",
|
||||||
"projectName: " + projectName
|
"projectName: " + projectName
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class GetSavedVersResult extends Result {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromJSON(JsonElement json) {
|
public void fromJSON(JsonElement json) {
|
||||||
Log.info("GetSavedVersResult({})", json);
|
Log.debug("GetSavedVersResult({})", json);
|
||||||
savedVers = new ArrayList<>();
|
savedVers = new ArrayList<>();
|
||||||
for (JsonElement elem : json.getAsJsonArray()) {
|
for (JsonElement elem : json.getAsJsonArray()) {
|
||||||
savedVers.add(
|
savedVers.add(
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class PushRequest extends SnapshotAPIRequest<PushResult> {
|
||||||
super(candidateSnapshot.getProjectName(), API_CALL, oauth2);
|
super(candidateSnapshot.getProjectName(), API_CALL, oauth2);
|
||||||
this.candidateSnapshot = candidateSnapshot;
|
this.candidateSnapshot = candidateSnapshot;
|
||||||
this.postbackKey = postbackKey;
|
this.postbackKey = postbackKey;
|
||||||
Log.info(
|
Log.debug(
|
||||||
"PushRequest({}, {}, {})",
|
"PushRequest({}, {}, {})",
|
||||||
"oauth2: <oauth2>",
|
"oauth2: <oauth2>",
|
||||||
"candidateSnapshot: " + candidateSnapshot,
|
"candidateSnapshot: " + candidateSnapshot,
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class PushResult extends Result {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromJSON(JsonElement json) {
|
public void fromJSON(JsonElement json) {
|
||||||
Log.info("PushResult({})", json);
|
Log.debug("PushResult({})", json);
|
||||||
JsonObject responseObject = json.getAsJsonObject();
|
JsonObject responseObject = json.getAsJsonObject();
|
||||||
String code = Util.getCodeFromResponse(responseObject);
|
String code = Util.getCodeFromResponse(responseObject);
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ public class Util {
|
||||||
deleteInDirectory(file);
|
deleteInDirectory(file);
|
||||||
}
|
}
|
||||||
file.delete();
|
file.delete();
|
||||||
Log.info("Deleted file: {}", file.getAbsolutePath());
|
Log.debug("Deleted file: {}", file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue