Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Upload endpoint not available #132

Open
2 tasks done
orousseau49170 opened this issue Jan 23, 2025 · 2 comments
Open
2 tasks done

[Bug]: Upload endpoint not available #132

orousseau49170 opened this issue Jan 23, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@orousseau49170
Copy link
Contributor

Bug Description

I'm using Docker to run the app-sim but the upload endpoint does not answer

curl http://localhost:3000/upload
curl: (7) Failed to connect to localhost port 3000 after 0 ms: Couldn't connect to server

Expected Behavior

Reason:
We did several tests with Alex - @noMoreCLI , and it seems that:
- Even if we define a specific port in the config.yaml, the value is not used in entrypoint.sh, it uses exposedPort instead
- For the java service, it always listen on port 8080 (same configuration will work if we use a nodejs service instead of Java)

example of a working configuration (extract of config.yaml)
services:
frontend:
type: nodejs
port: 3000
endpoints:
http:
/upload:
- http://processing:8080/magicByte
- http://processing:8080/virus

Non-working config:
services:
frontend:
type: java
port: 3000
endpoints:
http:
/upload:
- http://processing/magicByte
- http://processing/virus

Affected Version

v1.0.0

Steps to Reproduce

docker run --rm -t -i -v ${PWD}:/mnt ghcr.io/cisco-open/app-simulator-generators-docker-compose --config /mnt/config.yaml --output /mnt/docker-compose.yaml

Docker compose up -d

curl http://localhost:3000/upload

Config.yaml:services:
frontend:
type: java
port: 3000
endpoints:
http:
/upload:
- http://processing/magicByte
- http://processing/virus
processing:
type: java
port: 8080
endpoints:
http:
/magicByte:
- cache,128
/virus:
- http://virus-scanner/scan
virus-scanner:
type: nodejs
endpoints:
http:
scan:
- sleep,1500
- call: error,500,Scan failed
probability: 0.1
- sleep,500
loaders:
user-1:
type: curl
wait: 0
sleep: 2
urls:
- http://frontend/upload
- http://frontend/upload
- http://frontend/upload

Checklist

@orousseau49170 orousseau49170 added bug Something isn't working triage This issue or pull request requires triaging labels Jan 23, 2025
@svrnm svrnm removed the triage This issue or pull request requires triaging label Jan 23, 2025
@noMoreCLI
Copy link
Contributor

looking at the java code I can see, that we're not using the port provided in the config before starting the server:

    int port = 8080;
    // CacheManager cacheManager;

    if (args.length > 0) {
      port = Integer.parseInt(args[0]);
    }

    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    StatusPrinter.print(loggerContext);

    logger.info("Reading AppConfig");
    String envAppConfig = System.getenv("APP_CONFIG");
    logger.info("Using config {}", envAppConfig);
    if (envAppConfig == null) {
      envAppConfig = "{\"endpoints\":{\"http\":{}}}";
    }

    JsonReader jsonReader = Json.createReader(new StringReader(envAppConfig));
    JsonObject config = jsonReader.readObject();

    CacheManager cm = CacheManager.getInstance();

    cm.addCache("cache1");

    cache = cm.getCache("cache1");

    logger.info("Starting Server on port {}", port);
    Server server = new Server(port);

Also, with the change of the default port of 8080 that breaks the ease of use for non-k8s environments @svrnm. In k8s the service maps port 8080 from the container to port 80, but thats not available in docker-compose. We might need to revert that, what do you think?

@svrnm
Copy link
Member

svrnm commented Jan 24, 2025

looking at the java code I can see, that we're not using the port provided in the config before starting the server:

The port in the config is not the port that should be used here, that's why we renamed it to "exposedPort", I might need to fix that for the docker compose generator still. The port the service uses is configured via SERVICE_DEFAULT_PORT environment variable, but we might consider moving this into the configuration as well (with a proper name to distinguish it from the exposedPort), however I still think we need to think about moving those ports into the endpoints.http.* section if we ever want to support additional endpoint types (grpc, message queues, etc.)

Also, with the change of the default port of 8080 that breaks the ease of use for non-k8s environments @svrnm. In k8s the service maps port 8080 from the container to port 80, but thats not available in docker-compose. We might need to revert that, what do you think?

The default port is still 8080, what I do for docker compose is that by default it is remapped to 80, such that the services can communicate via port-less URLs between each other since such a mapping is not possible with compose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants