Skip to content

feat!: Add PodSecurityContextBuilder::with_stackable_defaults#1205

Open
sbernauer wants to merge 1 commit into
mainfrom
chore/security-context-stackable-defaults
Open

feat!: Add PodSecurityContextBuilder::with_stackable_defaults#1205
sbernauer wants to merge 1 commit into
mainfrom
chore/security-context-stackable-defaults

Conversation

@sbernauer
Copy link
Copy Markdown
Member

Description

Part of stackabletech/issues#645

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes

Author

  • Changes are OpenShift compatible
  • CRD changes approved
  • CRD documentation for all fields, following the style guide.
  • Integration tests passed (for non trivial changes)
  • Changes need to be "offline" compatible

Reviewer

  • Code contains useful comments
  • Code contains useful logging statements
  • (Integration-)Test cases added
  • Documentation added or updated. Follows the style guide.
  • Changelog updated
  • Cargo.toml only contains references to git tags (not specific commits or branches)

Acceptance

  • Feature Tracker has been updated
  • Proper release label has been added

/// It is recommended to use the [`PodSecurityContextBuilder::with_stackable_defaults`] instead
/// (if possible).
pub fn stackable_default_pod_security_context() -> PodSecurityContext {
todo!("Lars needs to define the exact settings he wants");
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A TODO for @lfrancke :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just leave the with_recommended_settings() function empty for now and keep the TODO in the issue, so that this pull request can be merged.

@siegfriedweber siegfriedweber self-requested a review May 6, 2026 16:04
@siegfriedweber siegfriedweber moved this to Development: In Review in Stackable Engineering May 6, 2026
pub fn new() -> Self {
Self::default()
/// Construct a new [`PodSecurityContextBuilder`] that is pre-filled with Stackable's defaults.
pub fn with_stackable_defaults() -> Self {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I prefer a vendor neutral term like with_recommended_settings, similar to https://search.nixos.org/options?channel=25.11&query=services.nginx.recommended.
  • I would keep the new function and not force the settings yet: new().with_recommended_settings(). On the one hand, this pull request can then be merged now, and on the other hand, it is not guaranteed that we will be able to roll out this change on all operators at the same time. If we want to force the recommended settings later (which I would not do), we could create a function like new_with_recommended_settings and remove the new function.
  • I would already use the builder functions here, to ensure that builder functions exist to override these settings.
  • I asked for the stackable_default_pod_security_context function but it is not necessary and can be removed. The recommended settings can also be retrieved via PodSecurityContextBuilder::new().with_recommended_settings().build().

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objection against with_recommended_settings, so works for me. Hhowever to me this boils down to "is stackable-operator only for use or are other users also expected to use this?". I think we have different opinions in the team ^^ Discussion for later.

If we want to force the recommended settings later (which I would not do)

I though that was the point of this PR ^^ If some defaults don't work for a tool it can manually overwrite them.

I would keep the new function and not force the settings yet. On the one hand, this pull request can then be merged now

If we add a no-op function and rolling that out everywhere later one I have a bad feeling about e.g. setting the root filesystem to read only. If we define the defaults before merging we have a clearly breaking change. And not some operator-rs bump later on breaks everything silently. But no strong opinion.

pod_security_context: PodSecurityContext,
}

impl PodSecurityContextBuilder {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// It is recommended to use the [`PodSecurityContextBuilder::with_stackable_defaults`] instead
/// (if possible).
pub fn stackable_default_pod_security_context() -> PodSecurityContext {
todo!("Lars needs to define the exact settings he wants");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just leave the with_recommended_settings() function empty for now and keep the TODO in the issue, so that this pull request can be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development: In Review

Development

Successfully merging this pull request may close these issues.

2 participants