Skip to content
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<div align="center">

[![Docker Pulls](https://img.shields.io/docker/pulls/parseable/parseable?logo=docker&label=Docker%20Pulls)](https://hub.docker.com/r/parseable/parseable)
[![Slack](https://img.shields.io/badge/slack-brightgreen.svg?logo=slack&label=Community&style=flat&color=%2373DC8C&)](https://launchpass.com/parseable)
[![Docs](https://img.shields.io/badge/stable%20docs-parseable.io%2Fdocs-brightgreen?style=flat&color=%2373DC8C&label=Docs)](https://www.parseable.io/docs)
[![Slack](https://img.shields.io/badge/slack-brightgreen.svg?logo=slack&label=Community&style=flat&color=%2373DC8C&)](https://logg.ing/community)
[![Docs](https://img.shields.io/badge/stable%20docs-parseable.io%2Fdocs-brightgreen?style=flat&color=%2373DC8C&label=Docs)](https://logg.ing/docs)
[![Build](https://img.shields.io/github/checks-status/parseablehq/parseable/main?style=flat&color=%2373DC8C&label=Checks)](https://github.com/parseablehq/parseable/actions)

[Key Concepts](https://www.parseable.io/docs/concepts) | [Features](https://github.com/parseablehq/parseable#rocket-highlights) | [Documentation](https://www.parseable.io/docs) | [Demo](https://demo.parseable.com/login?q=eyJ1c2VybmFtZSI6ImFkbWluIiwicGFzc3dvcmQiOiJhZG1pbiJ9) | [Integrations](https://www.parseable.io/docs/category/integrations) | [FAQ](https://www.parseable.io/docs/faq)
Expand Down
2 changes: 1 addition & 1 deletion server/src/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub fn print_about(
eprintln!(
"
Commit: \"{commit_hash}\"
Docs: \"https://www.parseable.io/docs\""
Docs: \"https://logg.ing/docs\""
);
}

Expand Down
34 changes: 15 additions & 19 deletions server/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use crate::oidc::{self, OpenidConfig};
use crate::storage::{FSConfig, ObjectStorageError, ObjectStorageProvider, S3Config};

pub const MIN_CACHE_SIZE_BYTES: u64 = 1000u64.pow(3); // 1 GiB

pub const JOIN_COMMUNITY: &str =
"Join us on Parseable Slack community for questions : https://logg.ing/community";
pub static CONFIG: Lazy<Arc<Config>> = Lazy::new(|| Arc::new(Config::new()));

#[derive(Debug)]
Expand Down Expand Up @@ -104,30 +105,25 @@ impl Config {

let has_parseable_json = obj_store.get_object(&rel_path).await.is_ok();

let has_dirs = match obj_store.list_dirs_in_storage().await {
// Lists all the directories in the root of the bucket/directory
// can be a stream (if it contains .stream.json file) or not
let has_dirs = match obj_store.list_dirs().await {
Ok(dirs) => !dirs.is_empty(),
Err(_) => false,
};

let has_streams = obj_store.list_streams().await.is_ok();

if !has_dirs || has_parseable_json && has_streams {
Ok(())
} else if has_parseable_json && !has_streams {
Err(ObjectStorageError::Custom(
"Could not start the server because storage contains stale data from previous deployment, please choose an empty storage and restart the server.\nJoin us on Parseable Slack to report this incident : launchpass.com/parseable"
.to_owned(),
))
} else if !has_parseable_json && !has_streams && has_dirs {
Err(ObjectStorageError::Custom(
"Could not start the server because storage contains some stale data, please provide an empty storage and restart the server.\nJoin us on Parseable Slack to report this incident : launchpass.com/parseable".to_owned(),
))
} else {
Err(ObjectStorageError::Custom(
"Could not start the server because storage contains stale data from previous deployment.\nJoin us on Parseable Slack to report this incident : launchpass.com/parseable"
.to_owned()
))
if has_streams || !has_dirs && !has_parseable_json {
return Ok(());
}

if self.mode_string() == "Local drive" {
return Err(ObjectStorageError::Custom(format!("Could not start the server because directory '{}' contains stale data, please use an empty directory, and restart the server.\n{}", self.storage.get_endpoint(), JOIN_COMMUNITY)));
}

// S3 bucket mode
Err(ObjectStorageError::Custom(format!("Could not start the server because bucket '{}' contains stale data, please use an empty bucket and restart the server.\n{}", self.storage.get_endpoint(), JOIN_COMMUNITY)))
}

pub fn storage(&self) -> Arc<dyn ObjectStorageProvider + Send + Sync> {
Expand Down Expand Up @@ -185,7 +181,7 @@ fn parseable_cli_command() -> Command {
.next_line_help(false)
.help_template(
r#"
{about} Join the community at https://launchpass.com/parseable.
{about} Join the community at https://logg.ing/community.

{all-args}
"#,
Expand Down
2 changes: 1 addition & 1 deletion server/src/storage/localfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl ObjectStorage for LocalFS {
Ok(logstreams)
}

async fn list_dirs_in_storage(&self) -> Result<Vec<String>, ObjectStorageError> {
async fn list_dirs(&self) -> Result<Vec<String>, ObjectStorageError> {
let dirs = ReadDirStream::new(fs::read_dir(&self.root).await?)
.try_collect::<Vec<DirEntry>>()
.await?
Expand Down
2 changes: 1 addition & 1 deletion server/src/storage/object_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub trait ObjectStorage: Sync + 'static {
async fn check(&self) -> Result<(), ObjectStorageError>;
async fn delete_stream(&self, stream_name: &str) -> Result<(), ObjectStorageError>;
async fn list_streams(&self) -> Result<Vec<LogStream>, ObjectStorageError>;
async fn list_dirs_in_storage(&self) -> Result<Vec<String>, ObjectStorageError>;
async fn list_dirs(&self) -> Result<Vec<String>, ObjectStorageError>;
async fn list_dates(&self, stream_name: &str) -> Result<Vec<String>, ObjectStorageError>;
async fn upload_file(&self, key: &str, path: &Path) -> Result<(), ObjectStorageError>;

Expand Down
2 changes: 1 addition & 1 deletion server/src/storage/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ impl ObjectStorage for S3 {
url::Url::parse(&format!("s3://{}", self.bucket)).unwrap()
}

async fn list_dirs_in_storage(&self) -> Result<Vec<String>, ObjectStorageError> {
async fn list_dirs(&self) -> Result<Vec<String>, ObjectStorageError> {
let pre = object_store::path::Path::from("/");
let resp = self.client.list_with_delimiter(Some(&pre)).await?;

Expand Down
8 changes: 2 additions & 6 deletions server/src/storage/store_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use once_cell::sync::OnceCell;
use std::io;

use crate::{
option::CONFIG,
option::{CONFIG, JOIN_COMMUNITY},
rbac::{role::model::DefaultPrivilege, user::User},
storage::ObjectStorageError,
utils::uid,
Expand Down Expand Up @@ -145,11 +145,7 @@ pub async fn resolve_parseable_metadata() -> Result<StorageMetadata, ObjectStora
};

let metadata = res.map_err(|err| {
let err = format!(
"{}. {}",
err,
"Join us on Parseable Slack to report this incident : https://launchpass.com/parseable"
);
let err = format!("{}. {}", err, JOIN_COMMUNITY);
let err: Box<dyn std::error::Error + Send + Sync + 'static> = err.into();
ObjectStorageError::UnhandledError(err)
})?;
Expand Down