Compare commits
No commits in common. "main" and "feature/payment" have entirely different histories.
main
...
feature/pa
40
Dockerfile
40
Dockerfile
@ -1,41 +1,25 @@
|
|||||||
FROM golang:alpine AS deps
|
|
||||||
|
|
||||||
ARG MONITORD_IMAGE
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
COPY go.mod go.sum ./
|
|
||||||
RUN sed -i '/replace/d' go.mod
|
|
||||||
RUN go mod download -x
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
FROM golang:alpine AS builder
|
FROM golang:alpine AS builder
|
||||||
|
LABEL maintainer="IRT PFN"
|
||||||
|
ENV DOCKER_ENVIRONMENT=true
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY --from=deps /go/pkg /go/pkg
|
|
||||||
COPY --from=deps /app/go.mod /app/go.sum ./
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN go build
|
RUN go build .
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
FROM oc-monitord:latest AS monitord
|
||||||
FROM ${MONITORD_IMAGE:-oc-monitord}:latest AS monitord
|
|
||||||
|
|
||||||
FROM scratch
|
FROM argoproj/argocd:latest
|
||||||
|
|
||||||
|
ENV MONITORD_PATH = "./oc-monitord"
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY docker_schedulerd.json /etc/oc/schedulerd.json
|
COPY conf/docker_schedulerd.json /etc/oc/schedulerd.json
|
||||||
|
|
||||||
COPY --from=monitord /app/oc-monitord /usr/bin/oc-monitord
|
COPY --from=monitord /app/oc-monitord .
|
||||||
COPY --from=builder /app/oc-schedulerd /usr/bin/oc-schedulerd
|
COPY --from=builder /app/oc-schedulerd .
|
||||||
|
COPY conf/docker_schedulerd.json /etc/oc/schedulerd.json
|
||||||
|
|
||||||
COPY docker_schedulerd.json /etc/oc/schedulerd.json
|
ENTRYPOINT ["/app/oc-schedulerd"]
|
||||||
|
|
||||||
COPY argo_workflows .
|
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
|
|
||||||
ENTRYPOINT ["oc-schedulerd"]
|
|
||||||
|
29
Makefile
29
Makefile
@ -1,29 +0,0 @@
|
|||||||
.DEFAULT_GOAL := all
|
|
||||||
|
|
||||||
build: clean
|
|
||||||
go build .
|
|
||||||
|
|
||||||
build-monitord:
|
|
||||||
go build -o ../oc-monitord ../oc-monitord
|
|
||||||
|
|
||||||
run:
|
|
||||||
./oc-schedulerd
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf oc-schedulerd
|
|
||||||
|
|
||||||
docker:
|
|
||||||
DOCKER_BUILDKIT=1 docker build -t oc/oc-schedulerd:0.0.1 --build-arg MONITORD_IMAGE=oc/oc-monitord -f Dockerfile .
|
|
||||||
docker tag oc/oc-schedulerd:0.0.1 oc/oc-schedulerd:latest
|
|
||||||
|
|
||||||
publish-kind:
|
|
||||||
kind load docker-image oc/oc-schedulerd:0.0.1 --name opencloud
|
|
||||||
|
|
||||||
publish-registry:
|
|
||||||
@echo "TODO"
|
|
||||||
|
|
||||||
all: docker publish-kind publish-registry
|
|
||||||
|
|
||||||
dev: build-monitord build run
|
|
||||||
|
|
||||||
.PHONY: build run clean docker publish-kind publish-registry
|
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
OC-Scheduler retrieves the content of submitted workflows and prepare them to be executed.
|
OC-Scheduler retrieves the content of submitted workflows and prepare them to be executed.
|
||||||
|
|
||||||
make dev
|
|
||||||
|
|
||||||
## Parsing
|
## Parsing
|
||||||
|
|
||||||
From a workflow's name we retrieve the xml graph associated and parse it in order to create the object representing each componant.
|
From a workflow's name we retrieve the xml graph associated and parse it in order to create the object representing each componant.
|
||||||
@ -18,6 +16,3 @@ TODO :
|
|||||||
- [ ] create an argo file from the graph/worfklow
|
- [ ] create an argo file from the graph/worfklow
|
||||||
- [ ] Create a different entry for each component
|
- [ ] Create a different entry for each component
|
||||||
- [ ] execute each element in the right order
|
- [ ] execute each element in the right order
|
||||||
|
|
||||||
## CHANGE ENV FOR KUBE
|
|
||||||
Add your proper CA, Cert & Data + external IP for kube config.
|
|
12
conf/conf.go
12
conf/conf.go
@ -14,12 +14,6 @@ type Config struct {
|
|||||||
Logs string
|
Logs string
|
||||||
LokiUrl string
|
LokiUrl string
|
||||||
NatsUrl string
|
NatsUrl string
|
||||||
Mode string
|
|
||||||
KubeHost string
|
|
||||||
KubePort string
|
|
||||||
KubeCA string
|
|
||||||
KubeCert string
|
|
||||||
KubeData string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var instance *Config
|
var instance *Config
|
||||||
@ -44,6 +38,12 @@ func init() {
|
|||||||
o = onion.New(l2, l3)
|
o = onion.New(l2, l3)
|
||||||
}
|
}
|
||||||
GetConfig().MonitorPath = o.GetStringDefault("MONITORD_PATH", "../oc-monitord/oc-monitord")
|
GetConfig().MonitorPath = o.GetStringDefault("MONITORD_PATH", "../oc-monitord/oc-monitord")
|
||||||
|
GetConfig().Logs = o.GetStringDefault("LOG_LEVEL", "info")
|
||||||
|
GetConfig().LokiUrl = o.GetStringDefault("LOKI_URL", "http://127.0.0.1:3100")
|
||||||
|
GetConfig().NatsUrl = o.GetStringDefault("NATS_URL", "http://127.0.0.1:4222")
|
||||||
|
GetConfig().MongoUrl = o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017")
|
||||||
|
GetConfig().DBName = o.GetStringDefault("MONGO_DATABASE", "DC_myDC")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetConfig() *Config {
|
func GetConfig() *Config {
|
||||||
|
6
conf/docker_schedulerd.json
Normal file
6
conf/docker_schedulerd.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"LOKI_URL" : "http://loki:3100",
|
||||||
|
"MONGO_URL":"mongodb://mongo:27017/",
|
||||||
|
"MONGO_DATABASE":"DC_myDC",
|
||||||
|
"NATS_URL": "nats://nats:4222"
|
||||||
|
}
|
67
daemons/execute_monitor_kube.go
Normal file
67
daemons/execute_monitor_kube.go
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package daemons
|
||||||
|
|
||||||
|
// type manifestValues struct{
|
||||||
|
// ARGO_FILE string
|
||||||
|
// LOKI_URL string
|
||||||
|
// CONTAINER_NAME string
|
||||||
|
// }
|
||||||
|
|
||||||
|
// manifest, err := em.CreateManifest(booking, argo_file_path)
|
||||||
|
// if err != nil {
|
||||||
|
// logger.Logger.Error().Msg("Could not create manifest " + err.Error())
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // launch a pod that contains oc-monitor, give it the name of the workflow
|
||||||
|
// cmd := exec.Command("kubectl","apply","-f", "manifests/"+manifest)
|
||||||
|
// output , err := cmd.CombinedOutput()
|
||||||
|
// if err != nil {
|
||||||
|
// logger.Logger.Error().Msg("failed to create new pod for " + booking.Workflow + " :" + err.Error())
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func (*ExecutionManager) CreateManifest(booking models.Booking, argo_file string) (manifest_filepath string, err error) {
|
||||||
|
|
||||||
|
// var filled_template bytes.Buffer
|
||||||
|
|
||||||
|
// manifest_file, err := os.ReadFile("conf/monitor_pod_template.yml")
|
||||||
|
// if err != nil {
|
||||||
|
// logger.Logger.Error().Msg("Could not open the k8s template file for " + booking.Workflow)
|
||||||
|
// return "", err
|
||||||
|
// }
|
||||||
|
|
||||||
|
// container_name := getContainerName(argo_file)
|
||||||
|
// tmpl, err := template.New("manifest_template").Parse(string(manifest_file))
|
||||||
|
// if err != nil {
|
||||||
|
// logger.Logger.Error().Msg(err.Error())
|
||||||
|
// return "", err
|
||||||
|
// }
|
||||||
|
|
||||||
|
// manifest_data := manifestValues{
|
||||||
|
// ARGO_FILE: argo_file,
|
||||||
|
// LOKI_URL: conf.GetConfig().Logs,
|
||||||
|
// CONTAINER_NAME: container_name,
|
||||||
|
// }
|
||||||
|
|
||||||
|
// err = tmpl.Execute(&filled_template, manifest_data)
|
||||||
|
// if err != nil {
|
||||||
|
// logger.Logger.Error().Msg("Could not complete manifest template for " + booking.Workflow)
|
||||||
|
// return "", err }
|
||||||
|
|
||||||
|
// manifest_filepath = booking.Workflow + "_manifest.yaml"
|
||||||
|
|
||||||
|
// err = os.WriteFile("manifests/" + manifest_filepath, filled_template.Bytes(),0644)
|
||||||
|
// if err != nil {
|
||||||
|
// logger.Logger.Error().Msg("Could not write the YAML file for " + booking.Workflow + "'s manifest")
|
||||||
|
// return "", err
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return manifest_filepath, nil
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func getContainerName(argo_file string) string {
|
||||||
|
// regex := "([a-zA-Z]+-[a-zA-Z]+)"
|
||||||
|
// re := regexp.MustCompile(regex)
|
||||||
|
|
||||||
|
// container_name := re.FindString(argo_file)
|
||||||
|
// return container_name
|
||||||
|
// }
|
@ -9,6 +9,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type LocalMonitor struct {
|
type LocalMonitor struct {
|
||||||
|
LokiURL string
|
||||||
|
KubeURL string
|
||||||
ExecutionID string
|
ExecutionID string
|
||||||
PeerID string
|
PeerID string
|
||||||
Duration int
|
Duration int
|
||||||
@ -16,22 +18,20 @@ type LocalMonitor struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (lm *LocalMonitor) LaunchLocalMonitor() {
|
func (lm *LocalMonitor) LaunchLocalMonitor() {
|
||||||
if lm.ExecutionID == "" {
|
if lm.LokiURL == "" || lm.KubeURL == "" || lm.ExecutionID == "" {
|
||||||
lm.Logger.Error().Msg("Missing parameter in LocalMonitor")
|
lm.Logger.Error().Msg("Missing parameter in LocalMonitor")
|
||||||
}
|
}
|
||||||
lm.execKube()
|
|
||||||
|
// For dev purposes, in prod KubeURL must be a kube API's URL
|
||||||
|
if lm.KubeURL != "localhost" {
|
||||||
|
lm.execRemoteKube()
|
||||||
|
} else {
|
||||||
|
lm.execLocalKube()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lm *LocalMonitor) execKube() {
|
func (lm *LocalMonitor) execLocalKube() {
|
||||||
args := []string{
|
args := []string{"-e", lm.ExecutionID, "-p", lm.PeerID, "-u", lm.LokiURL, "-m", conf.GetConfig().MongoUrl, "-d", conf.GetConfig().DBName}
|
||||||
"-e", lm.ExecutionID, "-p", lm.PeerID, "-u", conf.GetConfig().LokiUrl, "-m", conf.GetConfig().MongoUrl,
|
|
||||||
"-d", conf.GetConfig().DBName,
|
|
||||||
}
|
|
||||||
|
|
||||||
if conf.GetConfig().Mode == "kubernetes" {
|
|
||||||
args = append(args, []string{"-M", conf.GetConfig().Mode, "-H", conf.GetConfig().KubeHost, "-P", conf.GetConfig().KubePort,
|
|
||||||
"-C", conf.GetConfig().KubeCert, "-D", conf.GetConfig().KubeData, "-c", conf.GetConfig().KubeCA}...)
|
|
||||||
}
|
|
||||||
if lm.Duration > 0 {
|
if lm.Duration > 0 {
|
||||||
args = append(args, "-t", fmt.Sprintf("%d", lm.Duration))
|
args = append(args, "-t", fmt.Sprintf("%d", lm.Duration))
|
||||||
}
|
}
|
||||||
@ -42,3 +42,6 @@ func (lm *LocalMonitor) execKube() {
|
|||||||
lm.Logger.Error().Msg("Could not start oc-monitor for " + lm.ExecutionID + " : " + err.Error())
|
lm.Logger.Error().Msg("Could not start oc-monitor for " + lm.ExecutionID + " : " + err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO : implement this
|
||||||
|
func (lm *LocalMonitor) execRemoteKube() {}
|
||||||
|
@ -2,6 +2,7 @@ package daemons
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"oc-schedulerd/conf"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -9,33 +10,33 @@ import (
|
|||||||
workflow_execution "cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
workflow_execution "cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Executions = ScheduledExecution{Execs: []*workflow_execution.WorkflowExecution{}}
|
var Bookings = ScheduledBooking{Bookings: []*workflow_execution.WorkflowExecutions{}}
|
||||||
|
|
||||||
type ExecutionManager struct{}
|
type ExecutionManager struct{}
|
||||||
|
|
||||||
// Loop every second on the Execution's list and move the Execution that must start to a new list
|
// Loop every second on the booking's list and move the booking that must start to a new list
|
||||||
// that will be looped over to start them
|
// that will be looped over to start them
|
||||||
func (em *ExecutionManager) RetrieveNextExecutions() {
|
func (em *ExecutionManager) RetrieveNextExecutions() {
|
||||||
logger := oclib.GetLogger()
|
logger := oclib.GetLogger()
|
||||||
for {
|
for {
|
||||||
fmt.Println("Checking for executions", len(Executions.Execs))
|
fmt.Println("Checking for bookings", len(Bookings.Bookings))
|
||||||
Executions.Mu.Lock()
|
Bookings.Mu.Lock()
|
||||||
if len(Executions.Execs) > 0 {
|
if len(Bookings.Bookings) > 0 {
|
||||||
executions := Executions.Execs
|
bookings := Bookings.Bookings
|
||||||
for i := len(executions) - 1; i >= 0; i-- {
|
for i := len(bookings) - 1; i >= 0; i-- {
|
||||||
if executions[i].ExecDate.Before(time.Now().UTC()) {
|
if bookings[i].ExecDate.Before(time.Now().UTC()) {
|
||||||
logger.Info().Msg("Will execute " + executions[i].UUID + " soon")
|
logger.Info().Msg("Will execute " + bookings[i].UUID + " soon")
|
||||||
go em.executeExecution(executions[i])
|
go em.executeBooking(bookings[i])
|
||||||
Executions.Execs = append(executions[:i], executions[i+1:]...)
|
Bookings.Bookings = append(bookings[:i], bookings[i+1:]...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Executions.Mu.Unlock()
|
Bookings.Mu.Unlock()
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (em *ExecutionManager) executeExecution(Execution *workflow_execution.WorkflowExecution) {
|
func (em *ExecutionManager) executeBooking(booking *workflow_execution.WorkflowExecutions) {
|
||||||
// start execution
|
// start execution
|
||||||
// create the yaml that describes the pod : filename, path/url to Loki
|
// create the yaml that describes the pod : filename, path/url to Loki
|
||||||
exec_method := os.Getenv("MONITOR_METHOD")
|
exec_method := os.Getenv("MONITOR_METHOD")
|
||||||
@ -45,14 +46,16 @@ func (em *ExecutionManager) executeExecution(Execution *workflow_execution.Workf
|
|||||||
} else {
|
} else {
|
||||||
logger.Debug().Msg("Executing oc-monitor localy")
|
logger.Debug().Msg("Executing oc-monitor localy")
|
||||||
duration := 0
|
duration := 0
|
||||||
if Execution.EndDate != nil {
|
if booking.EndDate != nil {
|
||||||
duration = int(Execution.EndDate.Sub(Execution.ExecDate).Seconds())
|
duration = int(booking.EndDate.Sub(booking.ExecDate).Seconds())
|
||||||
}
|
}
|
||||||
monitor := LocalMonitor{
|
monitor := LocalMonitor{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
Duration: duration,
|
Duration: duration,
|
||||||
ExecutionID: Execution.UUID,
|
LokiURL: conf.GetConfig().LokiUrl,
|
||||||
PeerID: Execution.CreatorID,
|
KubeURL: "localhost",
|
||||||
|
ExecutionID: booking.UUID,
|
||||||
|
PeerID: booking.CreatorID,
|
||||||
}
|
}
|
||||||
monitor.LaunchLocalMonitor()
|
monitor.LaunchLocalMonitor()
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package daemons
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"oc-schedulerd/conf"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -16,36 +17,36 @@ import (
|
|||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScheduledExecution struct {
|
type ScheduledBooking struct {
|
||||||
Execs []*workflow_execution.WorkflowExecution
|
Bookings []*workflow_execution.WorkflowExecutions
|
||||||
Mu sync.Mutex
|
Mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *ScheduledExecution) DeleteSchedules(workflow_id string) {
|
func (sb *ScheduledBooking) DeleteSchedules(workflow_id string) {
|
||||||
toNotDelete := []*workflow_execution.WorkflowExecution{}
|
toNotDelete := []*workflow_execution.WorkflowExecutions{}
|
||||||
for _, b := range sb.Execs {
|
for _, b := range sb.Bookings {
|
||||||
if b.WorkflowID != workflow_id {
|
if b.WorkflowID != workflow_id {
|
||||||
toNotDelete = append(toNotDelete, b)
|
toNotDelete = append(toNotDelete, b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Executions.Mu.Lock()
|
Bookings.Mu.Lock()
|
||||||
defer Executions.Mu.Unlock()
|
defer Bookings.Mu.Unlock()
|
||||||
sb.Execs = toNotDelete
|
sb.Bookings = toNotDelete
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *ScheduledExecution) AddSchedules(new_executions []*workflow_execution.WorkflowExecution, logger zerolog.Logger) {
|
func (sb *ScheduledBooking) AddSchedules(new_bookings []*workflow_execution.WorkflowExecutions, logger zerolog.Logger) {
|
||||||
Executions.Mu.Lock()
|
Bookings.Mu.Lock()
|
||||||
defer Executions.Mu.Unlock()
|
defer Bookings.Mu.Unlock()
|
||||||
for _, exec := range new_executions {
|
for _, exec := range new_bookings {
|
||||||
fmt.Println("Adding "+exec.UUID, !sb.execIsSet(exec))
|
fmt.Println("Adding "+exec.UUID, !sb.execIsSet(exec))
|
||||||
if !sb.execIsSet(exec) {
|
if !sb.execIsSet(exec) {
|
||||||
sb.Execs = append(sb.Execs, exec)
|
sb.Bookings = append(sb.Bookings, exec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *ScheduledExecution) execIsSet(exec *workflow_execution.WorkflowExecution) bool {
|
func (sb *ScheduledBooking) execIsSet(exec *workflow_execution.WorkflowExecutions) bool {
|
||||||
for _, b := range sb.Execs {
|
for _, b := range sb.Bookings {
|
||||||
if b.Equals(exec) {
|
if b.Equals(exec) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -65,7 +66,7 @@ type ScheduleManager struct {
|
|||||||
// on workflows' scheduling. Messages must contain
|
// on workflows' scheduling. Messages must contain
|
||||||
// workflow execution ID, to allow retrieval of execution infos
|
// workflow execution ID, to allow retrieval of execution infos
|
||||||
func (s *ScheduleManager) ListenNATS() {
|
func (s *ScheduleManager) ListenNATS() {
|
||||||
nc, err := nats.Connect(oclib.GetConfig().NATSUrl)
|
nc, err := nats.Connect(conf.GetConfig().NatsUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.Logger.Error().Msg("Could not connect to NATS")
|
s.Logger.Error().Msg("Could not connect to NATS")
|
||||||
return
|
return
|
||||||
@ -101,7 +102,7 @@ func (s *ScheduleManager) listenForChange(nc *nats.Conn, chanName string, delete
|
|||||||
}
|
}
|
||||||
fmt.Println("Catching " + str + " workflow... " + map_mess["id"])
|
fmt.Println("Catching " + str + " workflow... " + map_mess["id"])
|
||||||
if delete {
|
if delete {
|
||||||
Executions.DeleteSchedules(map_mess["id"])
|
Bookings.DeleteSchedules(map_mess["id"])
|
||||||
} else {
|
} else {
|
||||||
s.getNextScheduledWorkflows(1)
|
s.getNextScheduledWorkflows(1)
|
||||||
}
|
}
|
||||||
@ -114,11 +115,11 @@ func (s *ScheduleManager) SchedulePolling() {
|
|||||||
var sleep_time float64 = 1
|
var sleep_time float64 = 1
|
||||||
for {
|
for {
|
||||||
s.getNextScheduledWorkflows(1)
|
s.getNextScheduledWorkflows(1)
|
||||||
s.Logger.Info().Msg("Current list of schedules -------> " + fmt.Sprintf("%v", len(Executions.Execs)))
|
s.Logger.Info().Msg("Current list of schedules -------> " + fmt.Sprintf("%v", len(Bookings.Bookings)))
|
||||||
time.Sleep(time.Minute * time.Duration(sleep_time))
|
time.Sleep(time.Minute * time.Duration(sleep_time))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (s *ScheduleManager) getExecution(from time.Time, to time.Time) (exec_list []*workflow_execution.WorkflowExecution, err error) {
|
func (s *ScheduleManager) getExecution(from time.Time, to time.Time) (exec_list []*workflow_execution.WorkflowExecutions, err error) {
|
||||||
fmt.Printf("Getting workflows execution from %s to %s \n", from.String(), to.String())
|
fmt.Printf("Getting workflows execution from %s to %s \n", from.String(), to.String())
|
||||||
f := dbs.Filters{
|
f := dbs.Filters{
|
||||||
And: map[string][]dbs.Filter{
|
And: map[string][]dbs.Filter{
|
||||||
@ -132,7 +133,7 @@ func (s *ScheduleManager) getExecution(from time.Time, to time.Time) (exec_list
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, exec := range res.Data {
|
for _, exec := range res.Data {
|
||||||
exec_list = append(exec_list, exec.(*workflow_execution.WorkflowExecution))
|
exec_list = append(exec_list, exec.(*workflow_execution.WorkflowExecutions))
|
||||||
}
|
}
|
||||||
fmt.Println("Found "+fmt.Sprintf("%v", len(exec_list))+" workflows", res)
|
fmt.Println("Found "+fmt.Sprintf("%v", len(exec_list))+" workflows", res)
|
||||||
return
|
return
|
||||||
@ -150,6 +151,6 @@ func (s *ScheduleManager) getNextScheduledWorkflows(minutes float64) {
|
|||||||
); err != nil {
|
); err != nil {
|
||||||
s.Logger.Error().Msg("Could not retrieve next schedules")
|
s.Logger.Error().Msg("Could not retrieve next schedules")
|
||||||
} else {
|
} else {
|
||||||
Executions.AddSchedules(next_wf_exec, s.Logger)
|
Bookings.AddSchedules(next_wf_exec, s.Logger)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
36
docker-compose.tools.yml
Normal file
36
docker-compose.tools.yml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
services:
|
||||||
|
nats:
|
||||||
|
image: 'nats:latest'
|
||||||
|
container_name: nats
|
||||||
|
ports:
|
||||||
|
- 4222:4222
|
||||||
|
command:
|
||||||
|
- "--debug"
|
||||||
|
networks:
|
||||||
|
- catalog
|
||||||
|
loki:
|
||||||
|
image: 'grafana/loki'
|
||||||
|
container_name: loki
|
||||||
|
ports :
|
||||||
|
- "3100:3100"
|
||||||
|
networks:
|
||||||
|
- catalog
|
||||||
|
grafana:
|
||||||
|
image: 'grafana/grafana'
|
||||||
|
container_name: grafana
|
||||||
|
ports:
|
||||||
|
- '3000:3000'
|
||||||
|
networks:
|
||||||
|
- catalog
|
||||||
|
volumes:
|
||||||
|
- ./conf/grafana_data_source.yml:/etc/grafana/provisioning/datasources/datasource.yml
|
||||||
|
environment:
|
||||||
|
- GF_SECURITY_ADMIN_PASSWORD=pfnirt # Change this to anything but admin to not have a password change page at startup
|
||||||
|
- GF_SECURITY_ADMIN_USER=admin
|
||||||
|
- GF_SECURITY_DISABLE_INITIAL_ADMIN_PASSWORD_CHANGE=true
|
||||||
|
|
||||||
|
networks:
|
||||||
|
catalog:
|
||||||
|
external: true
|
@ -4,16 +4,13 @@ services:
|
|||||||
oc-schedulerd:
|
oc-schedulerd:
|
||||||
environment:
|
environment:
|
||||||
- MONGO_DATABASE=DC_myDC
|
- MONGO_DATABASE=DC_myDC
|
||||||
- KUBERNETES_SERVICE_HOST=${KUBERNETES_SERVICE_HOST:-193.50.43.14}
|
|
||||||
- KUBE_CA=${KUBE_CA:-LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJrVENDQVRlZ0F3SUJBZ0lJWUxWNkFPQkdrU1F3Q2dZSUtvWkl6ajBFQXdJd0l6RWhNQjhHQTFVRUF3d1kKYXpOekxXTnNhV1Z1ZEMxallVQXhOekl6TVRFeU1ETTJNQjRYRFRJME1EZ3dPREV3TVRNMU5sb1hEVEkxTURndwpPREV3TVRNMU5sb3dNREVYTUJVR0ExVUVDaE1PYzNsemRHVnRPbTFoYzNSbGNuTXhGVEFUQmdOVkJBTVRESE41CmMzUmxiVHBoWkcxcGJqQlpNQk1HQnlxR1NNNDlBZ0VHQ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UxJL2dNYnNMT3MvUUpJa3U2WHVpRVMwTEE2cEJHMXgKcnBlTnpGdlZOekZsQWlFQW1wdjBubjZqN3M0MVI0QzFNMEpSL0djNE53MHdldlFmZWdEVGF1R2p3cFk9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K}
|
|
||||||
- KUBE_TOKEN=${KUBE_TOKEN:-LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSU5ZS1BFb1dhd1NKUzJlRW5oWmlYMk5VZlY1ZlhKV2krSVNnV09TNFE5VTlvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFVUozblJZN0tCNEtUWUx0WnFUMS96VS84a0Z2Sk1lUGhYMm1Vc25pczBiR3FZblkyaVZEeApYVzR2SVhTYjNqcm9iZ1YwSUtDT0twUWs2OHJEbE03ckRBPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=}
|
|
||||||
image: 'oc-schedulerd:latest'
|
image: 'oc-schedulerd:latest'
|
||||||
ports:
|
ports:
|
||||||
- 9001:8080
|
- 9001:8080
|
||||||
container_name: oc-schedulerd
|
container_name: oc-schedulerd
|
||||||
networks:
|
networks:
|
||||||
- oc
|
- catalog
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
oc:
|
catalog:
|
||||||
external: true
|
external: true
|
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"LOKI_URL" : "http://loki:3100",
|
|
||||||
"MONGO_URL":"mongodb://mongo:27017/",
|
|
||||||
"NATS_URL":"nats://nats:4222",
|
|
||||||
"MONGO_DATABASE":"DC_myDC",
|
|
||||||
"MONITORD_PATH": "oc-monitord",
|
|
||||||
"KUBERNETES_SERVICE_HOST" : "192.168.47.41",
|
|
||||||
"MODE": "kubernetes",
|
|
||||||
"KUBE_CA" : "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJkekNDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPU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RVMwTEE2cEJHMXgKcnBlTnpGdlZOekZsQWlFQW1wdjBubjZqN3M0MVI0QzFNMEpSL0djNE53MHdldlFmZWdEVGF1R2p3cFk9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K",
|
|
||||||
"KUBE_DATA": "LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSU5ZS1BFb1dhd1NKUzJlRW5oWmlYMk5VZlY1ZlhKV2krSVNnV09TNFE5VTlvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFVUozblJZN0tCNEtUWUx0WnFUMS96VS84a0Z2Sk1lUGhYMm1Vc25pczBiR3FZblkyaVZEeApYVzR2SVhTYjNqcm9iZ1YwSUtDT0twUWs2OHJEbE03ckRBPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo="
|
|
||||||
}
|
|
||||||
|
|
59
go.mod
59
go.mod
@ -5,50 +5,99 @@ go 1.22.0
|
|||||||
toolchain go1.22.5
|
toolchain go1.22.5
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250219142942-5111c9c8bec7
|
|
||||||
github.com/beego/beego v1.12.12
|
github.com/beego/beego v1.12.12
|
||||||
|
github.com/beego/beego/v2 v2.3.1
|
||||||
github.com/goraz/onion v0.1.3
|
github.com/goraz/onion v0.1.3
|
||||||
github.com/nats-io/nats.go v1.37.0
|
github.com/nats-io/nats.go v1.37.0
|
||||||
|
github.com/nwtgck/go-fakelish v0.1.3
|
||||||
github.com/rs/zerolog v1.33.0
|
github.com/rs/zerolog v1.33.0
|
||||||
go.mongodb.org/mongo-driver v1.17.1
|
github.com/tidwall/gjson v1.17.1
|
||||||
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
|
k8s.io/client-go v0.30.3
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/beego/beego/v2 v2.3.1 // indirect
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250205160221-88b7cfe2fd0f // indirect
|
||||||
|
github.com/Klathmon/StructToMap v0.0.0-20140724123129-3d0229e2dce7 // indirect
|
||||||
|
github.com/antihax/optional v1.0.0 // indirect
|
||||||
|
github.com/aws/aws-sdk-go v1.36.29 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/biter777/countries v1.7.5 // indirect
|
github.com/biter777/countries v1.7.5 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
|
||||||
|
github.com/go-logr/logr v1.4.1 // indirect
|
||||||
|
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||||
|
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
||||||
|
github.com/go-openapi/swag v0.22.3 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.22.1 // indirect
|
github.com/go-playground/validator/v10 v10.22.1 // indirect
|
||||||
|
github.com/go-stack/stack v1.8.0 // indirect
|
||||||
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
|
github.com/golang/protobuf v1.5.4 // indirect
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
|
github.com/google/gnostic-models v0.6.8 // indirect
|
||||||
|
github.com/google/gofuzz v1.2.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||||
|
github.com/imdario/mergo v0.3.8 // indirect
|
||||||
|
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||||
|
github.com/josharian/intern v1.0.0 // indirect
|
||||||
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.17.11 // indirect
|
github.com/klauspost/compress v1.17.11 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
|
github.com/marcinwyszynski/geopoint v0.0.0-20140302213024-cf2a6f750c5b // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/montanaflynn/stats v0.7.1 // indirect
|
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||||
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
|
github.com/nats-io/jwt v0.3.2 // indirect
|
||||||
github.com/nats-io/nkeys v0.4.7 // indirect
|
github.com/nats-io/nkeys v0.4.7 // indirect
|
||||||
github.com/nats-io/nuid v1.0.1 // indirect
|
github.com/nats-io/nuid v1.0.1 // indirect
|
||||||
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/prometheus/client_golang v1.19.0 // indirect
|
github.com/prometheus/client_golang v1.19.0 // indirect
|
||||||
github.com/prometheus/client_model v0.5.0 // indirect
|
github.com/prometheus/client_model v0.5.0 // indirect
|
||||||
github.com/prometheus/common v0.48.0 // indirect
|
github.com/prometheus/common v0.48.0 // indirect
|
||||||
github.com/prometheus/procfs v0.12.0 // indirect
|
github.com/prometheus/procfs v0.12.0 // indirect
|
||||||
github.com/robfig/cron v1.2.0 // indirect
|
github.com/robfig/cron v1.2.0 // indirect
|
||||||
|
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||||
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
|
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
|
||||||
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
|
github.com/tidwall/pretty v1.2.0 // indirect
|
||||||
|
github.com/ugorji/go/codec v1.1.7 // indirect
|
||||||
|
github.com/vk496/cron v1.2.0 // indirect
|
||||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||||
github.com/xdg-go/scram v1.1.2 // indirect
|
github.com/xdg-go/scram v1.1.2 // indirect
|
||||||
github.com/xdg-go/stringprep v1.0.4 // indirect
|
github.com/xdg-go/stringprep v1.0.4 // indirect
|
||||||
|
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
|
||||||
|
github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc // indirect
|
||||||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
|
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
|
||||||
|
go.mongodb.org/mongo-driver v1.17.1 // indirect
|
||||||
golang.org/x/crypto v0.28.0 // indirect
|
golang.org/x/crypto v0.28.0 // indirect
|
||||||
golang.org/x/net v0.30.0 // indirect
|
golang.org/x/net v0.30.0 // indirect
|
||||||
|
golang.org/x/oauth2 v0.16.0 // indirect
|
||||||
golang.org/x/sync v0.8.0 // indirect
|
golang.org/x/sync v0.8.0 // indirect
|
||||||
golang.org/x/sys v0.26.0 // indirect
|
golang.org/x/sys v0.26.0 // indirect
|
||||||
|
golang.org/x/term v0.25.0 // indirect
|
||||||
golang.org/x/text v0.19.0 // indirect
|
golang.org/x/text v0.19.0 // indirect
|
||||||
|
golang.org/x/time v0.3.0 // indirect
|
||||||
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
google.golang.org/protobuf v1.35.1 // indirect
|
google.golang.org/protobuf v1.35.1 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
|
k8s.io/api v0.30.3 // indirect
|
||||||
|
k8s.io/apimachinery v0.30.3 // indirect
|
||||||
|
k8s.io/klog/v2 v2.120.1 // indirect
|
||||||
|
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
|
||||||
|
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
|
||||||
|
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
||||||
|
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
|
||||||
|
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||||
)
|
)
|
||||||
|
59
k8s/k8s_client.go
Normal file
59
k8s/k8s_client.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Note: the example only works with the code within the same release/branch.
|
||||||
|
package k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
"k8s.io/client-go/util/homedir"
|
||||||
|
//
|
||||||
|
// Uncomment to load all auth plugins
|
||||||
|
// _ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||||
|
//
|
||||||
|
// Or uncomment to load specific auth plugins
|
||||||
|
// _ "k8s.io/client-go/plugin/pkg/client/auth/azure"
|
||||||
|
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||||
|
// _ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewK8SClient() *kubernetes.Clientset {
|
||||||
|
var kubeconfig *string
|
||||||
|
if home := homedir.HomeDir(); home != "" {
|
||||||
|
kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
|
||||||
|
} else {
|
||||||
|
kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
|
||||||
|
}
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
// use the current context in kubeconfig
|
||||||
|
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
|
||||||
|
if err != nil {
|
||||||
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the clientset
|
||||||
|
clientset, err := kubernetes.NewForConfig(config)
|
||||||
|
if err != nil {
|
||||||
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientset
|
||||||
|
}
|
28
main.go
28
main.go
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"oc-schedulerd/conf"
|
"oc-schedulerd/conf"
|
||||||
"oc-schedulerd/daemons"
|
"oc-schedulerd/daemons"
|
||||||
|
|
||||||
@ -9,29 +10,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
oclib.InitDaemon("oc-schedulerd")
|
oclib.InitDaemon("oc-schedulerd")
|
||||||
o := oclib.GetConfLoader()
|
oclib.SetConfig(
|
||||||
|
conf.GetConfig().MongoUrl,
|
||||||
c := oclib.SetConfig(
|
conf.GetConfig().DBName,
|
||||||
o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"),
|
conf.GetConfig().NatsUrl,
|
||||||
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
|
conf.GetConfig().LokiUrl,
|
||||||
o.GetStringDefault("NATS_URL", "nats://localhost:4222"),
|
conf.GetConfig().Logs,
|
||||||
o.GetStringDefault("LOKI_URL", ""),
|
|
||||||
o.GetStringDefault("LOG_LEVEL", "info"),
|
|
||||||
)
|
)
|
||||||
conf.GetConfig().DBName = c.MongoDatabase
|
|
||||||
conf.GetConfig().MongoUrl = c.MongoUrl
|
|
||||||
conf.GetConfig().NatsUrl = c.NATSUrl
|
|
||||||
conf.GetConfig().LokiUrl = c.LokiUrl
|
|
||||||
conf.GetConfig().Mode = o.GetStringDefault("MODE", "")
|
|
||||||
conf.GetConfig().KubeHost = o.GetStringDefault("KUBERNETES_SERVICE_HOST", "")
|
|
||||||
conf.GetConfig().KubePort = o.GetStringDefault("KUBERNETES_SERVICE_PORT", "6443")
|
|
||||||
|
|
||||||
conf.GetConfig().KubeCA = o.GetStringDefault("KUBE_CA", "")
|
|
||||||
conf.GetConfig().KubeCert = o.GetStringDefault("KUBE_CERT", "")
|
|
||||||
conf.GetConfig().KubeData = o.GetStringDefault("KUBE_DATA", "")
|
|
||||||
|
|
||||||
sch_mngr := daemons.ScheduleManager{Logger: oclib.GetLogger()}
|
sch_mngr := daemons.ScheduleManager{Logger: oclib.GetLogger()}
|
||||||
exe_mngr := daemons.ExecutionManager{}
|
exe_mngr := daemons.ExecutionManager{}
|
||||||
|
|
||||||
|
BIN
oc-schedulerd
BIN
oc-schedulerd
Binary file not shown.
BIN
swagger/favicon-16x16.png
Normal file
BIN
swagger/favicon-16x16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 665 B |
BIN
swagger/favicon-32x32.png
Normal file
BIN
swagger/favicon-32x32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 628 B |
60
swagger/index.html
Normal file
60
swagger/index.html
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<!-- HTML for static distribution bundle build -->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Swagger UI</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
|
||||||
|
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||||
|
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||||
|
<style>
|
||||||
|
html
|
||||||
|
{
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: -moz-scrollbars-vertical;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
*,
|
||||||
|
*:before,
|
||||||
|
*:after
|
||||||
|
{
|
||||||
|
box-sizing: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
body
|
||||||
|
{
|
||||||
|
margin:0;
|
||||||
|
background: #fafafa;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="swagger-ui"></div>
|
||||||
|
|
||||||
|
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
|
||||||
|
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
|
||||||
|
<script>
|
||||||
|
window.onload = function() {
|
||||||
|
// Begin Swagger UI call region
|
||||||
|
const ui = SwaggerUIBundle({
|
||||||
|
url: "https://petstore.swagger.io/v2/swagger.json",
|
||||||
|
dom_id: '#swagger-ui',
|
||||||
|
deepLinking: true,
|
||||||
|
presets: [
|
||||||
|
SwaggerUIBundle.presets.apis,
|
||||||
|
SwaggerUIStandalonePreset
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
SwaggerUIBundle.plugins.DownloadUrl
|
||||||
|
],
|
||||||
|
layout: "StandaloneLayout"
|
||||||
|
});
|
||||||
|
// End Swagger UI call region
|
||||||
|
|
||||||
|
window.ui = ui;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
79
swagger/oauth2-redirect.html
Normal file
79
swagger/oauth2-redirect.html
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en-US">
|
||||||
|
<head>
|
||||||
|
<title>Swagger UI: OAuth2 Redirect</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
'use strict';
|
||||||
|
function run () {
|
||||||
|
var oauth2 = window.opener.swaggerUIRedirectOauth2;
|
||||||
|
var sentState = oauth2.state;
|
||||||
|
var redirectUrl = oauth2.redirectUrl;
|
||||||
|
var isValid, qp, arr;
|
||||||
|
|
||||||
|
if (/code|token|error/.test(window.location.hash)) {
|
||||||
|
qp = window.location.hash.substring(1);
|
||||||
|
} else {
|
||||||
|
qp = location.search.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
arr = qp.split("&");
|
||||||
|
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
|
||||||
|
qp = qp ? JSON.parse('{' + arr.join() + '}',
|
||||||
|
function (key, value) {
|
||||||
|
return key === "" ? value : decodeURIComponent(value);
|
||||||
|
}
|
||||||
|
) : {};
|
||||||
|
|
||||||
|
isValid = qp.state === sentState;
|
||||||
|
|
||||||
|
if ((
|
||||||
|
oauth2.auth.schema.get("flow") === "accessCode" ||
|
||||||
|
oauth2.auth.schema.get("flow") === "authorizationCode" ||
|
||||||
|
oauth2.auth.schema.get("flow") === "authorization_code"
|
||||||
|
) && !oauth2.auth.code) {
|
||||||
|
if (!isValid) {
|
||||||
|
oauth2.errCb({
|
||||||
|
authId: oauth2.auth.name,
|
||||||
|
source: "auth",
|
||||||
|
level: "warning",
|
||||||
|
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qp.code) {
|
||||||
|
delete oauth2.state;
|
||||||
|
oauth2.auth.code = qp.code;
|
||||||
|
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
||||||
|
} else {
|
||||||
|
let oauthErrorMsg;
|
||||||
|
if (qp.error) {
|
||||||
|
oauthErrorMsg = "["+qp.error+"]: " +
|
||||||
|
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
|
||||||
|
(qp.error_uri ? "More info: "+qp.error_uri : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
oauth2.errCb({
|
||||||
|
authId: oauth2.auth.name,
|
||||||
|
source: "auth",
|
||||||
|
level: "error",
|
||||||
|
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
|
||||||
|
}
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.readyState !== 'loading') {
|
||||||
|
run();
|
||||||
|
} else {
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
run();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
3
swagger/swagger-ui-bundle.js
Normal file
3
swagger/swagger-ui-bundle.js
Normal file
File diff suppressed because one or more lines are too long
1
swagger/swagger-ui-bundle.js.map
Normal file
1
swagger/swagger-ui-bundle.js.map
Normal file
File diff suppressed because one or more lines are too long
2
swagger/swagger-ui-es-bundle-core.js
Normal file
2
swagger/swagger-ui-es-bundle-core.js
Normal file
File diff suppressed because one or more lines are too long
3
swagger/swagger-ui-es-bundle.js
Normal file
3
swagger/swagger-ui-es-bundle.js
Normal file
File diff suppressed because one or more lines are too long
3
swagger/swagger-ui-standalone-preset.js
Normal file
3
swagger/swagger-ui-standalone-preset.js
Normal file
File diff suppressed because one or more lines are too long
1
swagger/swagger-ui-standalone-preset.js.map
Normal file
1
swagger/swagger-ui-standalone-preset.js.map
Normal file
File diff suppressed because one or more lines are too long
4
swagger/swagger-ui.css
Normal file
4
swagger/swagger-ui.css
Normal file
File diff suppressed because one or more lines are too long
1
swagger/swagger-ui.css.map
Normal file
1
swagger/swagger-ui.css.map
Normal file
File diff suppressed because one or more lines are too long
2
swagger/swagger-ui.js
Normal file
2
swagger/swagger-ui.js
Normal file
File diff suppressed because one or more lines are too long
1
swagger/swagger-ui.js.map
Normal file
1
swagger/swagger-ui.js.map
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user