Skip to content

Conversation

jmsnll
Copy link

@jmsnll jmsnll commented Apr 20, 2025

Overview

Refactors the auto-restart logic for workloads referencing 1Password-managed secrets. It generalises internal logic to allow future support for non-Deployment workload types (i.e. stateful sets, daemon sets) while preserving existing behaviour.

  • All restart logic now operates on client.Object or runtime.Object
  • Tests and helper functions are updated to handle polymorphic workloads
  • Sets the foundation for issue-driven expansion to DaemonSets, StatefulSets, etc.

The next steps should this implementation be approved would be to implement controllers for each of the remaining workloads. I believe the current controller could also be genericised in a similar way seen in this PR – which would be ideal as otherwise we'd need to think about how secrets are cleaned up when they're shared by multiple workloads/controllers.

A demo of this implementation working for DaemonSets can be found at: https://github.com/jmsnll/onepassword-operator/tree/feat/demo-daemonsets-autorestart

Related Issue(s)

Changelog

  • Refactored workload restart logic to support any client.Object, not just Deployment
  • Added helpers:
    • GetPodTemplate extracts pod template from known workload types
    • GetUpdatedSecretsForPodTemplate resolves updated secrets from a pod spec
  • Test struct updated to use runtime.Object for workload definitions
  • Should preserved full compatibility with existing Deployment-based functionality

jmsnll added 4 commits April 19, 2025 11:22
- lets use the same general structure and env variables to control if a workload (i.e. a deployment, statefulset, daemonset etc.) should automatically be restarted
- we can add better control for different resource types later if required
…loads

- Replaced deployment-specific logic with generalized handling for supported workloads
- Additional workload types can be marked as support in the `restartWorkload` function once their corresponding controller is implemented
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.

1 participant