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

Error: Kind: I/O error: Device or resource busy (os error 16) when using service.namespace.svc.cluster.local as host #1085

Closed
dev-with-no-username opened this issue Apr 20, 2024 · 2 comments
Assignees

Comments

@dev-with-no-username
Copy link

Versions/Environment

Rust version: 1.77.1
Mongodb version: 2.8.2
OS: windows subsystem linux 2
cargo pkgid mongodb: registry+https://github.com/rust-lang/crates.io-index#[email protected]
cargo pkgid bson: registry+https://github.com/rust-lang/crates.io-index#[email protected]
Mongo Replicaset
Kubernetes on k3d

Describe the bug

I try to connect to mongodb pod in a 'persistence' namespace from a pod of rust actix-web server in 'security' namespace, using the service name of mongodb pod, but i get this error:

Error {  
  kind: ServerSelection { 
    message: "Server selection timeout: No available servers. Topology: { 
      Type: Single, 
      Servers: [ 
        { 
          Address: mongodb.persistence.svc.cluster.local:27017, 
          Type: Unknown, 
          Error: Kind: I/O error: Device or resource busy (os error 16), 
          labels: {} 
        } 
      ] 
     }", 
    }, 
  labels: {}, 
  wire_version: None, 
  source: None,
} 

In local this doesn't occur and even if I try pointing from rust running local to ingress of mongodb pod (or port-forwarding the mongodb pod), it works as expected, so I can't understand how this happens. I also used a 'busybox' pod, inside 'security' namespace, executing 'nslookup mongodb.persistence.svc.cluster.local' and it works, so the mongodb pod and service seems to be ok.

I'm making the connection with below code:

let credential = Credential::builder()
            .username(db_clone.username)
            .password(db_clone.password)
            .source(db_clone.source)
            .mechanism(AuthMechanism::ScramSha256)
            .build();

let client_options = ClientOptions::builder()
            .app_name("rust-idp".to_string())
            .credential(credential)
            .hosts(vec![
                ServerAddress::Tcp { 
                    host: format!("{}", db_clone.host).to_string(), 
                    port: Some(27017) 
                }
            ])
            .direct_connection(true)
            .connect_timeout(Some(Duration::from_secs(30)))
            .build();

I tried even without .direct_connection() (and without increasing .connect_timeout(), that I increased to try if there is some delay) but it didn't work, the only change in not using .direct_connetion() is the 'Topology Type' that changes from 'Single' to 'Unknown' in the error. I also used 'mongodb://mongodb.persistence.svc.cluster.local' as host but it didn't work.

It's the first time I try to connect from a rust pod to mongodb pod, so I don't have any other experience, and I'm fairly new to Rust so all this, looks very strange to me (considering that using Golang this works as expected).

Thanks in advance

@isabelatkinson
Copy link
Contributor

Hi @Leonardo-94, thanks for opening this issue! The error you're receiving:

I/O error: Device or resource busy (os error 16),

indicates that this issue is likely not related to the driver itself, but instead related to your setup or how you're connecting. I recommend posting this question on the community forums where you can get some help debugging this!

@dev-with-no-username
Copy link
Author

dev-with-no-username commented Apr 29, 2024

Hi @isabelatkinson, thanks for your response. It looks very strange cause using the IP of the service (instead of the service.namespace.svc.cluster.local) as host, works well. But ok, if you say that this is a setup problem, I try to post a question on the community forum.
I let you decide whether to close the issue or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants