Skip to content

Commit

Permalink
Merge pull request #42 from foriequal0/fix/report-level
Browse files Browse the repository at this point in the history
  • Loading branch information
foriequal0 authored Aug 12, 2024
2 parents 71060cf + fd6af4c commit 6daf574
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "pod-graceful-drain"
description = "You don't need `lifecycle: { preStop: { exec: { command: [\"sleep\", \"30\"] } } }`"
authors = ["SeongChan Lee <[email protected]>"]
version = "0.1.0-rc.2"
version = "0.1.0-rc.3"
edition = "2021"
rust-version = "1.79"

Expand Down
4 changes: 2 additions & 2 deletions charts/pod-graceful-drain/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name: pod-graceful-drain
description: |
You don't need `lifecycle: { preStop: { exec: { command: ["sleep", "30"] } } }`
type: application
version: 0.1.0-rc.2
appVersion: "v0.1.0-rc.2"
version: 0.1.0-rc.3
appVersion: "v0.1.0-rc.3"
11 changes: 5 additions & 6 deletions src/webhooks/report.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use k8s_openapi::api::core::v1::{ObjectReference, Pod};
use kube::runtime::events::{Event, EventType, Recorder};
use kube::Resource;
use tracing::{debug, enabled, info, Level};
use tracing::{debug, event_enabled, info, warn, Level};

use crate::webhooks::AppState;

async fn report(
state: &AppState,
reference: ObjectReference,
Expand Down Expand Up @@ -52,7 +51,7 @@ pub async fn debug_report_for_ref(
reason: &str,
note: String,
) {
if !enabled!(Level::DEBUG) {
if !event_enabled!(Level::DEBUG) {
return;
}

Expand All @@ -77,16 +76,16 @@ pub async fn warn_report_for_ref(
reason: &str,
note: String,
) {
if !enabled!(Level::WARN) {
if !event_enabled!(Level::WARN) {
return;
}

info!(action, reason, note);
warn!(action, reason, note);
report(state, object_ref, EventType::Warning, action, reason, note).await;
}

pub async fn report_for(state: &AppState, pod: &Pod, action: &str, reason: &str, note: String) {
if !enabled!(Level::INFO) {
if !event_enabled!(Level::INFO) {
return;
}

Expand Down

0 comments on commit 6daf574

Please sign in to comment.