Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
fix: remove ntfs zone files
  • Loading branch information
hunjixin committed Aug 9, 2024
1 parent 7fb4352 commit bff8398
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 37 deletions.
58 changes: 53 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,69 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Run Clippy
run: cargo +nightly clippy --fix --workspace --exclude jiaozifs_client_rs --allow-dirty
- name: Install git
run: |
sudo apt update
sudo apt install git
- name: Create mongo Docker container
uses: DigiPie/[email protected]
with:
image_version: latest
port: 27017

- name: Install Protoc
uses: arduino/setup-protoc@v3

- name: Run tests
run: cargo test --verbose --workspace
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy rustfmt

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Start minikube
uses: medyagh/setup-minikube@latest

- name: Build image
- name: Enabel plugin
run: |
eval $(minikube -p minikube docker-env)
alias kubectl="minikube kubectl --"
minikube addons enable metrics-server
- name: Install Helm
uses: azure/[email protected]
id: install

- name: Install StorageClass
run: |
kubectl apply -f ./script/local-storageclass.yaml
kubectl -n local-path-storage get storageclass
- name: Run Clippy
run: |
rustup show
cargo clippy --workspace --exclude jiaozifs_client_rs
- name: Build image
run: |
make minikube-docker
- name: Run tests
run: cargo test --verbose --workspace




161 changes: 161 additions & 0 deletions script/local-storageclass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
apiVersion: v1
kind: Namespace
metadata:
name: local-path-storage

---
apiVersion: v1
kind: ServiceAccount
metadata:
name: local-path-provisioner-service-account
namespace: local-path-storage

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: local-path-provisioner-role
namespace: local-path-storage
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch", "create", "patch", "update", "delete"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: local-path-provisioner-role
rules:
- apiGroups: [""]
resources: ["nodes", "persistentvolumeclaims", "configmaps", "pods", "pods/log"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "patch", "update", "delete"]
- apiGroups: [""]
resources: ["events"]
verbs: ["create", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: local-path-provisioner-bind
namespace: local-path-storage
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: local-path-provisioner-role
subjects:
- kind: ServiceAccount
name: local-path-provisioner-service-account
namespace: local-path-storage

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: local-path-provisioner-bind
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: local-path-provisioner-role
subjects:
- kind: ServiceAccount
name: local-path-provisioner-service-account
namespace: local-path-storage

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: local-path-provisioner
namespace: local-path-storage
spec:
replicas: 1
selector:
matchLabels:
app: local-path-provisioner
template:
metadata:
labels:
app: local-path-provisioner
spec:
serviceAccountName: local-path-provisioner-service-account
containers:
- name: local-path-provisioner
image: rancher/local-path-provisioner:v0.0.28
imagePullPolicy: IfNotPresent
command:
- local-path-provisioner
- --debug
- start
- --config
- /etc/config/config.json
volumeMounts:
- name: config-volume
mountPath: /etc/config/
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: CONFIG_MOUNT_PATH
value: /etc/config/
volumes:
- name: config-volume
configMap:
name: local-path-config

---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: jz-action-fs
provisioner: rancher.io/local-path
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete

---
kind: ConfigMap
apiVersion: v1
metadata:
name: local-path-config
namespace: local-path-storage
data:
config.json: |-
{
"nodePathMap":[
{
"node":"DEFAULT_PATH_FOR_NON_LISTED_NODES",
"paths":["/opt/local-path-provisioner"]
}
]
}
setup: |-
#!/bin/sh
set -eu
mkdir -m 0777 -p "$VOL_DIR"
teardown: |-
#!/bin/sh
set -eu
rm -rf "$VOL_DIR"
helperPod.yaml: |-
apiVersion: v1
kind: Pod
metadata:
name: helper-pod
spec:
priorityClassName: system-node-critical
tolerations:
- key: node.kubernetes.io/disk-pressure
operator: Exists
effect: NoSchedule
containers:
- name: helper-pod
image: busybox
imagePullPolicy: IfNotPresent
10 changes: 1 addition & 9 deletions src/bin/jz-flow/job.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
use std::{
io::{
self,
stdout,
},
iter,
os::linux::raw::stat,
str::FromStr,
};
use std::str::FromStr;

use crate::global::GlobalOptions;
use anyhow::Result;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/jz-flow/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::global::GlobalOptions;
pub(super) struct RunArgs {
#[arg(
long,
default_value = "mongodb://192.168.3.163:27017",
default_value = "mongodb://127.0.0.1:27017",
help = "mongo connection string"
)]
mongo_url: String,
Expand Down
3 changes: 1 addition & 2 deletions src/dbrepo/job_db_mongo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::os::linux::raw::stat;

use crate::{
core::db::{
Expand Down Expand Up @@ -259,7 +258,7 @@ impl DataRepo for MongoRunDbRepo {
direction: Option<&Direction>,
) -> Result<usize> {
let mut query = doc! {"node_name":node_name};
if states.len() > 0 {
if !states.is_empty() {
let states: Vec<&str> = states.iter().map(to_variant_name).try_collect()?;
query.insert("state", doc! {"$in": states});
}
Expand Down
20 changes: 7 additions & 13 deletions src/driver/kube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,16 @@ use handlebars::{
RenderContext,
RenderError,
};
use k8s_metrics::{
v1beta1 as metricsv1,
QuantityExt,
};
use k8s_openapi::{
api::{
use k8s_metrics::v1beta1 as metricsv1;
use k8s_openapi::api::{
apps::v1::StatefulSet,
core::v1::{
Namespace,
PersistentVolumeClaim,
Pod,
Service,
},
},
apimachinery::pkg::api::resource::Quantity,
};
};
use kube::{
api::{
DeleteParams,
Expand Down Expand Up @@ -145,7 +139,7 @@ where
let mut node_status = NodeStatus {
name: self.node_name.clone(),
state: db_node.state,
data_count: data_count,
data_count,
replicas: statefulset
.spec
.as_ref()
Expand Down Expand Up @@ -280,7 +274,7 @@ where
let mut node_status = NodeStatus {
name: self.node_name.clone(),
state: db_node.state,
data_count: data_count,
data_count,
replicas: statefulset
.spec
.as_ref()
Expand Down Expand Up @@ -373,7 +367,7 @@ where
fn new(repo: R, client: Client,topo_sort_nodes: Vec<String>) -> Self {
Self {
_db_repo: repo,
topo_sort_nodes:topo_sort_nodes,
topo_sort_nodes,
_client: client,
handlers: Default::default(),
}
Expand Down Expand Up @@ -918,7 +912,7 @@ mod tests {
"#;
let dag = Dag::from_json(json_str).unwrap();

let db_url = "mongodb://192.168.3.163:27017";
let db_url = "mongodb://127.0.0.1:27017";
let client = MongoClient::with_uri_str(db_url.to_string() + "/ntest")
.await
.unwrap();
Expand Down
10 changes: 3 additions & 7 deletions src/job/job_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@ use crate::{
};
use anyhow::Result;
use futures::future::try_join_all;
use k8s_openapi::api::node;
use kube::Client;
use mongodb::bson::oid::ObjectId;
use serde::{
Deserialize,
Serialize,
};
use std::{
collections::HashMap,
marker::PhantomData,
};
use std::marker::PhantomData;
use tokio::task::JoinSet;
use tokio_util::sync::CancellationToken;
use tracing::{
Expand Down Expand Up @@ -177,7 +173,7 @@ where
let namespace = format!("{}-{}", job.name, job.retry_number - 1);
self.db
.update(
&id,
id,
&JobUpdateInfo {
state: Some(JobState::Finish),
},
Expand All @@ -186,7 +182,7 @@ where
self.driver.clean(&namespace).await?;
self.db
.update(
&id,
id,
&JobUpdateInfo {
state: Some(JobState::Clean),
},
Expand Down

0 comments on commit bff8398

Please sign in to comment.