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

feat: add risectl scale check command for sql in version 2.0.x #19761

Merged
merged 7 commits into from
Dec 20, 2024
2 changes: 2 additions & 0 deletions src/ctl/src/cmd_impl/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

mod backup_meta;
mod check;
mod cluster_info;
mod connection;
mod migration;
Expand All @@ -21,6 +22,7 @@ mod reschedule;
mod serving;

pub use backup_meta::*;
pub use check::*;
pub use cluster_info::*;
pub use connection::*;
pub use migration::*;
Expand Down
33 changes: 33 additions & 0 deletions src/ctl/src/cmd_impl/meta/check.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2024 RisingWave Labs
//
// Licensed 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 std::process::exit;

use risingwave_meta::controller::catalog::CatalogController;
use sea_orm::TransactionTrait;

pub async fn graph_check(endpoint: String) -> anyhow::Result<()> {
let conn = sea_orm::Database::connect(sea_orm::ConnectOptions::new(endpoint)).await?;
let txn = conn.begin().await?;
match CatalogController::graph_check(&txn).await {
Ok(_) => {
println!("integrity check passed!");
exit(0);
}
Err(_) => {
println!("integrity check failed!");
exit(1);
}
}
}
12 changes: 12 additions & 0 deletions src/ctl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,14 @@ enum MetaCommands {
#[clap(short = 'f', long, default_value_t = false)]
force_clean: bool,
},

/// Performing graph check for scaling.
#[clap(verbatim_doc_comment)]
GraphCheck {
/// SQL endpoint
#[clap(long, required = true)]
endpoint: String,
},
}

#[derive(Subcommand, Clone, Debug)]
Expand Down Expand Up @@ -850,6 +858,9 @@ async fn start_impl(opts: CliOpts, context: &CtlContext) -> Result<()> {
Commands::Meta(MetaCommands::ValidateSource { props }) => {
cmd_impl::meta::validate_source(context, props).await?
}
Commands::Meta(MetaCommands::GraphCheck { endpoint }) => {
cmd_impl::meta::graph_check(endpoint).await?
}
Commands::Meta(MetaCommands::Migration {
etcd_endpoints,
etcd_user_password,
Expand Down Expand Up @@ -881,6 +892,7 @@ async fn start_impl(opts: CliOpts, context: &CtlContext) -> Result<()> {
Commands::Profile(ProfileCommands::Heap { dir }) => {
cmd_impl::profile::heap_profile(context, dir).await?
}

Commands::Scale(ScaleCommands::Cordon { workers }) => {
cmd_impl::scale::update_schedulability(context, workers, Schedulability::Unschedulable)
.await?
Expand Down
Loading
Loading