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

[#5626] feat (gvfs-fuse): Set up a submodule project for the Gvfs-fuse #5627

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions clients/filesystem-fuse/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

[build]
target-dir = "build"

1 change: 1 addition & 0 deletions clients/filesystem-fuse/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Cargo.lock
33 changes: 33 additions & 0 deletions clients/filesystem-fuse/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

[package]
name = "filesystem-fuse"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we plan to publish our lib to crates? If yes, maybe use a more meaningful name and add gravitino to the name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may probably push the lib in future, but for now we don't have such requirement.

version = "0.8.0-incubating-SNAPSHOT"
edition = "2021"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the usage of this "edition", shall we remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version specify the minimum Rust compiler version required for this project.

rust-version = "1.75"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add homepage, repository, license ?


[[bin]]
name = "gvfs-fuse"
path = "src/main.rs"

[dependencies]
futures-util = "0.3.30"
libc = "0.2.164"
log = "0.4.22"
tokio = { version = "1.38.0", features = ["full"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
75 changes: 75 additions & 0 deletions clients/filesystem-fuse/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.gradle.api.tasks.Exec

val enablePgvfsFuse = project.hasProperty("enable_gvfs_fuse")

if (enablePgvfsFuse) {
val checkRustEnvironment by tasks.registering(Exec::class) {
description = "Check if Rust environment."
group = "verification"
commandLine("bash", "-c", "cargo --version")
standardOutput = System.out
errorOutput = System.err
isIgnoreExitValue = false
}

val compileRust by tasks.registering(Exec::class) {
dependsOn(checkRustEnvironment)
description = "Compile the Rust project"
workingDir = file("$projectDir")

commandLine(
"bash",
"-c",
"""
set -e
echo "Checking the code format"
cargo fmt --all -- --check

echo "Running clippy"
cargo clippy --all-targets --all-features --workspace -- -D warnings

echo "Compiling Rust project"
cargo build --release
""".trimIndent()
)
}

val testRust by tasks.registering(Exec::class) {
dependsOn(checkRustEnvironment)
description = "Run tests in the Rust project"
group = "verification"
workingDir = file("$projectDir")
commandLine("bash", "-c", "cargo test --release")

standardOutput = System.out
errorOutput = System.err
}

tasks.named("build") {
dependsOn(compileRust)
}
tasks.named("test") {
dependsOn(testRust)
}
} else {
println("Skipping Gvfs-fuse tasks since -Penable_gvfs_fuse is not enabled.")
}
43 changes: 43 additions & 0 deletions clients/filesystem-fuse/check_rust_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -e

if ! command -v cargo &> /dev/null; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of installing rust env automaticlly, I suggest to provide a separate tool to setup dev environments manually.
If there is no rust env in the machine, don't build it

echo "Rust is not installed. Installing Rust..."

if command -v curl &> /dev/null; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
elif command -v wget &> /dev/null; then
wget -qO- https://sh.rustup.rs | sh -s -- -y
else
echo "Error: Neither curl nor wget is available. Please install one of them to proceed."
exit 1
fi

export PATH="$HOME/.cargo/bin:$PATH"
if command -v cargo &> /dev/null; then
echo "Rust has been installed successfully."
else
echo "Error: Rust installation failed. Please check your setup."
exit 1
fi
else
echo "Rust is already installed: $(cargo --version)"
fi
Comment on lines +22 to +43
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd do this to 1) return early if possible 2) save some of the nested if- tests.

if command -v cargo &> /dev/null; then
    echo "Rust is already installed: $(cargo --version)"
    exit 0
fi

echo "Rust is not installed. Installing Rust..."
# the rest of the install and check
# ...
if ! command -v cargo &> /dev/null; then
    echo "Error: Rust installation failed. Please check your setup."
    exit 1
fi

echo "Rust has been installed successfully."
exit 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cargo command does not run after running the rust installation command. Unless you set the PATH environment variable or restart the bash session.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well ... we are assuming that cargo is installed in a specific directory, i.e. $HOME/.cargo/bin, any way...
The only difference is that we manually invoke the binary (with full path) or let the "polluted" shell to find it. Right?

Copy link
Contributor Author

@diqiu50 diqiu50 Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the cargo install script will add logic to modify the PATH inn the .profile. If we restart the shell session, it will automatically add this environment variable.
Is modifying the PATH not allowed?

30 changes: 30 additions & 0 deletions clients/filesystem-fuse/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

use log::debug;
use log::info;
use std::process::exit;

#[tokio::main]
async fn main() {
tracing_subscriber::fmt().with_env_filter("debug").init();
info!("Starting filesystem...");
debug!("Shutdown filesystem...");
exit(0);
}
23 changes: 23 additions & 0 deletions clients/filesystem-fuse/tests/it.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#[test]
fn test_math_add() {
assert_eq!(1, 1);
}
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ include(
"clients:filesystem-hadoop3",
"clients:filesystem-hadoop3-runtime",
"clients:client-python",
"clients:cli"
"clients:cli",
"clients:filesystem-fuse"
)
include("iceberg:iceberg-common")
include("iceberg:iceberg-rest-server")
Expand Down
Loading