Skip to content

Commit

Permalink
Add a requeue channel (#8)
Browse files Browse the repository at this point in the history
As a controller processes events, it may not be able to act successfully
on these events: there may be a transient problem when writing to the
API server, or the system may not be in a converged state and it may be
necessary to reprocess the update at a later time.

The `requeue` channel provides a bounded, multi-producer/single-
consumer, delay-queue channel. Applications can use this channel to
reschedule updates for a later time. While this is especially useful for
controllers, this channel is not inherently tied to Kubernetes in any
way.
  • Loading branch information
olix0r committed Feb 21, 2022
1 parent 89d0c94 commit af8afe5
Show file tree
Hide file tree
Showing 6 changed files with 400 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lints.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: lints
name: lint

on:
pull_request:
paths:
- '**/*.rs'
- .github/workflows/lints.yml
- .github/workflows/lint.yml

permissions:
contents: read
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: test

on:
pull_request:
paths:
- Cargo.lock
- '**/*.rs'
- .github/workflows/test.yml

permissions:
contents: read

env:
CARGO_ACTION_FMT_VERSION: v0.1.3
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUST_BACKTRACE: short
RUSTUP_MAX_RETRIES: 10

jobs:
test:
timeout-minutes: 10
runs-on: ubuntu-latest
container:
image: docker://rust:1.58.1
steps:
- name: install cargo-action-fmt
run: |
curl --proto =https --tlsv1.3 -vsSfLo /usr/local/bin/cargo-action-fmt "https://github.com/olix0r/cargo-action-fmt/releases/download/release%2F${CARGO_ACTION_FMT_VERSION}/cargo-action-fmt-x86_64-unknown-linux-gnu"
chmod 755 /usr/local/bin/cargo-action-fmt
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- run: cargo fetch
- name: cargo test --no-run
run: cargo test --frozen --workspace --all-features --no-run --message-format=json | cargo-action-fmt
- name: cargo test
run: cargo test --frozen --workspace --all-features
2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ignore = [

[licenses]
unlicensed = "deny"
allow = ["Apache-2.0", "ISC", "MIT"]
allow = ["Apache-2.0", "BSD-3-Clause", "ISC", "MIT"]
deny = []
copyleft = "deny"
allow-osi-fsf-free = "neither"
Expand Down
21 changes: 21 additions & 0 deletions kubert/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ keywords = ["kubernetes", "client", "runtime", "server"]
client = ["kube-client", "thiserror"]
# TODO controller = ["client", "kube/runtime"]
log = ["thiserror", "tracing-subscriber"]
requeue = ["futures-core", "tokio/macros", "tokio/sync", "tokio-util/time"]
# TODO runtime = ["clap", "drain", "log", "tokio/signal"]
server = [
"drain",
Expand Down Expand Up @@ -44,10 +45,12 @@ features = [

[dependencies]
drain = { version = "0.1.0", optional = true, default-features = false }
futures-core = { version = "0.3", optional = true, default-features = false }
hyper = { version = "0.14.17", optional = true, default-features = false }
rustls-pemfile = { version = "0.3.0", optional = true }
thiserror = { version = "1.0.30", optional = true }
tokio = { version = "1.17.0", optional = false, default-features = false }
tokio-util = { version = "0.7", optional = true, default-features = false }
tokio-rustls = { version = "0.23.2", optional = true, default-features = false }
tower-service = { version = "0.3.1", optional = true }
tracing = "0.1.31"
Expand All @@ -64,6 +67,16 @@ optional = true
default-features = false
features = ["client", "config"]

[dependencies.kube-core]
version = "0.69.1"
optional = true
default-features = false

[dependencies.kube-runtime]
version = "0.69.1"
optional = true
default-features = false

[dependencies.tracing-subscriber]
version = "0.3.9"
optional = true
Expand All @@ -77,4 +90,12 @@ features = [
]

[dev-dependencies]
kube = { version = "0.69.1", default-features = false, features = ["runtime"] }
k8s-openapi = { version = "0.14.0", default-features = false, features = ["v1_23"] }
tracing-subscriber = { version = "0.3", features = ["ansi"] }
tokio-test = "0.4"

[dev-dependencies.tokio]
version = "1.17"
default-features = false
features = ["macros", "test-util"]
4 changes: 4 additions & 0 deletions kubert/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ pub mod log;
#[cfg_attr(docsrs, doc(cfg(any(feature = "shutdown"))))]
pub mod shutdown;

#[cfg(feature = "requeue")]
#[cfg_attr(docsrs, doc(cfg(any(feature = "requeue"))))]
pub mod requeue;

#[cfg(feature = "server")]
#[cfg_attr(docsrs, doc(cfg(any(feature = "shutdown"))))]
pub mod server;
Loading

0 comments on commit af8afe5

Please sign in to comment.