Skip to content

Commit 2916830

Browse files
committed
Merge remote-tracking branch 'origin/main' into op-rs-0.79.0
2 parents e418a2c + ca6e4da commit 2916830

File tree

8 files changed

+61
-39
lines changed

8 files changed

+61
-39
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525
CARGO_TERM_COLOR: always
2626
CARGO_INCREMENTAL: '0'
2727
CARGO_PROFILE_DEV_DEBUG: '0'
28-
RUST_TOOLCHAIN_VERSION: "1.80.1"
28+
RUST_TOOLCHAIN_VERSION: "1.81.0"
2929
RUSTFLAGS: "-D warnings"
3030
RUSTDOCFLAGS: "-D warnings"
3131
RUST_LOG: "info"

.github/workflows/pr_pre-commit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
env:
88
CARGO_TERM_COLOR: always
9-
RUST_TOOLCHAIN_VERSION: "1.80.1"
9+
RUST_TOOLCHAIN_VERSION: "1.81.0"
1010
HADOLINT_VERSION: "v2.12.0"
1111
PYTHON_VERSION: "3.12"
1212

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ default_language_version:
66

77
repos:
88
- repo: https://github.com/pre-commit/pre-commit-hooks
9-
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # 4.6.0
9+
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # 5.0.0
1010
hooks:
1111
- id: trailing-whitespace
1212
- id: end-of-file-fixer
@@ -28,7 +28,7 @@ repos:
2828
- id: yamllint
2929

3030
- repo: https://github.com/igorshubovych/markdownlint-cli
31-
rev: f295829140d25717bc79368d3f966fc1f67a824f # 0.41.0
31+
rev: aa975a18c9a869648007d33864034dbc7481fe5e # 0.42.0
3232
hooks:
3333
- id: markdownlint
3434
types: [text]
@@ -44,15 +44,15 @@ repos:
4444
# If you do not, you will need to delete the cached ruff binary shown in the
4545
# error message
4646
- repo: https://github.com/astral-sh/ruff-pre-commit
47-
rev: f1ebc5730d98440041cc43e4d69829ad598ae1e7 # 0.6.3
47+
rev: 8983acb92ee4b01924893632cf90af926fa608f0 # 0.7.0
4848
hooks:
4949
# Run the linter.
5050
- id: ruff
5151
# Run the formatter.
5252
- id: ruff-format
5353

5454
- repo: https://github.com/rhysd/actionlint
55-
rev: 62dc61a45fc95efe8c800af7a557ab0b9165d63b # 1.7.1
55+
rev: 4e683ab8014a63fafa117492a0c6053758e6d593 # 1.7.3
5656
hooks:
5757
- id: actionlint
5858

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file.
2222
### Fixed
2323

2424
- Bundle builder should no longer keep serving deleted rules until it is restarted ([#578]).
25+
- Failing to parse one `OpaCluster` should no longer cause the whole operator to stop functioning ([#638]).
2526

2627
### Removed
2728

@@ -32,6 +33,7 @@ All notable changes to this project will be documented in this file.
3233
[#616]: https://github.com/stackabletech/opa-operator/pull/616
3334
[#621]: https://github.com/stackabletech/opa-operator/pull/621
3435
[#637]: https://github.com/stackabletech/opa-operator/pull/637
36+
[#638]: https://github.com/stackabletech/opa-operator/pull/638
3537

3638
## [24.7.0] - 2024-07-24
3739

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ docker-publish:
4848
# Uses the keyless signing flow with Github Actions as identity provider\
4949
cosign sign -y "${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}@$$REPO_DIGEST_OF_IMAGE";\
5050
# Generate the SBOM for the operator image, this leverages the already generated SBOM for the operator binary by cargo-cyclonedx\
51-
syft scan --output cyclonedx-json=sbom.json --select-catalogers "-cargo-auditable-binary-cataloger" --scope all-layers --source-name "${OPERATOR_NAME}" --source-version "${VERSION}" "${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}@$$REPO_DIGEST_OF_IMAGE";\
51+
syft scan --output cyclonedx-json=sbom.json --select-catalogers "-cargo-auditable-binary-cataloger" --scope all-layers --source-name "${OPERATOR_NAME}" --source-version "${VERSION}-${ARCH}" "${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}@$$REPO_DIGEST_OF_IMAGE";\
5252
# Determine the PURL for the container image\
53-
PURL="pkg:docker/${ORGANIZATION}/${OPERATOR_NAME}@$$REPO_DIGEST_OF_IMAGE?repository_url=${DOCKER_REPO}";\
53+
URLENCODED_REPO_DIGEST_OF_IMAGE=$$(echo "$$REPO_DIGEST_OF_IMAGE" | sed 's/:/%3A/g');\
54+
PURL="pkg:oci/${OPERATOR_NAME}@$$URLENCODED_REPO_DIGEST_OF_IMAGE?arch=${ARCH}&repository_url=${DOCKER_REPO}%2F${ORGANIZATION}%2F${OPERATOR_NAME}";\
5455
# Get metadata from the image\
5556
IMAGE_DESCRIPTION=$$(docker inspect --format='{{.Config.Labels.description}}' "${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}:${VERSION}-${ARCH}");\
5657
IMAGE_NAME=$$(docker inspect --format='{{.Config.Labels.name}}' "${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}:${VERSION}-${ARCH}");\
@@ -73,9 +74,10 @@ docker-publish:
7374
# Uses the keyless signing flow with Github Actions as identity provider\
7475
cosign sign -y "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}@$$REPO_DIGEST_OF_IMAGE";\
7576
# Generate the SBOM for the operator image, this leverages the already generated SBOM for the operator binary by cargo-cyclonedx\
76-
syft scan --output cyclonedx-json=sbom.json --select-catalogers "-cargo-auditable-binary-cataloger" --scope all-layers --source-name "${OPERATOR_NAME}" --source-version "${VERSION}" "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}@$$REPO_DIGEST_OF_IMAGE";\
77+
syft scan --output cyclonedx-json=sbom.json --select-catalogers "-cargo-auditable-binary-cataloger" --scope all-layers --source-name "${OPERATOR_NAME}" --source-version "${VERSION}-${ARCH}" "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}@$$REPO_DIGEST_OF_IMAGE";\
7778
# Determine the PURL for the container image\
78-
PURL="pkg:docker/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}@$$REPO_DIGEST_OF_IMAGE?repository_url=${OCI_REGISTRY_HOSTNAME}";\
79+
URLENCODED_REPO_DIGEST_OF_IMAGE=$$(echo "$$REPO_DIGEST_OF_IMAGE" | sed 's/:/%3A/g');\
80+
PURL="pkg:oci/${OPERATOR_NAME}@$$URLENCODED_REPO_DIGEST_OF_IMAGE?arch=${ARCH}&repository_url=${OCI_REGISTRY_HOSTNAME}%2F${OCI_REGISTRY_PROJECT_IMAGES}%2F${OPERATOR_NAME}";\
7981
# Get metadata from the image\
8082
IMAGE_DESCRIPTION=$$(docker inspect --format='{{.Config.Labels.description}}' "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}-${ARCH}");\
8183
IMAGE_NAME=$$(docker inspect --format='{{.Config.Labels.name}}' "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}-${ARCH}");\

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# DO NOT EDIT, this file is generated by operator-templating
22
[toolchain]
3-
channel = "1.80.1"
3+
channel = "1.81.0"

rust/operator-binary/src/controller.rs

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ use stackable_operator::{
4343
DeepMerge,
4444
},
4545
kube::{
46+
core::{error_boundary, DeserializeGuard},
4647
runtime::{controller::Action, reflector::ObjectRef},
4748
Resource as KubeResource, ResourceExt,
4849
},
@@ -146,6 +147,11 @@ pub struct Ctx {
146147
#[strum_discriminants(derive(IntoStaticStr))]
147148
#[allow(clippy::enum_variant_names)]
148149
pub enum Error {
150+
#[snafu(display("OpaCluster object is invalid"))]
151+
InvalidOpaCluster {
152+
source: error_boundary::InvalidObject,
153+
},
154+
149155
#[snafu(display("object does not define meta name"))]
150156
NoName,
151157

@@ -363,9 +369,18 @@ pub struct OpaClusterConfigDecisionLog {
363369
console: bool,
364370
}
365371

366-
pub async fn reconcile_opa(opa: Arc<OpaCluster>, ctx: Arc<Ctx>) -> Result<Action> {
372+
pub async fn reconcile_opa(
373+
opa: Arc<DeserializeGuard<OpaCluster>>,
374+
ctx: Arc<Ctx>,
375+
) -> Result<Action> {
367376
tracing::info!("Starting reconcile");
368-
let opa_ref = ObjectRef::from_obj(opa.as_ref());
377+
let opa = opa
378+
.0
379+
.as_ref()
380+
.map_err(error_boundary::InvalidObject::clone)
381+
.context(InvalidOpaClusterSnafu)?;
382+
let opa_ref = ObjectRef::from_obj(opa);
383+
369384
let client = &ctx.client;
370385
let resolved_product_image = opa
371386
.spec
@@ -385,7 +400,7 @@ pub async fn reconcile_opa(opa: Arc<OpaCluster>, ctx: Arc<Ctx>) -> Result<Action
385400
let validated_config = validate_all_roles_and_groups_config(
386401
&resolved_product_image.product_version,
387402
&transform_all_roles_to_config(
388-
opa.as_ref(),
403+
opa,
389404
[(
390405
opa_role.to_string(),
391406
(
@@ -409,11 +424,11 @@ pub async fn reconcile_opa(opa: Arc<OpaCluster>, ctx: Arc<Ctx>) -> Result<Action
409424
.map(Cow::Borrowed)
410425
.unwrap_or_default();
411426

412-
let vector_aggregator_address = resolve_vector_aggregator_address(&opa, client)
427+
let vector_aggregator_address = resolve_vector_aggregator_address(opa, client)
413428
.await
414429
.context(ResolveVectorAggregatorAddressSnafu)?;
415430

416-
let server_role_service = build_server_role_service(&opa, &resolved_product_image)?;
431+
let server_role_service = build_server_role_service(opa, &resolved_product_image)?;
417432
// required for discovery config map later
418433
let server_role_service = cluster_resources
419434
.add(client, server_role_service)
@@ -424,8 +439,8 @@ pub async fn reconcile_opa(opa: Arc<OpaCluster>, ctx: Arc<Ctx>) -> Result<Action
424439
.get_required_labels()
425440
.context(BuildLabelSnafu)?;
426441

427-
let (rbac_sa, rbac_rolebinding) = build_rbac_resources(opa.as_ref(), APP_NAME, required_labels)
428-
.context(BuildRbacResourcesSnafu)?;
442+
let (rbac_sa, rbac_rolebinding) =
443+
build_rbac_resources(opa, APP_NAME, required_labels).context(BuildRbacResourcesSnafu)?;
429444

430445
let rbac_sa = cluster_resources
431446
.add(client, rbac_sa)
@@ -450,15 +465,15 @@ pub async fn reconcile_opa(opa: Arc<OpaCluster>, ctx: Arc<Ctx>) -> Result<Action
450465
.context(FailedToResolveConfigSnafu)?;
451466

452467
let rg_configmap = build_server_rolegroup_config_map(
453-
&opa,
468+
opa,
454469
&resolved_product_image,
455470
&rolegroup,
456471
&merged_config,
457472
vector_aggregator_address.as_deref(),
458473
)?;
459-
let rg_service = build_rolegroup_service(&opa, &resolved_product_image, &rolegroup)?;
474+
let rg_service = build_rolegroup_service(opa, &resolved_product_image, &rolegroup)?;
460475
let rg_daemonset = build_server_rolegroup_daemonset(
461-
&opa,
476+
opa,
462477
&resolved_product_image,
463478
&opa_role,
464479
&rolegroup,
@@ -512,13 +527,9 @@ pub async fn reconcile_opa(opa: Arc<OpaCluster>, ctx: Arc<Ctx>) -> Result<Action
512527
.context(ApplyPatchRoleGroupDaemonSetSnafu { rolegroup })?;
513528
}
514529

515-
for discovery_cm in build_discovery_configmaps(
516-
opa.as_ref(),
517-
opa.as_ref(),
518-
&resolved_product_image,
519-
&server_role_service,
520-
)
521-
.context(BuildDiscoveryConfigSnafu)?
530+
for discovery_cm in
531+
build_discovery_configmaps(opa, opa, &resolved_product_image, &server_role_service)
532+
.context(BuildDiscoveryConfigSnafu)?
522533
{
523534
cluster_resources
524535
.add(client, discovery_cm)
@@ -530,14 +541,11 @@ pub async fn reconcile_opa(opa: Arc<OpaCluster>, ctx: Arc<Ctx>) -> Result<Action
530541
ClusterOperationsConditionBuilder::new(&opa.spec.cluster_operation);
531542

532543
let status = OpaClusterStatus {
533-
conditions: compute_conditions(
534-
opa.as_ref(),
535-
&[&ds_cond_builder, &cluster_operation_cond_builder],
536-
),
544+
conditions: compute_conditions(opa, &[&ds_cond_builder, &cluster_operation_cond_builder]),
537545
};
538546

539547
client
540-
.apply_patch_status(OPERATOR_NAME, &*opa, &status)
548+
.apply_patch_status(OPERATOR_NAME, opa, &status)
541549
.await
542550
.context(ApplyStatusSnafu)?;
543551

@@ -1026,8 +1034,17 @@ fn build_server_rolegroup_daemonset(
10261034
})
10271035
}
10281036

1029-
pub fn error_policy(_obj: Arc<OpaCluster>, _error: &Error, _ctx: Arc<Ctx>) -> Action {
1030-
Action::requeue(*Duration::from_secs(5))
1037+
pub fn error_policy(
1038+
_obj: Arc<DeserializeGuard<OpaCluster>>,
1039+
error: &Error,
1040+
_ctx: Arc<Ctx>,
1041+
) -> Action {
1042+
match error {
1043+
// root object is invalid, will be requeued when modified anyway
1044+
Error::InvalidOpaCluster { .. } => Action::await_change(),
1045+
1046+
_ => Action::requeue(*Duration::from_secs(10)),
1047+
}
10311048
}
10321049

10331050
fn build_config_file(merged_config: &OpaConfig) -> String {

rust/operator-binary/src/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use stackable_operator::{
1212
core::v1::{ConfigMap, Service},
1313
},
1414
kube::{
15+
core::DeserializeGuard,
1516
runtime::{watcher, Controller},
1617
Api,
1718
},
@@ -108,10 +109,10 @@ async fn create_controller(
108109
opa_bundle_builder_image: String,
109110
user_info_fetcher_image: String,
110111
) {
111-
let opa_api: Api<OpaCluster> = watch_namespace.get_api(&client);
112-
let daemonsets_api: Api<DaemonSet> = watch_namespace.get_api(&client);
113-
let configmaps_api: Api<ConfigMap> = watch_namespace.get_api(&client);
114-
let services_api: Api<Service> = watch_namespace.get_api(&client);
112+
let opa_api: Api<DeserializeGuard<OpaCluster>> = watch_namespace.get_api(&client);
113+
let daemonsets_api: Api<DeserializeGuard<DaemonSet>> = watch_namespace.get_api(&client);
114+
let configmaps_api: Api<DeserializeGuard<ConfigMap>> = watch_namespace.get_api(&client);
115+
let services_api: Api<DeserializeGuard<Service>> = watch_namespace.get_api(&client);
115116

116117
let controller = Controller::new(opa_api, watcher::Config::default())
117118
.owns(daemonsets_api, watcher::Config::default())

0 commit comments

Comments
 (0)