examples icon indicating copy to clipboard operation
examples copied to clipboard

CPU_PERCENT and GPS examples do not expose port

Open johnwalicki opened this issue 2 years ago • 5 comments

Describe the bug The CPU Percent example does not expose the port to query the CPU load See https://github.com/open-horizon/examples/blob/master/edge/services/cpu_percent/horizon/service.definition.json

The README shows a curl excample but the user would need to run the curl within the workload container. I am not certain that is the expected behavior. The Makefile has a test rule which calls

../../../tools/curlServiceTest.sh

which is here: https://github.com/open-horizon/examples/blob/master/tools/curlServiceTest.sh That script does a docker exec into the container and curl works.

If the purpose is to not expose the CPU performance data, then clarify in the README If the intended example should report the CPU data, then service.definition.json should expose the port.

johnwalicki avatar Sep 13 '22 15:09 johnwalicki

Hi John, I will work with Troy, I think he owns/maintains those examples.

tbsloan avatar Sep 13 '22 17:09 tbsloan

John - I contacted Troy - he was aware from examples meeting where this was discussed:

Troy Fine 1:49 PM Hey Tim, ah yes John brought that up in the examples working group meeting this morning and mentioned he would open the issue … I’ll take a look at some of the documentation around and try to decide whether to make the change to expose the port or simply update the readme to mention you would need to exec into the container first

tbsloan avatar Sep 13 '22 17:09 tbsloan

@tbsloan Oops, sorry for the misdirect. GitHub type-ahead tagged you instead of Troy.

johnwalicki avatar Sep 13 '22 18:09 johnwalicki

@johnwalicki No worries, we got it moved over to Troy.

tbsloan avatar Sep 13 '22 18:09 tbsloan

Similar to the open-horizon-services web-helloworld-python service exposes port 8000 we would like cpu_percent and gps to also expose the port to allow the service to be curl-ed from outside the container.

web-helloworld-python service.json file: https://github.com/open-horizon-services/web-helloworld-python/blob/main/service.json

cpu_percent: https://github.com/open-horizon/examples/tree/master/edge/services/cpu_percent

gps: https://github.com/open-horizon/examples/tree/master/edge/services/gps

t-fine avatar Oct 11 '22 00:10 t-fine

@t-fine Could I be assigned this issue ?

If I am not wrong we need to expose the port in cpu_percent/horizon/service.defination.json and gps/horizon/service.defination.json so that the service can be curl-ed from outside the container.

saurav1004 avatar Feb 03 '23 11:02 saurav1004

@saurav1004 - Yes, the service.definition.json files would expose the port. The web-helloworld-python service json has a snippet. Check the port number, it might be 8080

        "ports": [ 
          { "HostIP": "0.0.0.0", "HostPort": "8080:8080/tcp" }
        ]

johnwalicki avatar Feb 03 '23 21:02 johnwalicki

Yes the port number is 8080 for both the services cpu_percent and gps

saurav1004 avatar Feb 04 '23 02:02 saurav1004

@johnwalicki I have created a draft pull request, will mark it "ready for review" once you confirm.

saurav1004 avatar Feb 04 '23 03:02 saurav1004

The PR looks good. I think it's ready to merge.

johnwalicki avatar Feb 04 '23 05:02 johnwalicki

Thanks, I have marked it ready for review. You should be able to merge it now.

saurav1004 avatar Feb 04 '23 05:02 saurav1004

With the bump of version number of cpu_percent and gps in the PR just merged (https://github.com/open-horizon/examples/pull/580) I will be closing this issue.

t-fine avatar Feb 28 '23 15:02 t-fine