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

[Merged by Bors] - increase size limit of log volumes #460

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ All notable changes to this project will be documented in this file.

### Changed

- Operator-rs: `0.40.1` -> `0.41.0` ([#440]).
- Operator-rs: `0.40.1` -> `0.44.0` ([#440], [#460]).
- Use 0.0.0-dev product images for testing ([#441]).
- Use testing-tools 0.2.0 ([#441]).
- Added kuttl test suites ([#455]).
Expand All @@ -23,6 +23,7 @@ All notable changes to this project will be documented in this file.
### Fixed

- Migrate "opa-bundle-builder" container name from <= 23.1 releases ([#445]).
- Increase the size limit of the log volume ([#460]).

[#440]: https://github.com/stackabletech/opa-operator/pull/440
[#441]: https://github.com/stackabletech/opa-operator/pull/441
Expand All @@ -34,6 +35,7 @@ All notable changes to this project will be documented in this file.
[#455]: https://github.com/stackabletech/opa-operator/pull/455
[#456]: https://github.com/stackabletech/opa-operator/pull/456
[#458]: https://github.com/stackabletech/opa-operator/pull/458
[#460]: https://github.com/stackabletech/opa-operator/pull/460

## [23.4.0] - 2023-04-17

Expand Down
8 changes: 4 additions & 4 deletions 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 rust/crd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version = "0.0.0-dev"
publish = false

[dependencies]
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.42.2" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.44.0" }

semver = "1.0"
serde = { version = "1.0", features = ["derive"] }
Expand Down
4 changes: 2 additions & 2 deletions rust/operator-binary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version = "0.0.0-dev"
publish = false

[dependencies]
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.42.2" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.44.0" }
stackable-opa-crd = { path = "../crd" }

clap = "4.1"
Expand All @@ -27,5 +27,5 @@ pin-project = "1.0"

[build-dependencies]
built = { version = "0.5", features = ["chrono", "git2"] }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.42.2" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.44.0" }
stackable-opa-crd = { path = "../crd" }
59 changes: 37 additions & 22 deletions rust/operator-binary/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use snafu::{OptionExt, ResultExt, Snafu};
use stackable_opa_crd::{
Container, OpaCluster, OpaClusterStatus, OpaConfig, OpaRole, APP_NAME, OPERATOR_NAME,
};
use stackable_operator::k8s_openapi::api::core::v1::EmptyDirVolumeSource;
use stackable_operator::k8s_openapi::DeepMerge;
use stackable_operator::memory::{BinaryMultiple, MemoryQuantity};
use stackable_operator::{
builder::{
resources::ResourceRequirementsBuilder, ConfigMapBuilder, ContainerBuilder,
Expand All @@ -26,9 +28,7 @@ use stackable_operator::{
ConfigMap, EnvVar, HTTPGetAction, Probe, Service, ServicePort, ServiceSpec,
},
},
apimachinery::pkg::{
api::resource::Quantity, apis::meta::v1::LabelSelector, util::intstr::IntOrString,
},
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
},
kube::{
runtime::{controller::Action, reflector::ObjectRef},
Expand Down Expand Up @@ -79,20 +79,29 @@ const BUNDLES_DIR: &str = "/bundles";

const DOCKER_IMAGE_BASE_NAME: &str = "opa";

// ~ 5 MB
const MAX_OPA_BUNDLE_BUILDER_LOG_FILE_SIZE_IN_BYTES: u32 = 5000000;
// ~ 5 MB x 2
// these sizes are needed both for the single file (for multilog) as well as the total (for the EmptyDir)
const OPA_ROLLING_BUNDLE_BUILDER_LOG_FILE_SIZE_MB: u32 = 5;
const OPA_ROLLING_BUNDLE_BUILDER_LOG_FILES: u32 = 2;
// ~ 5 MB
const MAX_OPA_LOG_FILE_SIZE_IN_BYTES: u32 = 5000000;
const MAX_OPA_BUNDLE_BUILDER_LOG_FILE_SIZE: MemoryQuantity = MemoryQuantity {
value: (OPA_ROLLING_BUNDLE_BUILDER_LOG_FILE_SIZE_MB * OPA_ROLLING_BUNDLE_BUILDER_LOG_FILES)
as f32,
unit: BinaryMultiple::Mebi,
};
// ~ 5 MB x 2
// these sizes are needed both for the single file (for multilog) as well as the total (for the EmptyDir)
const OPA_ROLLING_LOG_FILE_SIZE_MB: u32 = 5;
const OPA_ROLLING_LOG_FILES: u32 = 2;
// ~ 1 MB
const MAX_PREPARE_LOG_FILE_SIZE_IN_BYTES: u32 = 1000000;
const MAX_OPA_LOG_FILE_SIZE: MemoryQuantity = MemoryQuantity {
value: (OPA_ROLLING_LOG_FILE_SIZE_MB * OPA_ROLLING_LOG_FILES) as f32,
unit: BinaryMultiple::Mebi,
};

const LOG_FILE_VOLUME_SIZE_IN_MB: u32 = ((MAX_OPA_BUNDLE_BUILDER_LOG_FILE_SIZE_IN_BYTES
* OPA_ROLLING_BUNDLE_BUILDER_LOG_FILES)
+ (MAX_OPA_LOG_FILE_SIZE_IN_BYTES * OPA_ROLLING_LOG_FILES)
+ MAX_PREPARE_LOG_FILE_SIZE_IN_BYTES)
/ 1000000;
// ~ 1 MB
const MAX_PREPARE_LOG_FILE_SIZE: MemoryQuantity = MemoryQuantity {
value: 1.0,
unit: BinaryMultiple::Mebi,
};

pub struct Ctx {
pub client: stackable_operator::client::Client,
Expand Down Expand Up @@ -678,10 +687,16 @@ fn build_server_rolegroup_daemonset(
)
.add_volume(
VolumeBuilder::new(LOG_VOLUME_NAME)
.with_empty_dir(
None::<String>,
Some(Quantity(format!("{LOG_FILE_VOLUME_SIZE_IN_MB}Mi"))),
)
.empty_dir(EmptyDirVolumeSource {
medium: None,
size_limit: Some(product_logging::framework::calculate_log_volume_size_limit(
&[
MAX_OPA_BUNDLE_BUILDER_LOG_FILE_SIZE,
MAX_OPA_LOG_FILE_SIZE,
MAX_PREPARE_LOG_FILE_SIZE,
],
)),
})
.build(),
)
.service_account_name(sa_name)
Expand Down Expand Up @@ -799,9 +814,9 @@ fn build_opa_start_command(merged_config: &OpaConfig, container_name: &str) -> S
let mut start_command = format!("/stackable/opa/opa run -s -a 0.0.0.0:{APP_PORT} -c {CONFIG_DIR}/config.yaml -l {opa_log_level}");

if console_logging_off {
start_command.push_str(&format!(" |& /stackable/multilog s{MAX_OPA_LOG_FILE_SIZE_IN_BYTES} n{OPA_ROLLING_LOG_FILES} {LOG_DIR}/{container_name}"));
start_command.push_str(&format!(" |& /stackable/multilog s{OPA_ROLLING_LOG_FILE_SIZE_MB} n{OPA_ROLLING_LOG_FILES} {LOG_DIR}/{container_name}"));
} else {
start_command.push_str(&format!(" |& tee >(/stackable/multilog s{MAX_OPA_LOG_FILE_SIZE_IN_BYTES} n{OPA_ROLLING_LOG_FILES} {LOG_DIR}/{container_name})"));
start_command.push_str(&format!(" |& tee >(/stackable/multilog s{OPA_ROLLING_LOG_FILE_SIZE_MB} n{OPA_ROLLING_LOG_FILES} {LOG_DIR}/{container_name})"));
}

start_command
Expand Down Expand Up @@ -830,9 +845,9 @@ fn build_bundle_builder_start_command(merged_config: &OpaConfig, container_name:
let mut start_command = "/stackable/opa-bundle-builder".to_string();

if console_logging_off {
start_command.push_str(&format!(" |& /stackable/multilog s{MAX_OPA_BUNDLE_BUILDER_LOG_FILE_SIZE_IN_BYTES} n{OPA_ROLLING_BUNDLE_BUILDER_LOG_FILES} {LOG_DIR}/{container_name}"))
start_command.push_str(&format!(" |& /stackable/multilog s{OPA_ROLLING_BUNDLE_BUILDER_LOG_FILE_SIZE_MB} n{OPA_ROLLING_BUNDLE_BUILDER_LOG_FILES} {LOG_DIR}/{container_name}"))
} else {
start_command.push_str(&format!(" |& tee >(/stackable/multilog s{MAX_OPA_BUNDLE_BUILDER_LOG_FILE_SIZE_IN_BYTES} n{OPA_ROLLING_BUNDLE_BUILDER_LOG_FILES} {LOG_DIR}/{container_name})"));
start_command.push_str(&format!(" |& tee >(/stackable/multilog s{OPA_ROLLING_BUNDLE_BUILDER_LOG_FILE_SIZE_MB} n{OPA_ROLLING_BUNDLE_BUILDER_LOG_FILES} {LOG_DIR}/{container_name})"));
siegfriedweber marked this conversation as resolved.
Show resolved Hide resolved
}

start_command
Expand Down