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

Create the schedule API #2350

Closed
deviantony opened this issue Oct 10, 2018 · 5 comments · Fixed by #2390
Closed

Create the schedule API #2350

deviantony opened this issue Oct 10, 2018 · 5 comments · Fixed by #2390
Assignees
Milestone

Comments

@deviantony
Copy link
Member

Related to #2183

@chiptus
Copy link
Contributor

chiptus commented Oct 21, 2018

Backend

Introduction of a new Schedule entity with the following fields:

  • Name string
  • Endpoints []EndpointId
  • Schedule string
  • ScriptPath string

New API handlers to manage schedules:

  • /schedules (GET)
  • /schedules (POST): should support two different payloads (JSON for script content / form-data for file upload)
  • /schedules/:id (GET)
  • /schedules/:id (PUT)
  • /schedules/:id (DELETE)

Leads for a potential implementation:

  • It can re-use the existing cron library to manage scheduling / job executions. When a job is trigger, endpoints that are considered as Down should be ignored for now.
  • Scripts can be stored on disk in /data/schedules/:scheduleId
  • When targeting a Swarm + agent environment, all node names in the cluster can be retrieved to execute the job on each node in the cluster
  • Each container created as a part of a schedule should have the io.portainer.schedule.ID label set to scheduleID.

@chiptus
Copy link
Contributor

chiptus commented Oct 21, 2018

Implementation details:

1. Schedule service (docker package)

This is the interface for handling actions on schedules.

It will provide the following methods:

Schedules(): []Schedules
Schedule(scheduleId int): returns the schedule object
CreateSchedule(name string, endpoints [], schedule string, script []byte) : int
UpdateSchedule(scheduleId int, name string, endpoints [], schedule string, script []byte)
DeleteSchedule(scheduleId int)

2. Bolt Schedule Service

A new service inside the bolt package that is responsible to add, remove, update, get schedules in the db

3. Cron Schedule Service

Responsible of scheduling, removing and updating and running tasks schedules in cron

@deviantony
Copy link
Member Author

@chiptus I think that the schedule service should be located in the cron package instead and leverage the JobService introduced via #2361

2 similar comments
@deviantony
Copy link
Member Author

@chiptus I think that the schedule service should be located in the cron package instead and leverage the JobService introduced via #2361

@deviantony
Copy link
Member Author

@chiptus I think that the schedule service should be located in the cron package instead and leverage the JobService introduced via #2361

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

Successfully merging a pull request may close this issue.

2 participants