Skip to content

Conversation

@fpacifici
Copy link
Collaborator

@fpacifici fpacifici commented Jan 15, 2026

This is the first pass for the implementation of the PipelineStep sentry-kube
external macro.

This macro takes:

  • A streaming pipeline config file
  • a deployment template (provided by the user to customize the deployment)
  • a container template (provided by the user to customize the container)
  • some fields like the pipeline name, set resources, etc.

With the above it creates a Deployment that runs the streaming platform
rust runner and a configmap with the streaming pipeline config.
The configmap is also mounted inside the Deployment so the runner can
access the pieline config.

The principle in the macro is that we take a basic deployment template,
we overlay the customer provided template on that, and we overlay the
streaming platform part on top of that.

This means doing a deepmerge of 3 yaml file one over the other.
This could be achieved by patching the three yaml file one over the
other. Doign this with python dictionaries allows us to be a more
flexible and reuse pieces (see the labels).

The next steps will be:

  • Support emergency patches. During incident we want to allow the oncall to
    edit a specific field of the result whether or not it is customizable.
    This can be achieved by passing in an emergency_patch parameter.
  • Interpret properly the platform config file: multiprocess for example
  • Support scaling

- Create validation.py module in sentry_streams package
- Extract validation logic from runner.py for reusability
- Add comprehensive unit tests for validation function
- Function validates pipeline configs against config.json schema
- Create PipelineStep class in new pipeline_step.py module
- Define PipelineStepContext TypedDict with all required fields
- Implement validate_context with pipeline_config schema validation
- Add sentry-streams dependency to access validation function
- Keep Consumer class for backward compatibility
- Add build_name() to generate RFC 1123 compliant k8s names
- Add build_labels() to generate standard k8s labels
- Add build_container() to build complete container spec with:
  - Command/args for running the streaming platform
  - Resource requests (CPU and memory)
  - Volume mount for pipeline config
- All functions handle deep copying to avoid mutations
- Generate deployment and configmap manifests
- Deep copy deployment_template to avoid mutations
- Update deployment metadata with name and labels
- Add container to deployment spec
- Add configmap volume mount to deployment
- Create configmap with pipeline_config as YAML data
- Preserve namespace from deployment template if present
- Return both resources in dictionary with separate keys
- Remove validation.py and test_validation.py from sentry_streams
- Keep sentry_streams package unchanged as requested
…implementation

- Create validation.py in sentry_streams_k8s with inline config schema
- Add validation tests for pipeline config
- Update PipelineStep to use local validation module
- Remove sentry-streams dependency from pyproject.toml
- All 15 tests passing (12 pipeline_step + 3 validation tests)
- No changes made to sentry_streams package
- Update validation.py to read config.json from sentry_streams package
- Remove duplicated CONFIG_SCHEMA dictionary
- Add sentry-streams as regular dependency (not local path)
- All 15 tests still passing
- No duplication of schema definition
- No changes to sentry_streams package
@fpacifici fpacifici marked this pull request as ready for review January 16, 2026 00:42
@fpacifici fpacifici requested a review from a team as a code owner January 16, 2026 00:42
Merge semantics:
- Simple types (str, int, bool, None): override replaces base
- Dictionaries: recursively merge
- Lists: concatenate (append override elements to base)
Copy link
Member

Choose a reason for hiding this comment

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

Why does this append instead of replacing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I followed the patch semantics of kubectl patch https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#notes-on-the-strategic-merge-patch.

In this specific case scenarios for this choices are:

  • adding a container. Containers are lists not dictionaries. If we replaced the list we would not be able to make the template provide envoy
  • adding volumes. They are lists as well.

Copy link
Member

Choose a reason for hiding this comment

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

OK, makes sense.

Copy link
Member

@evanh evanh left a comment

Choose a reason for hiding this comment

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

LGTM!

cursor[bot]

This comment was marked as outdated.

@fpacifici fpacifici force-pushed the fpacifici/fill_k8s branch 2 times, most recently from eadecdb to d6db388 Compare January 22, 2026 23:34
cursor[bot]

This comment was marked as outdated.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

labels = {
"pipeline-app": make_k8s_name(pipeline_module),
"pipeline": make_k8s_name(pipeline_name),
}
Copy link

Choose a reason for hiding this comment

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

Missing length validation for label values

Medium Severity

Label values created from pipeline_module and pipeline_name via make_k8s_name are not validated or truncated to meet Kubernetes' 63-character limit for label values. Long module or pipeline names like my.very.long.module.name.that.exceeds.the.kubernetes.limit would create labels exceeding 63 characters, causing Kubernetes API to reject the deployment with validation errors.

Fix in Cursor Fix in Web

@fpacifici fpacifici merged commit b4231ca into main Jan 23, 2026
21 checks passed
@fpacifici fpacifici deleted the fpacifici/fill_k8s branch January 23, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants