Skip to content

Commit

Permalink
Remove JNA
Browse files Browse the repository at this point in the history
JNA doesn't work in a shadow jar, which we'll need for workspace test
rigs in other repos
  • Loading branch information
MrCreosote committed Mar 28, 2024
1 parent 6fdb23b commit 23a2657
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 32 deletions.
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ dependencies {
implementation 'javax.servlet:servlet-api:2.5'
// joda-time is required for kbase-common and syslog4j
implementation 'joda-time:joda-time:2.2'
// needed for syslog4j
implementation 'net.java.dev.jna:jna:3.4.0'
// this is OOOOOOLD. But that probably means updating java_common
implementation 'org.eclipse.jetty.aggregate:jetty-all:7.0.0.v20091005'

Expand Down
4 changes: 2 additions & 2 deletions docsource/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
# built documents.
#
# The short X.Y version.
version = '0.14'
version = '0.15'
# The full version, including alpha/beta/rc tags.
release = '0.14.3'
release = '0.15.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 5 additions & 1 deletion docsource/releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
Workspace service release notes
===============================

VERSION: 0.14.3 (Released 2/22/2024)
VERSION: 0.15.0 (Released TBD)
------------------------------------

BACKWARDS INCOMPATIBILIES:

* The Docserver now logs to standard out in the same way as the workspace server.

UPDATES:

* The MongoDB clients have been updated to the most recent version and the service tested
Expand Down
59 changes: 36 additions & 23 deletions src/us/kbase/workspace/docserver/DocServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.productivity.java.syslog4j.SyslogIF;

import com.google.common.io.Files;

Expand All @@ -34,10 +35,11 @@ public class DocServer extends HttpServlet {
/**
* The name of the service that this document server is serving documents
* for. This name will be used to find the appropriate section of the
* KBase deploy.cfg configuration file if the name is not specified in the
* environment.
* KBase deploy.cfg configuration file.
*/
public static final String DEFAULT_COMPANION_SERVICE_NAME = "Workspace";
public static final String COMPANION_SERVICE_NAME = "Workspace";
// TODO CONFIG configure directly vs going through JsonSererServlet

/**
* The name of this document server, used for logging purposes.
*/
Expand All @@ -56,10 +58,8 @@ public class DocServer extends HttpServlet {

private static final FileNameMap FILE_NAME_MAP = URLConnection.getFileNameMap();

private static final String DONT_TRUST_X_IP_HEADERS =
"dont_trust_x_ip_headers";
private static final String DONT_TRUST_X_IP_HEADERS2 =
"dont-trust-x-ip-headers";
private static final String DONT_TRUST_X_IP_HEADERS = "dont_trust_x_ip_headers";
private static final String DONT_TRUST_X_IP_HEADERS2 = "dont-trust-x-ip-headers";
private static final String STRING_TRUE = "true";

private final String docsLoc;
Expand All @@ -83,18 +83,13 @@ public class DocServer extends HttpServlet {
public DocServer() {
//TODO JERSEY switch to a jersey endpoint when that's available, ditch logger, etc. Pretty big rewrite/simplification
super();
/* really should try and get the companion service name from the env
* here, but not worth the effort
*/
JsonServerSyslog templogger = new JsonServerSyslog(
DEFAULT_COMPANION_SERVICE_NAME, JsonServerServlet.KB_DEP,
JsonServerSyslog.LOG_LEVEL_INFO, false);
if (sysLogOut != null) {
templogger.changeOutput(sysLogOut);
}
// getConfig() gets the service name from the env if it exists
JsonServerSyslog.setStaticUseSyslog(false);
final JsonServerSyslog templogger = getLogger(COMPANION_SERVICE_NAME, sysLogOut);

// getConfig() gets the service name from the env if it exists which is bad
// since the Workspace doesn't. Need to redo configuration handling at some point
final Map<String, String> config = JsonServerServlet.getConfig(
DEFAULT_COMPANION_SERVICE_NAME, templogger);
COMPANION_SERVICE_NAME, templogger);

String serverName = config.get(CFG_SERVICE_NAME);
if (serverName == null || serverName.isEmpty()) {
Expand All @@ -110,16 +105,34 @@ public DocServer() {
docsLoc = dlog;
}
}
logger = new JsonServerSyslog(serverName, JsonServerServlet.KB_DEP,
JsonServerSyslog.LOG_LEVEL_INFO, false);
if (sysLogOut != null) {
logger.changeOutput(sysLogOut);
}
logger = getLogger(serverName, sysLogOut);
this.trustX_IPHeaders =
!STRING_TRUE.equals(config.get(DONT_TRUST_X_IP_HEADERS)) &&
!STRING_TRUE.equals(config.get(DONT_TRUST_X_IP_HEADERS2));
}

private JsonServerSyslog getLogger(
final String serverName,
final SyslogOutput output) {
final JsonServerSyslog logger = new JsonServerSyslog(
serverName, JsonServerServlet.KB_DEP, JsonServerSyslog.LOG_LEVEL_INFO, false);
if (output == null) {
logger.changeOutput(new SyslogOutput() {

Check warning on line 120 in src/us/kbase/workspace/docserver/DocServer.java

View check run for this annotation

Codecov / codecov/patch

src/us/kbase/workspace/docserver/DocServer.java#L120

Added line #L120 was not covered by tests
// this is manually tested
@Override
public void logToSystem(
final SyslogIF log,
final int level,
final String message) {
System.out.println(message);
}

Check warning on line 128 in src/us/kbase/workspace/docserver/DocServer.java

View check run for this annotation

Codecov / codecov/patch

src/us/kbase/workspace/docserver/DocServer.java#L127-L128

Added lines #L127 - L128 were not covered by tests
});
} else {
logger.changeOutput(output);
}
return logger;
}

@Override
protected void doOptions(
final HttpServletRequest request,
Expand Down
2 changes: 1 addition & 1 deletion src/us/kbase/workspace/test/kbase/JSONRPCLayerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
*/
public class JSONRPCLayerTest extends JSONRPCLayerTester {

private static final String VER = "0.14.3";
private static final String VER = "0.15.0";

@Test
public void ver() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

public class SchemaUpdaterCLITest {

private static final String VERSION = "0.14.3";
private static final String VERSION = "0.15.0";

private static final List<String> HELP = list(
"Usage: update_workspace_database_schema [-chosV] <CONFIG_FILE>",
Expand Down
2 changes: 1 addition & 1 deletion src/us/kbase/workspace/version/WorkspaceVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public class WorkspaceVersion {
private WorkspaceVersion() {};

/** The version. */
public static final String VERSION = "0.14.3";
public static final String VERSION = "0.15.0";

}
2 changes: 1 addition & 1 deletion test/workspace_container_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""

WORKSPACE_VERSION = "0.14.3"
WORKSPACE_VERSION = "0.15.0"

AUTH_URL = "http://localhost:8080"
WS_URL = "http://localhost:7058"
Expand Down

0 comments on commit 23a2657

Please sign in to comment.