Workin' Argo struct
This commit is contained in:
parent
a1d28f2563
commit
a0b1117075
@ -3,14 +3,15 @@ package conf
|
|||||||
import "sync"
|
import "sync"
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
MongoURL string
|
MongoURL string
|
||||||
Database string
|
Database string
|
||||||
LokiURL string
|
LokiURL string
|
||||||
NatsURL string
|
NatsURL string
|
||||||
ExecutionID string
|
ExecutionID string
|
||||||
|
PeerID string
|
||||||
Timeout int
|
Timeout int
|
||||||
WorkflowID string
|
WorkflowID string
|
||||||
Logs string
|
Logs string
|
||||||
}
|
}
|
||||||
|
|
||||||
var instance *Config
|
var instance *Config
|
||||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module oc-monitord
|
|||||||
go 1.22.0
|
go 1.22.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250113124812-6e5c87379649
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250204155113-a8e2445c103c
|
||||||
github.com/akamensky/argparse v1.4.0
|
github.com/akamensky/argparse v1.4.0
|
||||||
github.com/goraz/onion v0.1.3
|
github.com/goraz/onion v0.1.3
|
||||||
github.com/nats-io/nats-server/v2 v2.10.18
|
github.com/nats-io/nats-server/v2 v2.10.18
|
||||||
|
144
go.sum
144
go.sum
@ -136,6 +136,150 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20250113114256-11905339bb24 h1:Kc51xKbnyfeaf
|
|||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250113114256-11905339bb24/go.mod h1:VgWEn23ddKySWXrwPMhqtiBjTJnbm5t7yWjzfvNxbbI=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250113114256-11905339bb24/go.mod h1:VgWEn23ddKySWXrwPMhqtiBjTJnbm5t7yWjzfvNxbbI=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250113124812-6e5c87379649 h1:dmtrmNDdTR/2R3HjaIbPdu5LZViPzigwSjU207NXCxI=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250113124812-6e5c87379649 h1:dmtrmNDdTR/2R3HjaIbPdu5LZViPzigwSjU207NXCxI=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250113124812-6e5c87379649/go.mod h1:VgWEn23ddKySWXrwPMhqtiBjTJnbm5t7yWjzfvNxbbI=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250113124812-6e5c87379649/go.mod h1:VgWEn23ddKySWXrwPMhqtiBjTJnbm5t7yWjzfvNxbbI=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250113135241-a0f436b3e162 h1:oGP40P/uUngU7stnsRdx0jwxZGc+pzLzrMlUjEBSy0M=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250113135241-a0f436b3e162/go.mod h1:VgWEn23ddKySWXrwPMhqtiBjTJnbm5t7yWjzfvNxbbI=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250114071722-1c32cd2d12df h1:T52jgXQddoxwe+embR26Fwmz4G2jkl4QpYVHGtiLUNI=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250114071722-1c32cd2d12df/go.mod h1:VgWEn23ddKySWXrwPMhqtiBjTJnbm5t7yWjzfvNxbbI=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250114081637-918006302bb4 h1:AwCbDHjvUz9iQaF7hgYWyabVF/EzSSSk5bCNgntNJ6c=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250114081637-918006302bb4/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250114105339-b782248da741 h1:akAQLlcAXDtUhbNHbona9xJrHCzK9jxlvsDsEpVP1fg=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250114105339-b782248da741/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250114135055-1a4694c8913a h1:AxnecA1YKOZ81OKb1akK2Qc/0UNDUxdjSww7ALyehas=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250114135055-1a4694c8913a/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250115082026-ad69c0495144 h1:MZ90rw4SKL0dqL/Lb+7E54vkk9fb8W6X0UJo9UW/XBk=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250115082026-ad69c0495144/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250115095644-be3803039583 h1:6My1sqjvqgHnC4TlE7RsZQHC8AVhad0gZl8uOvLTM9o=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250115095644-be3803039583/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250115102820-0e0540af43d0 h1:AcHC2WIeHOSjz5xe7OsjMi39EevxdY2O/9q0VMkDRz0=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250115102820-0e0540af43d0/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250116091455-68f418928395 h1:u4myLPGqBbzprWHg6713k5a++4yiq1ujlVy7yrMkZ9g=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250116091455-68f418928395/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250116142544-a4a249bab828 h1:yMDBDTs7LECyueUfh0iug502GN8GodVpQSl/gZchUjU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250116142544-a4a249bab828/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117081640-450fab437cb7 h1:SV9U48sR09cNRl48489lQHrrKJFtTMQoQcRhmtsLTYQ=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117081640-450fab437cb7/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117090737-b990fe42d375 h1:UsPWfbVgvUcOC3BtD8B9dUQfv/FnRF4IZGrYxUJr1iM=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117090737-b990fe42d375/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117100508-d44fb976e4ff h1:GaLrVn6ame6BV7pfUB2xeHCCJLBECRiCCpPj6zteL+s=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117100508-d44fb976e4ff/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117121920-ed787683f47b h1:3wap+dPPplJkDglE5toKfdFUmjobAeIJWdiRtCQ3xkQ=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117121920-ed787683f47b/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117124801-e5c7dbe4cb96 h1:opQ/Uku27DOKAqDcKC9k6J9H5Tj9bNyKdHnJnD3U850=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117124801-e5c7dbe4cb96/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117135417-c63a1fef6c48 h1:dEebv8ZV5rt6BYPkcK6HOts+OPqkSxkKp5zn1lCq1vs=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117135417-c63a1fef6c48/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117152246-b85ca8674b27 h1:QEIj90eIoYsjs1uekbI3Nu48KDWmzGV7ugcr9agJbYI=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250117152246-b85ca8674b27/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250120123706-58b36f282344 h1:MPt8BhrbMJiMa4KDWqBUvdrlone7UxgIgZ5PW4du0Ek=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250120123706-58b36f282344/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250120124939-67b8215adf79 h1:9Y+KJlzy5jHhrd4b44pNEBjSJKnIyvlSQ5Mbj1zcXbA=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250120124939-67b8215adf79/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250120143509-305f2605030d h1:f1tpLADIAbwTKxN62csH+v2Fe0q1eQ7dYIDhPl1GZ8I=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250120143509-305f2605030d/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250121080257-de585a723426 h1:49cuCsDsBE6ZrvqMh6d48ZynpPyEpkw1LtC0nMQnvEU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250121080257-de585a723426/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250121083541-0d83885b9b5e h1:yh2tiTxuQbrdgCePREyMewPr8Btdacpw6vo7ymmqf7Y=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250121083541-0d83885b9b5e/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250121101118-bc12fb53be23 h1:oOSJA8w33aJ2TlMRuR7bU/rme/IYSBcVjrb6gE/jwSw=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250121101118-bc12fb53be23/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250121105544-bf5a16f41bea h1:X9YiXv2GSLT6jotS3C/JvvdYBLtxgKI8OV60ndJzjXk=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250121105544-bf5a16f41bea/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250121131007-745bb58c593e h1:rHbooeLrsMvIYj5nHc3MK8NVEh9v5edFBCkOxeRoYjs=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250121131007-745bb58c593e/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250121160438-67ebeca1f489 h1:XwPLFaKjP0o6ZuKnj5aDJ9hIBlX8giNS9BB78uIH0g0=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250121160438-67ebeca1f489/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122080653-67940296d255 h1:VFlxjrbks8pDzoZ40lnyHD5qVyEMAIfEAmY2w4wBAE8=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122080653-67940296d255/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122090736-8ab313e6cbd8 h1:u7Rt0tQMCzylFPyMcO5uNQ8041K80cM0BQNbBDbjAj0=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122090736-8ab313e6cbd8/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122101635-2a93b17d71d8 h1:AvthXY1/mrB4aeQpoj84ewVCdIYYemwn9WydYJ+9hyw=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122101635-2a93b17d71d8/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122110438-062c1afe8568 h1:pk7Gqa1yEwl5ASc9wJNjxJ+1XfTXYSwDvsxB3KOHWoo=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122110438-062c1afe8568/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122121814-ed1e76105250 h1:TwCz7oXB7diECiM/kadwDZ78iM8E8ka2ShKs/PzdszA=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122121814-ed1e76105250/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122135342-4be954a6f359 h1:x5dGOGYgdDhSeYtAkWeNlWQLU24yv8BUpwx1Idc9+ME=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122135342-4be954a6f359/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122140340-9c71730d9cb7 h1:oAkv9IOuiP71VO/plOkPHaPk9X3ELfnGdSz2cctLnGw=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122140340-9c71730d9cb7/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122153005-0e798dac5081 h1:P/WDRzkAJHhPuZZbU2VmVqSJ6AcMN/ia/pPZ60MpRfo=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250122153005-0e798dac5081/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123074822-df04133551e4 h1:ayV2U6VUUJXdBE2AGuRuwTKr7WqIycmVgEMv8v/KlGU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123074822-df04133551e4/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123082727-8cba10c4fe29 h1:zt0AA0GddWtbgupsvFvNAozrGMP0FISHnjSmsp3Ihgc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123082727-8cba10c4fe29/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123094950-d15fdac27bde h1:Yjr0WPiR3dMg+H8EIO4GzqohRZBvGh/h4ysx5n8wCZw=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123094950-d15fdac27bde/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123103535-2205ac9b5819 h1:y/opEsKeo7G5Os2RWd7zF5i5DU4neDLt6fUq2hSW66U=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123103535-2205ac9b5819/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123114959-49e495f062eb h1:9FDB2xUhO+PFkb1mhNq+vItyfW/Jb0KjBRDEDPqPcno=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123114959-49e495f062eb/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123134717-db6049bab345 h1:OW5TLnNhNxJCkhMXUy5d9VSOgEGNFc9+uA3thyPuRA4=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123134717-db6049bab345/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123140834-c1888f89218f h1:iNqXYlnTh4nnfuVN/NObIJO5g9Mu3Mi9yFGmNFwO1Jk=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250123140834-c1888f89218f/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250124095557-97d466818af0 h1:v8Fj897AF5l8icSm2FE0E2tkl96eJI43Zr4UHIUkL6Y=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250124095557-97d466818af0/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250127080547-fbb55e64dcf4 h1:s6+5sTIeR86N+9oK3uXItlP0L1SgKCwMNQFU6LERDU4=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250127080547-fbb55e64dcf4/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250127083756-68bacf5da410 h1:b+dzulgEl+a7BudsqCkgBg/1aEqo8/1WpGs+WGZHznE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250127083756-68bacf5da410/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250127110938-1ad9ce09cb35 h1:PWlFiCaAHTUDuwOf84hA4BDivEA3FU+DDH7dBg9IPho=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250127110938-1ad9ce09cb35/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250127131512-7ca360be6aa4 h1:8y8I+hmSuUPV2dt/qw6d2TY/YRLXvZp0zE9iSwR3qv4=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250127131512-7ca360be6aa4/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250127134257-8b03df7923bd h1:eylhA0MziFMzY+kfXy2tnZEHDWIXCh/kPDLyBG2OC5E=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250127134257-8b03df7923bd/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250127150345-db85d1a48b73 h1:SNwsmEyaHrnoN7/IBathlA/HI/y4D2IBJjZEdtUC7Ew=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250127150345-db85d1a48b73/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250128131916-598774b0b197 h1:tAi5pznkPDjCFO81EhvS8Djx1e7iz4D2e72lxegRVmQ=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250128131916-598774b0b197/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250129073743-74a1f66d26c2 h1:ScjLqkn82u+on8CXnfgi52UZqddR879WlUtiq9qQOdo=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250129073743-74a1f66d26c2/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250129100135-330768490a61 h1:afATt4OzRndXApO1Xqn9PeKohW5G2nhqvptZkE2pML8=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250129100135-330768490a61/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250129133324-ede2d5fd5322 h1:d0/n7kJZNG6QKdI5ySqYGe3nYYOKmko76ysjlZA30Dk=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250129133324-ede2d5fd5322/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250129143004-df2c38199cf0 h1:8cIJxCeVHbefpa7oBZPeFUAa7Mmtiw93Z1xMa9Qf/wk=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250129143004-df2c38199cf0/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250129154925-84d20c52fa1c h1:6+KdDssQyPZSCmtiBrlygHIAt2yhewx3rz/SPEfsYnI=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250129154925-84d20c52fa1c/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250130072403-826d7586b127 h1:wYLo29accEk0anP8eLjBKbDyYGLFKg4Qp41NvCb2JsQ=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250130072403-826d7586b127/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250130084513-787c01b4be1c h1:3TEloYSf4k1o9tkEo5T3sES+qZcJBsdR82o+T81SC3A=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250130084513-787c01b4be1c/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250130101134-107ce2580128 h1:AElHp4SeiVmMiyCta9r8JOpSYMAS0To/fLK6eaBz1PU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250130101134-107ce2580128/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250130130847-976a5cedcb5f h1:0buFXek+V4E4rIGBEygLXpw34I50yAGqTIAOyTgZwsA=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250130130847-976a5cedcb5f/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250131073800-3ec0d554edad h1:Ey6yORB8TOa+PkMpNhH0tayZuZ6FwyJ59vZM4BRGHnY=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250131073800-3ec0d554edad/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250131082340-892bd93471aa h1:53a/yqBAVkNpeAaCqxHx3FWC0wV5XK/dhooR3f0Kp8g=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250131082340-892bd93471aa/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250131100142-b2113bff62fa h1:S7nsqFotIeXSPJqipNW6wB3VsfYhFrWcZIR8mX6aJg0=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250131100142-b2113bff62fa/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250131110730-a2f2d0ebef72 h1:0EUj84bzUWvaH8egQkjH1xQ+HoyX9EZqtokNosYywgU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250131110730-a2f2d0ebef72/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250131153610-6807614ac86b h1:/SjZVsLeH8sXopUeR3xB7wygJvIyA2V2uS+GsfPFysE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250131153610-6807614ac86b/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250203105249-64bea2a66e35 h1:5Zkm2tPQ60l2oMdrf3/uC1mWOCU+ti77d0k9y/AW1z8=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250203105249-64bea2a66e35/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250203113830-275bd56fe64c h1:4EW1OEHuRjH9B3LhQEvOLp3qPxnU4kDBwgKzy7KNlS4=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250203113830-275bd56fe64c/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250203124514-14977c7b2c39 h1:XW7Hny4W/2ClAZR2Wi9KRvLTH/pjmwpgXiwM+fDsy50=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250203124514-14977c7b2c39/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250203143322-22d15fe395e8 h1:OWBLh52Ee4Txs0PY4bMlfRbaTbfNNR/ndj2J+RGrR6k=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250203143322-22d15fe395e8/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250204080055-bf114b39b7d5 h1:rsOMNER+ZIIt/as3bOU2lJe+MbCCR5x1iR/XyZYmuKU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250204080055-bf114b39b7d5/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250204091410-2ccb57ffb050 h1:NdKJD+hbAyDaUfRkdtMUZLasR1d/BGyEfCvuozTso+Y=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250204091410-2ccb57ffb050/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250204110709-3061df4f13da h1:Mx3vR5r21H0zX+B0yaQOeOn3hvWJUrdy0DFLI+RAH1I=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250204110709-3061df4f13da/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250204134321-69bf9518661e h1:etAdc6jOnpm49RFs2Z8R7zzwfP/uGN6eQAmMGVqTEnc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250204134321-69bf9518661e/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250204155113-a8e2445c103c h1:wNM/SweaGy+Wz4KV3+1wpLYgtDOSDK+WO6564TCGDjE=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250204155113-a8e2445c103c/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
|
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
|
||||||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
|
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
|
||||||
|
34
main.go
34
main.go
@ -21,6 +21,7 @@ import (
|
|||||||
"cloud.o-forge.io/core/oc-lib/logs"
|
"cloud.o-forge.io/core/oc-lib/logs"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/tools"
|
||||||
|
|
||||||
"github.com/akamensky/argparse"
|
"github.com/akamensky/argparse"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@ -38,7 +39,6 @@ import (
|
|||||||
var logger zerolog.Logger
|
var logger zerolog.Logger
|
||||||
var wf_logger zerolog.Logger
|
var wf_logger zerolog.Logger
|
||||||
var parser argparse.Parser
|
var parser argparse.Parser
|
||||||
var monitorLocal bool
|
|
||||||
var workflowName string
|
var workflowName string
|
||||||
|
|
||||||
const defaultConfigFile = "/etc/oc/ocmonitord_conf.json"
|
const defaultConfigFile = "/etc/oc/ocmonitord_conf.json"
|
||||||
@ -48,7 +48,6 @@ func main() {
|
|||||||
|
|
||||||
os.Setenv("test_service", "true") // Only for service demo, delete before merging on main
|
os.Setenv("test_service", "true") // Only for service demo, delete before merging on main
|
||||||
|
|
||||||
monitorLocal = false
|
|
||||||
// Test if monitor is launched outside (with parameters) or in a k8s environment (env variables sets)
|
// Test if monitor is launched outside (with parameters) or in a k8s environment (env variables sets)
|
||||||
if os.Getenv("KUBERNETES_SERVICE_HOST") == "" {
|
if os.Getenv("KUBERNETES_SERVICE_HOST") == "" {
|
||||||
// Not in a k8s environment, get conf from parameters
|
// Not in a k8s environment, get conf from parameters
|
||||||
@ -58,7 +57,6 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
// Executed in a k8s environment
|
// Executed in a k8s environment
|
||||||
fmt.Println("Executes inside a k8s")
|
fmt.Println("Executes inside a k8s")
|
||||||
monitorLocal = true
|
|
||||||
loadConfig(true, nil)
|
loadConfig(true, nil)
|
||||||
}
|
}
|
||||||
oclib.InitDaemon("oc-monitord")
|
oclib.InitDaemon("oc-monitord")
|
||||||
@ -89,7 +87,7 @@ func main() {
|
|||||||
// // create argo
|
// // create argo
|
||||||
new_wf := workflow_builder.WorflowDB{}
|
new_wf := workflow_builder.WorflowDB{}
|
||||||
|
|
||||||
err := new_wf.LoadFrom(conf.GetConfig().WorkflowID)
|
err := new_wf.LoadFrom(conf.GetConfig().WorkflowID, conf.GetConfig().PeerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error().Msg("Could not retrieve workflow " + conf.GetConfig().WorkflowID + " from oc-catalog API")
|
logger.Error().Msg("Could not retrieve workflow " + conf.GetConfig().WorkflowID + " from oc-catalog API")
|
||||||
}
|
}
|
||||||
@ -112,7 +110,7 @@ func main() {
|
|||||||
|
|
||||||
// Return the Workflow ID associated to a workflow execution object
|
// Return the Workflow ID associated to a workflow execution object
|
||||||
func getWorkflowId(exec_id string) string {
|
func getWorkflowId(exec_id string) string {
|
||||||
res := oclib.NewRequest(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), "", "", []string{}, nil).LoadOne(exec_id)
|
res := oclib.NewRequest(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), "", conf.GetConfig().PeerID, []string{}, nil).LoadOne(exec_id)
|
||||||
if res.Code != 200 {
|
if res.Code != 200 {
|
||||||
logger.Error().Msg("Could not retrieve workflow ID from execution ID " + exec_id)
|
logger.Error().Msg("Could not retrieve workflow ID from execution ID " + exec_id)
|
||||||
return ""
|
return ""
|
||||||
@ -145,7 +143,6 @@ func executeWorkflow(argo_file_path string, stepMax int) {
|
|||||||
wf_logger.Error().Msg(err.Error() + bufio.NewScanner(stderr).Text())
|
wf_logger.Error().Msg(err.Error() + bufio.NewScanner(stderr).Text())
|
||||||
updateStatus("fatal")
|
updateStatus("fatal")
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,6 +171,10 @@ func logWorkflow(argo_file_path string, stepMax int, pipe io.ReadCloser, wg *syn
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error().Msg("Could not create watch log")
|
logger.Error().Msg("Could not create watch log")
|
||||||
}
|
}
|
||||||
|
if strings.Contains(strings.ToLower(strings.Join(current_watch.Logs, " ")), "error") || strings.Contains(strings.ToLower(strings.ToLower(strings.Join(current_watch.Logs, " "))), "err") {
|
||||||
|
current_watch.Status = "Failed"
|
||||||
|
}
|
||||||
|
|
||||||
if current_watch.Status == "Failed" {
|
if current_watch.Status == "Failed" {
|
||||||
wf_logger.Error().Msg(string(jsonified))
|
wf_logger.Error().Msg(string(jsonified))
|
||||||
} else {
|
} else {
|
||||||
@ -188,13 +189,8 @@ func logWorkflow(argo_file_path string, stepMax int, pipe io.ReadCloser, wg *syn
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadConfig(is_k8s bool, parser *argparse.Parser) {
|
func loadConfig(is_k8s bool, parser *argparse.Parser) {
|
||||||
|
|
||||||
var o *onion.Onion
|
var o *onion.Onion
|
||||||
|
|
||||||
o = initOnion(o)
|
o = initOnion(o)
|
||||||
// These variables can only be retrieved in the onion
|
|
||||||
// Variables that don't depend on the environment (from conf file), can be loaded after
|
|
||||||
// We can't use underscore in the env variable names because it's the delimitor with OCMONITOR too
|
|
||||||
setConf(is_k8s, o, parser)
|
setConf(is_k8s, o, parser)
|
||||||
|
|
||||||
if !IsValidUUID(conf.GetConfig().ExecutionID) {
|
if !IsValidUUID(conf.GetConfig().ExecutionID) {
|
||||||
@ -212,6 +208,7 @@ func setConf(is_k8s bool, o *onion.Onion, parser *argparse.Parser) {
|
|||||||
logger.Error().Msg("Could not parse timeout, using default value")
|
logger.Error().Msg("Could not parse timeout, using default value")
|
||||||
}
|
}
|
||||||
conf.GetConfig().ExecutionID = o.GetString("workflow")
|
conf.GetConfig().ExecutionID = o.GetString("workflow")
|
||||||
|
conf.GetConfig().PeerID = o.GetString("peer")
|
||||||
mongo := o.GetStringDefault("mongourl", "mongodb://127.0.0.1:27017")
|
mongo := o.GetStringDefault("mongourl", "mongodb://127.0.0.1:27017")
|
||||||
db := o.GetStringDefault("database", "DC_myDC")
|
db := o.GetStringDefault("database", "DC_myDC")
|
||||||
|
|
||||||
@ -220,6 +217,7 @@ func setConf(is_k8s bool, o *onion.Onion, parser *argparse.Parser) {
|
|||||||
} else {
|
} else {
|
||||||
url := parser.String("u", "url", &argparse.Options{Required: true, Default: "http://127.0.0.1:3100", Help: "Url to the Loki database logs will be sent to"})
|
url := parser.String("u", "url", &argparse.Options{Required: true, Default: "http://127.0.0.1:3100", Help: "Url to the Loki database logs will be sent to"})
|
||||||
execution := parser.String("e", "execution", &argparse.Options{Required: true, Help: "Execution ID of the workflow to request from oc-catalog API"})
|
execution := parser.String("e", "execution", &argparse.Options{Required: true, Help: "Execution ID of the workflow to request from oc-catalog API"})
|
||||||
|
peer := parser.String("p", "peer", &argparse.Options{Required: false, Default: "", Help: "Peer ID of the workflow to request from oc-catalog API"})
|
||||||
mongo := parser.String("m", "mongo", &argparse.Options{Required: true, Default: "mongodb://127.0.0.1:27017", Help: "URL to reach the MongoDB"})
|
mongo := parser.String("m", "mongo", &argparse.Options{Required: true, Default: "mongodb://127.0.0.1:27017", Help: "URL to reach the MongoDB"})
|
||||||
db := parser.String("d", "database", &argparse.Options{Required: true, Default: "DC_myDC", Help: "Name of the database to query in MongoDB"})
|
db := parser.String("d", "database", &argparse.Options{Required: true, Default: "DC_myDC", Help: "Name of the database to query in MongoDB"})
|
||||||
timeout := parser.Int("t", "timeout", &argparse.Options{Required: false, Default: -1, Help: "Timeout for the execution of the workflow"})
|
timeout := parser.Int("t", "timeout", &argparse.Options{Required: false, Default: -1, Help: "Timeout for the execution of the workflow"})
|
||||||
@ -228,14 +226,13 @@ func setConf(is_k8s bool, o *onion.Onion, parser *argparse.Parser) {
|
|||||||
fmt.Println(parser.Usage(err))
|
fmt.Println(parser.Usage(err))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.GetConfig().Logs = "debug"
|
conf.GetConfig().Logs = "debug"
|
||||||
|
|
||||||
conf.GetConfig().LokiURL = *url
|
conf.GetConfig().LokiURL = *url
|
||||||
conf.GetConfig().MongoURL = *mongo
|
conf.GetConfig().MongoURL = *mongo
|
||||||
conf.GetConfig().Database = *db
|
conf.GetConfig().Database = *db
|
||||||
conf.GetConfig().Timeout = *timeout
|
conf.GetConfig().Timeout = *timeout
|
||||||
conf.GetConfig().ExecutionID = *execution
|
conf.GetConfig().ExecutionID = *execution
|
||||||
|
conf.GetConfig().PeerID = *peer
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -293,11 +290,10 @@ func updateStatus(status string) {
|
|||||||
|
|
||||||
wf_exec := &workflow_execution.WorkflowExecutions{AbstractObject: utils.AbstractObject{UUID: conf.GetConfig().ExecutionID}}
|
wf_exec := &workflow_execution.WorkflowExecutions{AbstractObject: utils.AbstractObject{UUID: conf.GetConfig().ExecutionID}}
|
||||||
wf_exec.ArgoStatusToState(status)
|
wf_exec.ArgoStatusToState(status)
|
||||||
|
_, _, err := workflow_execution.NewAccessor(&tools.APIRequest{
|
||||||
res := oclib.NewRequest(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), "", "", []string{}, nil).UpdateOne(
|
PeerID: conf.GetConfig().PeerID,
|
||||||
wf_exec.Serialize(wf_exec), exec_id)
|
}).UpdateOne(wf_exec, exec_id)
|
||||||
|
if err != nil {
|
||||||
if res.Code != 200 {
|
logger.Error().Msg("Could not update status for workflow execution " + exec_id + err.Error())
|
||||||
logger.Error().Msg("Could not update status for workflow execution " + exec_id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package models
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/common/models"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -59,11 +60,25 @@ type TemplateMetadata struct {
|
|||||||
Labels map[string]string `yaml:"labels,omitempty"`
|
Labels map[string]string `yaml:"labels,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Key struct {
|
||||||
|
Key string `yaml:"key"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Artifact struct {
|
||||||
|
Name string `yaml:"name"`
|
||||||
|
Path string `yaml:"path"`
|
||||||
|
S3 *Key `yaml:"s3,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type InOut struct {
|
||||||
|
Parameters []Parameter `yaml:"parameters"`
|
||||||
|
Artifacts []Artifact `yaml:"artifacts,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type Template struct {
|
type Template struct {
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
Inputs struct {
|
Inputs InOut `yaml:"inputs,omitempty"`
|
||||||
Parameters []Parameter `yaml:"parameters"`
|
Outputs InOut `yaml:"outputs,omitempty"`
|
||||||
} `yaml:"inputs,omitempty"`
|
|
||||||
Container Container `yaml:"container,omitempty"`
|
Container Container `yaml:"container,omitempty"`
|
||||||
Dag *Dag `yaml:"dag,omitempty"`
|
Dag *Dag `yaml:"dag,omitempty"`
|
||||||
Metadata TemplateMetadata `yaml:"metadata,omitempty"`
|
Metadata TemplateMetadata `yaml:"metadata,omitempty"`
|
||||||
@ -71,39 +86,43 @@ type Template struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (template *Template) CreateContainer(processing *resources.ProcessingResource, dag *Dag) {
|
func (template *Template) CreateContainer(processing *resources.ProcessingResource, dag *Dag) {
|
||||||
container := Container{Image: processing.Container.Image}
|
instance := processing.GetSelectedInstance()
|
||||||
|
if instance == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
inst := instance.(*resources.ProcessingInstance)
|
||||||
|
container := Container{Image: inst.Access.Container.Image}
|
||||||
if container.Image == "" {
|
if container.Image == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
container.Command = []string{"sh", "-c"} // all is bash
|
container.Command = []string{"sh", "-c"} // all is bash
|
||||||
for name := range processing.Container.Env {
|
for _, v := range inst.Env {
|
||||||
template.Inputs.Parameters = append(template.Inputs.Parameters, Parameter{Name: name})
|
template.Inputs.Parameters = append(template.Inputs.Parameters, Parameter{Name: v.Name})
|
||||||
}
|
}
|
||||||
for _, a := range strings.Split(processing.Container.Args, " ") {
|
for _, v := range inst.Inputs {
|
||||||
container.Args = append(container.Args, template.replacePerEnv(a, processing.Container.Env, dag))
|
template.Inputs.Parameters = append(template.Inputs.Parameters, Parameter{Name: v.Name})
|
||||||
}
|
}
|
||||||
cmd := strings.ReplaceAll(processing.Container.Command, container.Image, "")
|
for _, v := range inst.Inputs {
|
||||||
container.Args = []string{cmd + " " + strings.Join(container.Args, " ")}
|
template.Outputs.Parameters = append(template.Inputs.Parameters, Parameter{Name: v.Name})
|
||||||
|
}
|
||||||
|
cmd := strings.ReplaceAll(inst.Access.Container.Command, container.Image, "")
|
||||||
|
for _, a := range strings.Split(cmd, " ") {
|
||||||
|
container.Args = append(container.Args, template.ReplacePerEnv(a, inst.Env))
|
||||||
|
}
|
||||||
|
for _, a := range strings.Split(inst.Access.Container.Args, " ") {
|
||||||
|
container.Args = append(container.Args, template.ReplacePerEnv(a, inst.Env))
|
||||||
|
}
|
||||||
|
container.Args = []string{strings.Join(container.Args, " ")}
|
||||||
template.Container = container
|
template.Container = container
|
||||||
}
|
}
|
||||||
|
|
||||||
func (template *Template) replacePerEnv(arg string, envs map[string]string, dag *Dag) string {
|
func (template *Template) ReplacePerEnv(arg string, envs []models.Param) string {
|
||||||
for k, v := range envs {
|
for _, v := range envs {
|
||||||
if strings.Contains(arg, k) {
|
if strings.Contains(arg, v.Name) {
|
||||||
value := v
|
value := "{{ inputs.parameters." + v.Name + " }}"
|
||||||
for _, task := range dag.Tasks {
|
arg = strings.ReplaceAll(arg, v.Name, value)
|
||||||
if task.Name == template.Name {
|
arg = strings.ReplaceAll(arg, "$"+v.Name, value)
|
||||||
for _, p := range task.Arguments.Parameters {
|
arg = strings.ReplaceAll(arg, "$", "")
|
||||||
if p.Name == k {
|
|
||||||
value = p.Value
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
arg = strings.ReplaceAll(arg, "$"+k, value)
|
|
||||||
arg = strings.ReplaceAll(arg, "${"+k+"}", value)
|
|
||||||
arg = strings.ReplaceAll(arg, k, value)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return arg
|
return arg
|
||||||
|
BIN
oc-monitord
BIN
oc-monitord
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
@ -8,14 +8,13 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
. "oc-monitord/models"
|
. "oc-monitord/models"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
oclib "cloud.o-forge.io/core/oc-lib"
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/common/enum"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||||
w "cloud.o-forge.io/core/oc-lib/models/workflow"
|
w "cloud.o-forge.io/core/oc-lib/models/workflow"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/workflow/graph"
|
|
||||||
"github.com/nwtgck/go-fakelish"
|
"github.com/nwtgck/go-fakelish"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
@ -39,14 +38,6 @@ type Workflow struct {
|
|||||||
Spec Spec `yaml:"spec,omitempty"`
|
Spec Spec `yaml:"spec,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Workflow) setDag(dag *Dag) {
|
|
||||||
for _, t := range b.Spec.Templates {
|
|
||||||
if t.Name == "dag" {
|
|
||||||
t.Dag = dag
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *Workflow) getDag() *Dag {
|
func (b *Workflow) getDag() *Dag {
|
||||||
for _, t := range b.Spec.Templates {
|
for _, t := range b.Spec.Templates {
|
||||||
if t.Name == "dag" {
|
if t.Name == "dag" {
|
||||||
@ -65,8 +56,10 @@ type Spec struct {
|
|||||||
Timeout int `yaml:"activeDeadlineSeconds,omitempty"`
|
Timeout int `yaml:"activeDeadlineSeconds,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: found on a processing instance linked to storage
|
||||||
|
// add s3, gcs, azure, etc if needed on a link between processing and storage
|
||||||
func (b *ArgoBuilder) CreateDAG(write bool) (string, int, []string, []string, error) {
|
func (b *ArgoBuilder) CreateDAG(write bool) (string, int, []string, []string, error) {
|
||||||
|
fmt.Println("Creating DAG", b.OriginWorkflow.Graph.Items)
|
||||||
// handle services by checking if there is only one processing with hostname and port
|
// handle services by checking if there is only one processing with hostname and port
|
||||||
firstItems, lastItems, volumes := b.createTemplates()
|
firstItems, lastItems, volumes := b.createTemplates()
|
||||||
b.createVolumes(volumes)
|
b.createVolumes(volumes)
|
||||||
@ -104,14 +97,17 @@ func (b *ArgoBuilder) createTemplates() ([]string, []string, []VolumeMount) {
|
|||||||
volumes := []VolumeMount{}
|
volumes := []VolumeMount{}
|
||||||
firstItems := []string{}
|
firstItems := []string{}
|
||||||
lastItems := []string{}
|
lastItems := []string{}
|
||||||
for _, comp := range b.OriginWorkflow.ProcessingResources {
|
items := b.OriginWorkflow.GetGraphItems(b.OriginWorkflow.Graph.IsProcessing)
|
||||||
if comp.Container != nil {
|
fmt.Println("Creating templates", len(items))
|
||||||
volumes, firstItems, lastItems = b.createArgoTemplates(
|
for _, item := range b.OriginWorkflow.GetGraphItems(b.OriginWorkflow.Graph.IsProcessing) {
|
||||||
comp.UUID, comp, volumes, firstItems, lastItems)
|
instance := item.Processing.GetSelectedInstance()
|
||||||
} else {
|
fmt.Println("Creating template for", item.Processing.GetName(), instance)
|
||||||
logger.Error().Msg("Not enough configuration setup, template can't be created : " + comp.GetName())
|
if instance == nil || instance.(*resources.ProcessingInstance).Access == nil && instance.(*resources.ProcessingInstance).Access.Container != nil {
|
||||||
|
logger.Error().Msg("Not enough configuration setup, template can't be created : " + item.Processing.GetName())
|
||||||
return firstItems, lastItems, volumes
|
return firstItems, lastItems, volumes
|
||||||
}
|
}
|
||||||
|
volumes, firstItems, lastItems = b.createArgoTemplates(
|
||||||
|
item.ID, item.Processing, volumes, firstItems, lastItems)
|
||||||
}
|
}
|
||||||
firstWfTasks := map[string][]string{}
|
firstWfTasks := map[string][]string{}
|
||||||
latestWfTasks := map[string][]string{}
|
latestWfTasks := map[string][]string{}
|
||||||
@ -187,6 +183,7 @@ func (b *ArgoBuilder) createArgoTemplates(id string,
|
|||||||
lastItems []string) ([]VolumeMount, []string, []string) {
|
lastItems []string) ([]VolumeMount, []string, []string) {
|
||||||
_, firstItems, lastItems = b.addTaskToArgo(b.Workflow.getDag(), id, processing, firstItems, lastItems)
|
_, firstItems, lastItems = b.addTaskToArgo(b.Workflow.getDag(), id, processing, firstItems, lastItems)
|
||||||
template := &Template{Name: getArgoName(processing.GetName(), id)}
|
template := &Template{Name: getArgoName(processing.GetName(), id)}
|
||||||
|
fmt.Println("Creating template for", template.Name)
|
||||||
template.CreateContainer(processing, b.Workflow.getDag())
|
template.CreateContainer(processing, b.Workflow.getDag())
|
||||||
// get datacenter from the processing
|
// get datacenter from the processing
|
||||||
if processing.IsService {
|
if processing.IsService {
|
||||||
@ -194,17 +191,39 @@ func (b *ArgoBuilder) createArgoTemplates(id string,
|
|||||||
template.Metadata.Labels = make(map[string]string)
|
template.Metadata.Labels = make(map[string]string)
|
||||||
template.Metadata.Labels["app"] = "oc-service-" + processing.GetName() // Construct the template for the k8s service and add a link in graph between k8s service and processing
|
template.Metadata.Labels["app"] = "oc-service-" + processing.GetName() // Construct the template for the k8s service and add a link in graph between k8s service and processing
|
||||||
}
|
}
|
||||||
storages := b.OriginWorkflow.GetByRelatedProcessing(id, b.OriginWorkflow.IsStorage)
|
related := b.OriginWorkflow.GetByRelatedProcessing(id, b.OriginWorkflow.Graph.IsStorage)
|
||||||
for _, storage := range storages {
|
for _, r := range related {
|
||||||
if storage.(*resources.StorageResource).SelectedInstanceIndex < 0 {
|
storage := r.Node.(*resources.StorageResource)
|
||||||
continue
|
for _, linkToStorage := range r.Links {
|
||||||
|
for _, rw := range linkToStorage.StorageLinkInfos {
|
||||||
|
art := Artifact{Path: template.ReplacePerEnv(rw.Source, linkToStorage.Env)}
|
||||||
|
if rw.Write {
|
||||||
|
art.Name = storage.GetName() + "-" + rw.Destination + "-input-write"
|
||||||
|
} else {
|
||||||
|
art.Name = storage.GetName() + "-" + rw.Destination + "-input-read"
|
||||||
|
}
|
||||||
|
if storage.StorageType == enum.S3 {
|
||||||
|
art.S3 = &Key{
|
||||||
|
Key: template.ReplacePerEnv(rw.Destination+"/"+rw.FileName, linkToStorage.Env),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if rw.Write {
|
||||||
|
template.Outputs.Artifacts = append(template.Inputs.Artifacts, art)
|
||||||
|
} else {
|
||||||
|
template.Inputs.Artifacts = append(template.Outputs.Artifacts, art)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
s := storage.(*resources.StorageResource).Instances[storage.(*resources.StorageResource).SelectedInstanceIndex]
|
index := 0
|
||||||
|
if storage.SelectedInstanceIndex != nil && (*storage.SelectedInstanceIndex) >= 0 {
|
||||||
|
index = *storage.SelectedInstanceIndex
|
||||||
|
}
|
||||||
|
s := storage.Instances[index]
|
||||||
if s.Local {
|
if s.Local {
|
||||||
volumes = template.Container.AddVolumeMount(VolumeMount{
|
volumes = template.Container.AddVolumeMount(VolumeMount{
|
||||||
Name: strings.ReplaceAll(strings.ToLower(storage.GetName()), " ", "-"),
|
Name: strings.ReplaceAll(strings.ToLower(storage.GetName()), " ", "-"),
|
||||||
MountPath: s.Source,
|
MountPath: s.Source,
|
||||||
Storage: storage.(*resources.StorageResource),
|
Storage: storage,
|
||||||
}, volumes)
|
}, volumes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,11 +234,24 @@ func (b *ArgoBuilder) addTaskToArgo(dag *Dag, graphItemID string, processing *re
|
|||||||
firstItems []string, lastItems []string) (*Dag, []string, []string) {
|
firstItems []string, lastItems []string) (*Dag, []string, []string) {
|
||||||
unique_name := getArgoName(processing.GetName(), graphItemID)
|
unique_name := getArgoName(processing.GetName(), graphItemID)
|
||||||
step := Task{Name: unique_name, Template: unique_name}
|
step := Task{Name: unique_name, Template: unique_name}
|
||||||
if processing.Container != nil {
|
instance := processing.GetSelectedInstance()
|
||||||
for name, value := range processing.Container.Env {
|
if instance != nil {
|
||||||
|
for _, value := range instance.(*resources.ProcessingInstance).Env {
|
||||||
step.Arguments.Parameters = append(step.Arguments.Parameters, Parameter{
|
step.Arguments.Parameters = append(step.Arguments.Parameters, Parameter{
|
||||||
Name: name,
|
Name: value.Name,
|
||||||
Value: b.affectVariableEnv(value, b.OriginWorkflow.Graph),
|
Value: value.Value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
for _, value := range instance.(*resources.ProcessingInstance).Inputs {
|
||||||
|
step.Arguments.Parameters = append(step.Arguments.Parameters, Parameter{
|
||||||
|
Name: value.Name,
|
||||||
|
Value: value.Value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
for _, value := range instance.(*resources.ProcessingInstance).Outputs {
|
||||||
|
step.Arguments.Parameters = append(step.Arguments.Parameters, Parameter{
|
||||||
|
Name: value.Name,
|
||||||
|
Value: value.Value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -241,32 +273,13 @@ func (b *ArgoBuilder) addTaskToArgo(dag *Dag, graphItemID string, processing *re
|
|||||||
return dag, firstItems, lastItems
|
return dag, firstItems, lastItems
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *ArgoBuilder) affectVariableEnv(envVar string, graph *graph.Graph) string {
|
|
||||||
var myExp = regexp.MustCompile(`(\{\{.*\}\})`) // regex to find all the variables in the command
|
|
||||||
matches := myExp.FindAllString(envVar, -1) // find all the variables in the command
|
|
||||||
for _, match := range matches { // for each variable in the command
|
|
||||||
splitted := strings.Split( // split the variable to get the inout and the vars only
|
|
||||||
strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(match, "{{", ""), "}}", ""), " ", ""), "_")
|
|
||||||
if len(splitted) < 3 { // if the variable is not well formatted, we skip it
|
|
||||||
logger.Error().Msgf("The variable %v is not well formatted", match)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
graphItemID := splitted[1] // graphitemid is the id of the object
|
|
||||||
vars := splitted[2] // vars is the name of the variable of the object
|
|
||||||
_, obj := graph.GetResource(graphItemID)
|
|
||||||
if obj != nil {
|
|
||||||
envVar = strings.ReplaceAll(envVar, match, fmt.Sprintf("%v", obj.Serialize(obj)[vars]))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return envVar
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *ArgoBuilder) createVolumes(volumes []VolumeMount) { // TODO : one think about remote volume but TG
|
func (b *ArgoBuilder) createVolumes(volumes []VolumeMount) { // TODO : one think about remote volume but TG
|
||||||
for _, volume := range volumes {
|
for _, volume := range volumes {
|
||||||
if volume.Storage.SelectedInstanceIndex < 0 {
|
index := 0
|
||||||
continue
|
if volume.Storage.SelectedInstanceIndex != nil && (*volume.Storage.SelectedInstanceIndex) >= 0 {
|
||||||
|
index = *volume.Storage.SelectedInstanceIndex
|
||||||
}
|
}
|
||||||
storage := volume.Storage.Instances[volume.Storage.SelectedInstanceIndex]
|
storage := volume.Storage.Instances[index]
|
||||||
new_volume := VolumeClaimTemplate{}
|
new_volume := VolumeClaimTemplate{}
|
||||||
new_volume.Metadata.Name = strings.ReplaceAll(strings.ToLower(volume.Name), " ", "-")
|
new_volume.Metadata.Name = strings.ReplaceAll(strings.ToLower(volume.Name), " ", "-")
|
||||||
new_volume.Spec.AccessModes = []string{"ReadWriteOnce"}
|
new_volume.Spec.AccessModes = []string{"ReadWriteOnce"}
|
||||||
@ -295,6 +308,10 @@ func (b *ArgoBuilder) isArgoDependancy(id string) (bool, []string) {
|
|||||||
|
|
||||||
func (b *ArgoBuilder) getArgoDependencies(id string) (dependencies []string) {
|
func (b *ArgoBuilder) getArgoDependencies(id string) (dependencies []string) {
|
||||||
for _, link := range b.OriginWorkflow.Graph.Links {
|
for _, link := range b.OriginWorkflow.Graph.Links {
|
||||||
|
if _, ok := b.OriginWorkflow.Graph.Items[link.Source.ID]; !ok {
|
||||||
|
fmt.Println("Could not find the source of the link", link.Source.ID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
source := b.OriginWorkflow.Graph.Items[link.Source.ID].Processing
|
source := b.OriginWorkflow.Graph.Items[link.Source.ID].Processing
|
||||||
if id == link.Destination.ID && source != nil {
|
if id == link.Destination.ID && source != nil {
|
||||||
dependency_name := getArgoName(source.GetName(), link.Source.ID)
|
dependency_name := getArgoName(source.GetName(), link.Source.ID)
|
||||||
|
@ -29,15 +29,18 @@ func (b *ArgoBuilder) CreateService(id string, processing *resources.ProcessingR
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *ArgoBuilder) completeServicePorts(service *models.Service, id string, processing *resources.ProcessingResource) {
|
func (b *ArgoBuilder) completeServicePorts(service *models.Service, id string, processing *resources.ProcessingResource) {
|
||||||
for _, execute := range processing.Container.Exposes {
|
instance := processing.GetSelectedInstance()
|
||||||
if execute.PAT != 0 {
|
if instance != nil && instance.(*resources.ProcessingInstance).Access != nil && instance.(*resources.ProcessingInstance).Access.Container != nil {
|
||||||
new_port_translation := models.ServicePort{
|
for _, execute := range instance.(*resources.ProcessingInstance).Access.Container.Exposes {
|
||||||
Name: strings.ToLower(processing.Name) + id,
|
if execute.PAT != 0 {
|
||||||
Port: execute.Port,
|
new_port_translation := models.ServicePort{
|
||||||
TargetPort: execute.PAT,
|
Name: strings.ToLower(processing.Name) + id,
|
||||||
Protocol: "TCP",
|
Port: execute.Port,
|
||||||
|
TargetPort: execute.PAT,
|
||||||
|
Protocol: "TCP",
|
||||||
|
}
|
||||||
|
service.Spec.Ports = append(service.Spec.Ports, new_port_translation)
|
||||||
}
|
}
|
||||||
service.Spec.Ports = append(service.Spec.Ports, new_port_translation)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,7 +49,6 @@ func (b *ArgoBuilder) addServiceToArgo() error {
|
|||||||
for _, service := range b.Services {
|
for _, service := range b.Services {
|
||||||
service_manifest, err := yaml.Marshal(service)
|
service_manifest, err := yaml.Marshal(service)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error().Msg("Could not marshal service manifest : " + err.Error())
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
service_template := models.Template{Name: "workflow-service-pod",
|
service_template := models.Template{Name: "workflow-service-pod",
|
||||||
|
@ -13,20 +13,21 @@ type WorflowDB struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the obj!ects from the mxgraphxml stored in the workflow given as a parameter
|
// Create the obj!ects from the mxgraphxml stored in the workflow given as a parameter
|
||||||
func (w *WorflowDB) LoadFrom(workflow_id string) error {
|
func (w *WorflowDB) LoadFrom(workflow_id string, peerID string) error {
|
||||||
|
fmt.Println("Loading workflow from " + workflow_id)
|
||||||
var err error
|
var err error
|
||||||
if w.Workflow, err = w.getWorkflow(workflow_id); err != nil {
|
if w.Workflow, err = w.getWorkflow(workflow_id, peerID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use oclib to retrieve the graph contained in the workflow referenced
|
// Use oclib to retrieve the graph contained in the workflow referenced
|
||||||
func (w *WorflowDB) getWorkflow(workflow_id string) (workflow *workflow.Workflow, err error) {
|
func (w *WorflowDB) getWorkflow(workflow_id string, peerID string) (workflow *workflow.Workflow, err error) {
|
||||||
logger := oclib.GetLogger()
|
logger := oclib.GetLogger()
|
||||||
|
|
||||||
lib_data := oclib.NewRequest(oclib.LibDataEnum(oclib.WORKFLOW), "", "", []string{}, nil).LoadOne(workflow_id)
|
lib_data := oclib.NewRequest(oclib.LibDataEnum(oclib.WORKFLOW), "", peerID, []string{}, nil).LoadOne(workflow_id)
|
||||||
fmt.Println(lib_data.Code, lib_data.Err)
|
fmt.Println("ERR", lib_data.Code, lib_data.Err)
|
||||||
if lib_data.Code != 200 {
|
if lib_data.Code != 200 {
|
||||||
logger.Error().Msg("Error loading the graph")
|
logger.Error().Msg("Error loading the graph")
|
||||||
return workflow, errors.New(lib_data.Err)
|
return workflow, errors.New(lib_data.Err)
|
||||||
@ -42,7 +43,7 @@ func (w *WorflowDB) getWorkflow(workflow_id string) (workflow *workflow.Workflow
|
|||||||
|
|
||||||
func (w *WorflowDB) ExportToArgo(timeout int) (string, int, error) {
|
func (w *WorflowDB) ExportToArgo(timeout int) (string, int, error) {
|
||||||
logger := oclib.GetLogger()
|
logger := oclib.GetLogger()
|
||||||
|
fmt.Println("Exporting to Argo", w.Workflow)
|
||||||
if len(w.Workflow.Name) == 0 || w.Workflow.Graph == nil {
|
if len(w.Workflow.Name) == 0 || w.Workflow.Graph == nil {
|
||||||
return "", 0, fmt.Errorf("can't export a graph that has not been loaded yet")
|
return "", 0, fmt.Errorf("can't export a graph that has not been loaded yet")
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetGraph(t *testing.T){
|
func TestGetGraph(t *testing.T) {
|
||||||
w := WorflowDB{}
|
w := WorflowDB{}
|
||||||
w.LoadFrom("test-log")
|
w.LoadFrom("test-log", "")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user