Skip to content
Open
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
7 changes: 7 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file.

### Added

- Add `CustomResourceDefinitionMaintainer` which applies and patches CRDs triggered by TLS
certificate rotations of the `ConversionWebhookServer`. It additionally provides a `oneshot`
channel which can for example be used to trigger creation/patching of any custom resources deployed by
the operator ([#1099]).
- Add a `Client::create_if_missing` associated function to create a resource if it doesn't
exist ([#1099]).
- Add CLI argument and env var to disable the end-of-support checker: `EOS_DISABLED` (`--eos-disabled`) ([#1101]).
- Add end-of-support checker ([#1096]).
- The EoS checker can be constructed using `EndOfSupportChecker::new()`.
Expand All @@ -28,6 +34,7 @@ All notable changes to this project will be documented in this file.

[#1096]: https://github.com/stackabletech/operator-rs/pull/1096
[#1098]: https://github.com/stackabletech/operator-rs/pull/1098
[#1099]: https://github.com/stackabletech/operator-rs/pull/1099
[#1101]: https://github.com/stackabletech/operator-rs/pull/1101
[#1103]: https://github.com/stackabletech/operator-rs/pull/1103

Expand Down
2 changes: 1 addition & 1 deletion crates/stackable-operator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ stackable-operator-derive = { path = "../stackable-operator-derive" }
stackable-shared = { path = "../stackable-shared", features = ["chrono", "time"] }
stackable-telemetry = { path = "../stackable-telemetry", optional = true, features = ["clap"] }
stackable-versioned = { path = "../stackable-versioned", optional = true }
stackable-webhook = { path = "../stackable-webhook", optional = true }
stackable-webhook = { path = "../stackable-webhook", optional = true}

chrono.workspace = true
clap.workspace = true
Expand Down
19 changes: 19 additions & 0 deletions crates/stackable-operator/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,25 @@ impl Client {
})
}

/// Optionally creates a resource if it does not exist yet.
///
/// The name used for lookup is extracted from the resource via [`ResourceExt::name_any()`].
/// This function either returns the existing resource or the newly created one.
pub async fn create_if_missing<T>(&self, resource: &T) -> Result<T>
where
T: Clone + Debug + DeserializeOwned + Resource + Serialize + GetApi,
<T as Resource>::DynamicType: Default,
{
if let Some(r) = self
.get_opt(&resource.name_any(), resource.get_namespace())
.await?
{
return Ok(r);
}

self.create(resource).await
}

/// Patches a resource using the `MERGE` patch strategy described
/// in [JSON Merge Patch](https://tools.ietf.org/html/rfc7386)
/// This will fail for objects that do not exist yet.
Expand Down
15 changes: 15 additions & 0 deletions crates/stackable-webhook/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Changed

- BREAKING: The `ConversionWebhookServer` now returns a pair of values ([#1099]):
- The conversion webhook server itself
- A `mpsc::Receiver<Certificate>` to provide consumers the newly generated TLS certificate
- BREAKING: Constants for ports, IP addresses and socket addresses are now associated constants on
`(Conversion)WebhookServer` instead of free-standing ones ([#1099]).

### Removed

- BREAKING: The `maintain_crds` and `field_manager` fields in `ConversionWebhookOptions`
are removed ([#1099]).

[#1099]: https://github.com/stackabletech/operator-rs/pull/1099

## [0.6.0] - 2025-09-09

### Added
Expand Down
21 changes: 0 additions & 21 deletions crates/stackable-webhook/src/constants.rs

This file was deleted.

25 changes: 19 additions & 6 deletions crates/stackable-webhook/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
//! enable complete control over these details if needed.
//!
//! [1]: crate::servers::ConversionWebhookServer
use std::net::{IpAddr, Ipv4Addr, SocketAddr};

use ::x509_cert::Certificate;
use axum::{Router, routing::get};
use futures_util::{FutureExt as _, pin_mut, select};
use snafu::{ResultExt, Snafu};
Expand All @@ -35,19 +38,16 @@ use tokio::{
sync::mpsc,
};
use tower::ServiceBuilder;
use x509_cert::Certificate;

// use tower_http::trace::TraceLayer;
// Selected re-exports
pub use crate::options::WebhookOptions;
use crate::tls::TlsServer;

pub mod constants;
pub mod maintainer;
pub mod options;
pub mod servers;
pub mod tls;

// Selected re-exports
pub use crate::options::WebhookOptions;

/// A generic webhook handler receiving a request and sending back a response.
///
/// This trait is not intended to be implemented by external crates and this
Expand Down Expand Up @@ -86,6 +86,19 @@ pub struct WebhookServer {
}

impl WebhookServer {
/// The default HTTPS port `8443`
pub const DEFAULT_HTTPS_PORT: u16 = 8443;
/// The default IP address [`Ipv4Addr::UNSPECIFIED`] (`0.0.0.0`) the webhook server binds to,
/// which represents binding on all network addresses.
//
// TODO: We might want to switch to `Ipv6Addr::UNSPECIFIED)` here, as this *normally* binds to IPv4
// and IPv6. However, it's complicated and depends on the underlying system...
// If we do so, we should set `set_only_v6(false)` on the socket to not rely on system defaults.
pub const DEFAULT_LISTEN_ADDRESS: IpAddr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
/// The default socket address `0.0.0.0:8443` the webhook server binds to.
pub const DEFAULT_SOCKET_ADDRESS: SocketAddr =
SocketAddr::new(Self::DEFAULT_LISTEN_ADDRESS, Self::DEFAULT_HTTPS_PORT);

/// Creates a new ready-to-use webhook server.
///
/// The server listens on `socket_addr` which is provided via the [`WebhookOptions`] and handles
Expand Down
Loading