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

Support supercronic as scheduler #288

Open
meyayl opened this issue Nov 11, 2023 · 7 comments
Open

Support supercronic as scheduler #288

meyayl opened this issue Nov 11, 2023 · 7 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@meyayl
Copy link

meyayl commented Nov 11, 2023

I am trying to run Resticprofile on Openshift.

Our compliance (enforced by kyverno) requires us to run payloads with unprivileged user permissions and no privilege escalation, which seem to make it impossible to run crond inside an alpine container. The same is true for systemd.

supercronic on the other hand runs cronjobs for the current user (including unprivileged users), its file format is basically the know cron format.

Please add support for supercronic, so that users that find themselves in a situation where they need to meet specific compliance challenges can use this wonderful tool as well :)

@jkellerer
Copy link
Collaborator

jkellerer commented Nov 11, 2023

As far as I understand supercronic needs a crontab file.

When you configure resticprofile with:

global:
  scheduler: crond

It expects an executable to manage the crontab file, its interface is:

crontab -l > crontab.txt
cat new-crontab.txt | crontab -

So with a small adapter like /bin/crontab you should be able to use supersonic:

#!/bin/sh
CRONTAB=/opt/crontab.txt
if [ "$1" == "-l" ] && [ -f "$CRONTAB" ] ; then
  cat "$CRONTAB"
elif [ "$1" == "-" ] ; then
  cat - > "$CRONTAB"
fi

@jkellerer
Copy link
Collaborator

We could also add support to specify a crontab file since all is already in place we just use the crontab binary to select the correct file depending on the context.

@jkellerer jkellerer added the enhancement New feature or request label Nov 11, 2023
@jkellerer jkellerer self-assigned this Nov 11, 2023
@meyayl
Copy link
Author

meyayl commented Nov 11, 2023

Relying on crontab might provide two challenges for us:

  1. I am not sure if setting the suid flag on the crontab binary will run on OpenShift with our restricted policies.
  2. We are mandated to use read-only file systems, so we would need to be able to set the target path.

A solution where we could freely specify the target location for the generated contab file, would allow storing the file on an ephemeral volume.

If I am not mistaken, this would allow generating the contab file content with resticprofile -c /path/to/profile schedule and then exec supercronic /path/to/generated/crontab to hand over to supercronic and benefit from scheduled job execution.

@meyayl
Copy link
Author

meyayl commented Nov 11, 2023

I should have read you first comment completely.

The wrapper replaces the crontab binary, so I don't need to set a suid flag and won't run into problems with the read-only file system.

I can work with that :)

I still feel it might be nice to have direct support for supercronic on the long run, so that people can benefit from it out of the box.

Thank you for your quick response!

@creativeprojects
Copy link
Owner

We could also add support to specify a crontab file since all is already in place we just use the crontab binary to select the correct file depending on the context.

The crontab binary is also sending a signal to crond to reload the configuration files. If we save a crontab directly we'll need to do it ourselves 😉

@jkellerer
Copy link
Collaborator

jkellerer commented Nov 11, 2023

Btw. I'm updating the crond support:

  • New: Can be used on any OS with a crontab file (scheduler: "crontab:/path/to/generated/crontab") - the scheduler must then be started manually but that is easy in containers as the file is accepted by multiple solutions (including supersonic). What you wrote should work then: resticprofile -c /path/to/profile schedule && exec supercronic /path/to/generated/crontab).
  • Works as it currently does on linux using the crontab binary to manage the crontab.
  • Will also continue to support the workaround described above.

@meyayl
Copy link
Author

meyayl commented Nov 11, 2023

Awesome news! Much appreciated!

@creativeprojects creativeprojects added this to the v0.27.0 milestone Apr 2, 2024
@creativeprojects creativeprojects changed the title Support supercronic als scheduler Support supercronic as scheduler Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants