You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "Zyyeric (via GitHub)" <gi...@apache.org> on 2024/08/09 19:08:04 UTC

[I] bug: default GCS credentials load behaviour does not work [opendal]

Zyyeric opened a new issue, #4992:
URL: https://github.com/apache/opendal/issues/4992

   ### Describe the bug
   
   When attempting to use the GCS storage service, opendal fails to load the application default credential from ADC Well-known places (https://cloud.google.com/docs/authentication/application-default-credentials). I did realize that this is implemented within the load_via_well_known_location() in reqsign/src/google/credential.rs. However, while having the ADC stored within [HOME/.config/gcloud/application_default_credentials.json], I ended up getting this error. 
   
   ```
   Unexpected (temporary) at stat, context: { called: reqsign::LoadCredential, service: gcs, path: file.txt } => loading credential to sign http request, source: error sending request for url (http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token?scopes=https://www.googleapis.com/auth/devstorage.read_write)
   ```
   
   ### Steps to Reproduce
   
   Obtain ADC through gcloud CLI 
   
   ```
   gcloud auth application-default login 
   ```
   
   which shall output 
   
   ```
   Your browser has been opened to visit:
   
   https://accounts.google.com/o/oauth2/auth?...
   
   Credentials saved to file: 
   [HOME/.config/gcloud/application_default_credentials.json]
   
   These credentials will be used by any library that requests Application Default Credentials (ADC).
   ...
   ```
   
   Then, create a basic opendal operator, and send a head request. 
   ````
       let mut builder = opendal::services::Gcs::default();
       builder
           .bucket("my-bucket-here");
   
       let op = Operator::new(builder)?
           .layer(LoggingLayer::default())
           .finish();
   
       // Check if the file exists by querying its metadata
       match op.stat("my-path-here).await {
           Ok(metadata) => {
               // If successful, print the metadata or a success message
               println!("File exists! Metadata: {:?}", metadata);
           }
           Err(e) => {
               // If there is an error, print it
               eprintln!("Error accessing file: {}", e);
           }
       }
   ````
   
   ### Expected Behavior
   
   Opendal shall load the credential and returns the metadata of the file stored in GCS
   
   ### Additional Context
   
   _No response_
   
   ### Are you willing to submit a PR to fix this bug?
   
   - [ ] Yes, I would like to submit a PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: default GCS credentials load behaviour does not work [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #4992:
URL: https://github.com/apache/opendal/issues/4992#issuecomment-2964985419

   Hi, The `IncompleteMessage` error indicates that there are something wrong your http clients. Please try enabling rustls or native-tls features for `reqwest`.
   
   If it doesn't work, feel free to start a new issue. I'm willing to help get it figured out.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: default GCS credentials load behaviour does not work [opendal]

Posted by "Zyyeric (via GitHub)" <gi...@apache.org>.
Zyyeric closed issue #4992: bug: default GCS credentials load behaviour does not work
URL: https://github.com/apache/opendal/issues/4992


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: default GCS credentials load behaviour does not work [opendal]

Posted by "Zyyeric (via GitHub)" <gi...@apache.org>.
Zyyeric commented on issue #4992:
URL: https://github.com/apache/opendal/issues/4992#issuecomment-2282692779

   My ```XDG_CONFIG_HOME```configuration shall be empty. I will also look into the credential load logic when I have time. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: default GCS credentials load behaviour does not work [opendal]

Posted by "jonathan-ostrander (via GitHub)" <gi...@apache.org>.
jonathan-ostrander commented on issue #4992:
URL: https://github.com/apache/opendal/issues/4992#issuecomment-4007026652

   @Xuanwo It seems like it stems from opendal being pinned to `reqsign` version `0.16.5` which doesn't have support for parsing an `authorized_user` out of the application default credentials. This leads to the auth flow falling back to trying to use the GCE VM metadata server.
   
   It seems like https://github.com/apache/opendal/pull/7229 should close the issue. Is there a planned release for opendal that will include this change?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: default GCS credentials load behaviour does not work [opendal]

Posted by "kingwingfly (via GitHub)" <gi...@apache.org>.
kingwingfly commented on issue #4992:
URL: https://github.com/apache/opendal/issues/4992#issuecomment-2965161868

   ```toml
   opendal = { version = "0.53", features = ["services-gcs"] }
   reqwest = { version = "*", features = ["rustls-tls"] } # native-tls is also tried
   tokio = { version = "1", features = ["full"] }
   ```
   Thank u @Xuanwo . However, it still reports `IncompleteMessage` error. Am I enabling the feature in the right way?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: default GCS credentials load behaviour does not work [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #4992:
URL: https://github.com/apache/opendal/issues/4992#issuecomment-2965208017

   > opendal = { version = "0.53", features = ["services-gcs"] }
   > reqwest = { version = "*", features = ["rustls-tls"] } # native-tls is also tried
   > tokio = { version = "1", features = ["full"] }
   > Thank u [@Xuanwo](https://github.com/Xuanwo) . However, it still reports `IncompleteMessage` error. Am I enabling the feature in the right way?
   
   Seems we need more context for this. Would you like to start a new issue to report this bug? In the issue, I wish you to include the log message output by opendal via `RUST_LOG=debug`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: default GCS credentials load behaviour does not work [opendal]

Posted by "kingwingfly (via GitHub)" <gi...@apache.org>.
kingwingfly commented on issue #4992:
URL: https://github.com/apache/opendal/issues/4992#issuecomment-2965210867

   ```
   running 1 test
   2025-06-12T05:49:35.193251Z DEBUG ThreadId(02) reqwest::connect: 788: starting new connection: http://metadata.google.internal/    
   2025-06-12T05:49:37.175589Z DEBUG ThreadId(02) reqwest::connect: 788: starting new connection: http://metadata.google.internal/    
   2025-06-12T05:49:39.372960Z DEBUG ThreadId(02) reqwest::connect: 788: starting new connection: http://metadata.google.internal/    
   2025-06-12T05:49:44.490614Z DEBUG ThreadId(02) reqwest::connect: 788: starting new connection: http://metadata.google.internal/    
   [test/probe.rs:17:5] op.check().await = Err(
       Error {
           kind: Unexpected,
           message: "loading credential to sign http request",
   ```
   
   It fails to reach a strange endpoint... I'll raise a new issue then.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: default GCS credentials load behaviour does not work [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #4992:
URL: https://github.com/apache/opendal/issues/4992#issuecomment-2295341913

   Hi, @Zyyeric has this issue been resolved? Would you like to share more details?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: default GCS credentials load behaviour does not work [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #4992:
URL: https://github.com/apache/opendal/issues/4992#issuecomment-2282729691

   > My `XDG_CONFIG_HOME`configuration shall be empty. I will also look into the credential load logic when I have time.
   
   Thanks in advance!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: default GCS credentials load behaviour does not work [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #4992:
URL: https://github.com/apache/opendal/issues/4992#issuecomment-2282481616

   Hi, thanks for the report. reqsign will try to load the following env to decide the path to load file:
   
   https://github.com/Xuanwo/reqsign/blob/c24accec764b34c4db600bb99e03ed9c80ba5234/src/google/credential.rs#L185-L210
   
   ```rust
   fn load_via_well_known_location(&self) -> Result<Option<Credential>> {
       if self.disable_well_known_location {
           return Ok(None);
       }
   
       let config_dir = if let Ok(v) = env::var("APPDATA") {
           v
       } else if let Ok(v) = env::var("XDG_CONFIG_HOME") {
           v
       } else if let Ok(v) = env::var("HOME") {
           format!("{v}/.config")
       } else {
           // User's env doesn't have a config dir.
           return Ok(None);
       };
   
       let cred = Self::load_file(&format!(
           "{config_dir}/gcloud/application_default_credentials.json"
       ))?;
       Ok(Some(cred))
   }
   ```
   
   Do you have different `XDG_CONFIG_HOME` configurations? I will re-check the `gcloud`'s load logic to make sure we can align.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: default GCS credentials load behaviour does not work [opendal]

Posted by "kingwingfly (via GitHub)" <gi...@apache.org>.
kingwingfly commented on issue #4992:
URL: https://github.com/apache/opendal/issues/4992#issuecomment-2964947509

   Hello, is there anyone encountered the same problem and search to here?
   
   My `gcloud` can list bucket correctly with `gcloud storage ls gs://xxx-datasets/`. But opendal not works...
   
   ```rust
   pub fn create_operator(bucket: impl AsRef<str>) -> Result<Operator> {
       let builder = services::Gcs::default().bucket(bucket.as_ref());
       Ok(Operator::new(builder)?.finish())
   }
   
   #[tokio::test]
   async fn basic_probe() -> Result<()> {
       let op = create_operator("xxx-datasets")?;
       dbg!(op.check().await);
       Ok(())
   }
   ```
   I got
   ```sh
   op.check().await = Err(
       Error {
           kind: Unexpected,
           message: "loading credential to sign http request",
           status: Temporary,
           operation: "list",
           context: [
               (
                   "called",
                   "reqsign::LoadCredential",
               ),
               (
                   "service",
                   "gcs",
               ),
               (
                   "path",
                   "/",
               ),
               (
                   "listed",
                   "0",
               ),
           ],
           source: Some(
               reqwest::Error {
                   kind: Request,
                   source: hyper_util::client::legacy::Error(
                       SendRequest,
                       hyper::Error(
                           IncompleteMessage,
                       ),
                   ),
               },
           ),
       },
   )
   ```
   I'm pretty like this crate, but anyone could tell me if opendal can works well with GCS?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org