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

Add preRegisterContentCommand in an initContainer for register-content job #213

Merged
merged 2 commits into from
Jul 17, 2021

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Jun 29, 2021

Allow a custom command to run just before st2-register-content that can disable aliases/sensors in system packs.

For example

jobs:
  preRegisterContentCommand:
    - '/bin/bash'
    - '-c'
    - |
      sed -i -e 's/^\(\s*\)enabled: true/\1enabled: false/' /opt/stackstorm/packs/packs/aliases/*.yaml
      sed -i -e 's/^\(\s*\)enabled: true/\1enabled: false/' /opt/stackstorm/packs/linux/aliases/*.yaml

Closes: #211

@pull-request-size pull-request-size bot added the size/S PR that changes 10-29 lines. Very easy to review. label Jun 29, 2021
@cognifloyd cognifloyd force-pushed the register-content-init-container branch 6 times, most recently from 1a7fc31 to 7c3d1f0 Compare July 6, 2021 20:40
@cognifloyd cognifloyd changed the title WIP: Add custom initContainer command for register-content job Add preRegisterContentCommand in an initContainer for register-content job Jul 6, 2021
@cognifloyd cognifloyd added RFR and removed WIP labels Jul 6, 2021
@pull-request-size pull-request-size bot added size/M PR that changes 30-99 lines. Good size to review. and removed size/S PR that changes 10-29 lines. Very easy to review. labels Jul 6, 2021
@cognifloyd cognifloyd force-pushed the register-content-init-container branch from b38aad4 to 7fb8c5a Compare July 6, 2021 21:23
@pull-request-size pull-request-size bot added size/S PR that changes 10-29 lines. Very easy to review. and removed size/M PR that changes 30-99 lines. Good size to review. labels Jul 6, 2021
@cognifloyd cognifloyd requested a review from arm4b July 6, 2021 21:28
@cognifloyd
Copy link
Member Author

@armab I just wrapped up this PR too. This is size/S, so hopefully it'll be quick to review.

@cognifloyd cognifloyd force-pushed the register-content-init-container branch 3 times, most recently from d04f829 to 9e531dd Compare July 10, 2021 16:02
- document preRegistercontentCommand
- changelog entry
@cognifloyd cognifloyd force-pushed the register-content-init-container branch from 9e531dd to adce47a Compare July 13, 2021 22:10
@cognifloyd
Copy link
Member Author

@armab I think this is the easiest open k8s PR to merge.

Similar to the postStart change, this allows some init customization, but is restricted to only the register-content job.
Also, the preRegisterContentCommand runs in an initContainer because it has to run before the job itself, not in parallel (postStart runs in parallel with the entrypoint).

# If defined, this preRegisterContentCommand runs in an initContainer on the st2-register-content Job.
# The initContainer also uses the st2actionrunner image but runs this command instead of its entrypoint.
preRegisterContentCommand: []
# For example, to disable aliases in the "packs" system pack before content is registered:
Copy link
Member

Choose a reason for hiding this comment

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

that's a good example 👍
Thanks for highlighting the use case here

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this enhancement!

@arm4b arm4b merged commit 834c478 into StackStorm:master Jul 17, 2021
@cognifloyd
Copy link
Member Author

Thank you!

@cognifloyd cognifloyd removed the RFR label Jul 27, 2021
@cognifloyd cognifloyd deleted the register-content-init-container branch November 11, 2021 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature size/S PR that changes 10-29 lines. Very easy to review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

custom initContainer for register-content job
2 participants