#Issue binding mongo as a service

1 messages · Page 1 of 1 (latest)

pale valley
#

I'm trying to create a mongo module but I have some issues to use it as a service.
Actually I can start the service and request it from the port forwarding doing a: dagger call service up --ports 27017:27017
If I try to use it as a service bind to a container I don't know why but I have a timeout.

I try to reproduce my setup with a test function in my module, I have also the timeout, the difference is in my real case the mongo function is called from a python container for running tests.

I saw in another thread a suggestion to use tiny but I didn't see any difference.

Also logs fron the mongo container when this one is started as a service seems good ( I can see the startup logs, etc ...)

I tried to put a sleep of 20s between the binding and my exec but it didn't change anything

the code of the module is available here: https://github.com/heuritech/daggerverse/blob/mongo/mongo/src/mongo/main.py

Someone has an idea what is wrong ?

GitHub

dagger public modules. Contribute to heuritech/daggerverse development by creating an account on GitHub.

hybrid fiber
pale valley
#

hi, ok I try that in some minutes but it seems to be like my real pipeline

#

@hybrid fiber base on my example not sure how you want I do that if I'm calling: the service method in my test method

#

or you want I create a module which install mongo ?

#

btw I would like my pipeline start the service I don't want to start it outside of my pipeline

hybrid fiber
#

Hey @pale valley just pulled your repository down and test is working as I expect? Here is the output:

Current Mongosh Log ID:    67aa4a8319bf190065a00aa0
Connecting to:        ***db://<credentials>@***db.service:27017/?directConnection=true&appName=***sh+2.3.8
Using MongoDB:        7.0.16
Using Mongosh:        2.3.8

For ***sh info see: https://www.***db.com/docs/***db-shell/


To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.***db.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.

------
   The server generated these startup warnings when booting
   2025-02-10T18:50:42.223+00:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never' in this binary version
   2025-02-10T18:50:42.223+00:00: vm.max_map_count is too low
------

test>

Is it possible you have something running on that port already? Usually it gives you an error.

Also, a trace in Dagger Cloud would be helpful to troubleshoot if you can.

pale valley
#

ok what did you do ?

#

I can try to setup a trace

hybrid fiber
#

I cloned the repo, ran dagger develop in the mongo dir and ran dagger call test

pale valley
#

ok becaue the expected output is something like that: { ok: 1 }

hybrid fiber
#

I am also able to call dagger call service up and get it exposed on 27017

pale valley
#

with service up it's working on my side but when I'm trying to attach the service I have an issue

#

ok I think I have an idea what was wrong ....

#

I can't explain exactly but I think when I launch my first command dagger which create the dagger container I was a vpn where the network mask can have some overlap

#

I'm no more connected to this vpn trash the container and now it's running

hybrid fiber
#

Interesting, was going to suggest dagger core engine local-cache prune next - but glad you got it sorted! VPNs can do some strange things

#

Your code was guy_fieri_chef_kiss though!

pale valley
#

thanks 🙂
I just try with another vpn which have a complete different network mask and I don't have the issue so I think it's that

#

The network in dagger between container is at the host level is not sandboxed in the dagger engine container ?

pale valley
#

Hi, I re-up the issue because today without any vpn started and with multiple times delete the dagger container I was blocked on the timeout issue with the service binding.

#

To give a little more context, I didn't stop / restart the computer so I start / stop 2 differents VPNs (wireguard and openvpn, both are never start together, it's only one)

#

I don't really know how to reproduce the setup but definitely in long term I will have the openvpn started all the day for accessing to different services

pale valley
#

and sometimes without any reasons another function fail due to mongo timeout but withtout any link 😦

#

this function is just to extract information and compute it

#

I'm a bit loss with this network issue

#

and it occurs with a fresh reboot without any vpn

pale valley
#

another point on this last error I have yet all my tests executed on the mongo

#

Also I'm mounting a directory in /outputs but this one is not mounted at this point but on the path of the source container and I'm sure to be in the right container because there is the script of the checkRun

pale valley
#

if I comment the service binding the checkRun is working well but my test are failling due to the missing mongo

#

What I'm doing is:

  • create a mongo service
  • create a directory called outputs
  • I'm looping on multiple libraries to run test in // + service binding for integration tests, on the test part I'm sending output and too different files with this pattern: /tests/{LIB NAME}/{exit_code,output.txt}
  • then merging this folder in the outputs folder
  • then mounting the outputs directory in the runCheck function on the path /outputs
  • then I'm creating folder mounting script, executing the script

On this last step if I have the mongo attach to the test container I have a strange error with the mkdir

#

To resume I think I have 2 issues (maybe linked but not sure):

  • Sometime I can't reach my mongo during the test part and in general when I'm in this state I can reproduce the issue in my mongo module with the ci-test function
  • When my tests are able to execute the the test I have a strange side effect in the runCheck function which parse / analyse outputs from previous tests but didn't do any network call, the mount if not good and the mkdir fail with a network issue about the dns
pale valley
#

I just give a try with the new release and now I have again the timeout on the test part with mongo

#

I have to do 1h-1h30 then I can be avaiable to deep dive in the issue if someone is available

pale valley
pale valley
#

I'm a bit loss on this topic, fpr the runCheck I can split in 2 calls, it's not ideal but I have the fealing it's related to this issue.

For network isssue on my integration test the code looks like:

        mongo = dag.mongo()
        mongo_svc = mongo.service()
        for i in self.libraries_impacted:


            outputs = outputs.with_directory(
                f"{output_root_path}/{i}",
                (
                    dag.
                    python(
                        self.pipeline_id,
                        self.source.directory(f"libraries/{i}"),
                        sub_path=i
                    ).
                    with_discover_python_version().
                    with_python_path().
                    with_poetry_creds(
                        self.__pypi_username,
                        self.__pypi_password,
                        "htpypi",
                        publish_url=self.__pypi_publish_url,
                    ).
                    install().
                    # TODO(check if we need that)
                    # .with_secret_dotenv(
                    #     content=config_backend.get_secret(f"CI/LIBRARY_{i.upper()}_CONF")
                    # )
                    with_env(name="MONGO_MAIN_URI", value_secret=mongo.uri()).
                    with_env(name="MONGODB", value_secret=mongo.uri()).
                    test(
                        services=[
                            mongo_svc, # TODO(Inject only when it's required)
                        ]
                    )
                )
            )

should I move the mongo instantiation in the loop maybe to solve the network issue ?

#

@hybrid fiber ? (sorry to ping you but it's a blocking point for rollout dagger in my company)

hybrid fiber
#

Hey just trying to catch up on the thread

pale valley
#

👋

#

ok thanks I let you catch up

#

I just give a try moving the mongo create in the loop seems to work but not sure if it's really stable or it will break later

hybrid fiber
#

Just so I'm on the same page, the issue occurs when the service is running for a long time or reusing it for multiple containers/runs?

#

Also, is the code on the repo the most up to date so I can pull it down?

pale valley
#

I want to start a mongo for multiple test container but if it's limitation I can start one by test container.
The mongo code is on main on the public repo but the python test is in a private repo because it's testing a private libraries

#

maybe I can share my screen for this private part ? or something else

#

I think it's possible to recreate a similar case I trying to see

#

(I'm trying to reproduce a similar case)