diff --git a/server/.env.example b/server/.env.example index a22f29c89..80b3d16f5 100644 --- a/server/.env.example +++ b/server/.env.example @@ -1256,6 +1256,12 @@ # Default: # WORKFLOW_STACK_TRACE_ENABLED= +############################################################################### +# Forces the stack trace to record all steps +# Type: bool +# Default: +# WORKFLOW_STACK_TRACE_FULL= + ############################################################################### ############################################################################### # Discovery diff --git a/server/app/options/workflow.cue b/server/app/options/workflow.cue index f7892f08a..6843a515e 100644 --- a/server/app/options/workflow.cue +++ b/server/app/options/workflow.cue @@ -26,6 +26,11 @@ workflow: schema.#optionsGroup & { defaultGoExpr: "true" description: "Enables execution stack trace construction" } + stack_trace_full: { + type: "bool" + defaultGoExpr: "true" + description: "Forces the stack trace to record all steps" + } } title: "Workflow" } diff --git a/server/automation/envoy/yaml_decode.gen.go b/server/automation/envoy/yaml_decode.gen.go index ff243f92f..1351a9697 100644 --- a/server/automation/envoy/yaml_decode.gen.go +++ b/server/automation/envoy/yaml_decode.gen.go @@ -871,13 +871,14 @@ func unmarshalRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, err e // Example: // // modules: -// module1: -// name: "module 1" -// fields: ... -// allow: -// role1: -// - read -// - delete +// +// module1: +// name: "module 1" +// fields: ... +// allow: +// role1: +// - read +// - delete func unmarshalNestedRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, err error) { return out, y7s.EachMap(n, func(role, op *yaml.Node) error { out = append(out, &envoyx.Node{ @@ -903,10 +904,11 @@ func unmarshalNestedRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, // Example: // // allow: -// role1: -// corteza::system/: -// - users.search -// - users.create +// +// role1: +// corteza::system/: +// - users.search +// - users.create func unmarshalFlatRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, err error) { // Handles role return out, y7s.EachMap(n, func(role, perm *yaml.Node) error { diff --git a/server/automation/service/session.go b/server/automation/service/session.go index 676d61e59..a50c638af 100644 --- a/server/automation/service/session.go +++ b/server/automation/service/session.go @@ -325,6 +325,10 @@ func (svc *session) spawn(g *wfexec.Graph, workflowID uint64, trace bool, callSt ses.DisableStacktrace() } + if svc.opt.StackTraceFull { + ses.FullStacktrace() + } + svc.mux.Lock() svc.pool[ses.ID] = ses svc.mux.Unlock() diff --git a/server/automation/types/session.go b/server/automation/types/session.go index ce0ecbc35..e46bc1c0f 100644 --- a/server/automation/types/session.go +++ b/server/automation/types/session.go @@ -19,6 +19,7 @@ import ( type ( runtimeOptions struct { disableStacktrace bool + fullStacktrace bool } // Instance of single workflow execution @@ -131,6 +132,10 @@ func (s *Session) DisableStacktrace() { s.runtimeOpts.disableStacktrace = true } +func (s *Session) FullStacktrace() { + s.runtimeOpts.fullStacktrace = true +} + func (s *Session) Exec(ctx context.Context, step wfexec.Step, input *expr.Vars) error { return s.session.Exec(ctx, step, input) } @@ -190,12 +195,6 @@ func (s *Session) Apply(ssp SessionStartParams) { } } -// AppendRuntimeStacktrace adds a new frame to the runtime stacktrace -// -// This does have some smartness -// If the workflow uses longer iterators, the memory pressure got too high. -// To counter this, only the frames of the last iteration are preserved to -// better match what programming languages do. func (s *Session) AppendRuntimeStacktrace(frame *wfexec.Frame) { if s.runtimeOpts.disableStacktrace { return @@ -204,6 +203,20 @@ func (s *Session) AppendRuntimeStacktrace(frame *wfexec.Frame) { s.l.RLock() defer s.l.RUnlock() + if !s.runtimeOpts.fullStacktrace { + s.appendTruncatedRuntimeStacktrace(frame) + } else { + s.appendFullRuntimeStacktrace(frame) + } +} + +// appendTruncatedRuntimeStacktrace adds a new frame to the runtime stacktrace +// +// This does have some smartness +// If the workflow uses longer iterators, the memory pressure got too high. +// To counter this, only the frames of the last iteration are preserved to +// better match what programming languages do. +func (s *Session) appendTruncatedRuntimeStacktrace(frame *wfexec.Frame) { // The only way to get to the same stepID is when we're in a loop // Find where the first frame of the iterator is and slice the stack. if frame.Action != "iterator initialized" && s.hasDuplicate(frame.StepID) { @@ -225,6 +238,12 @@ func (s *Session) AppendRuntimeStacktrace(frame *wfexec.Frame) { s.RuntimeStacktrace = append(s.RuntimeStacktrace, frame) } +// appendFullRuntimeStacktrace is primarily meant for testing so we can inspect +// the entire execution and and state values +func (s *Session) appendFullRuntimeStacktrace(frame *wfexec.Frame) { + s.RuntimeStacktrace = append(s.RuntimeStacktrace, frame) +} + // @todo potentially optimize this; it'll probably be fine for now but // might degrade performance for larger workflows. // To investigate and potentially optimize it. diff --git a/server/compose/envoy/yaml_decode.gen.go b/server/compose/envoy/yaml_decode.gen.go index a4e546cab..c368e1d18 100644 --- a/server/compose/envoy/yaml_decode.gen.go +++ b/server/compose/envoy/yaml_decode.gen.go @@ -2405,13 +2405,14 @@ func unmarshalRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, err e // Example: // // modules: -// module1: -// name: "module 1" -// fields: ... -// allow: -// role1: -// - read -// - delete +// +// module1: +// name: "module 1" +// fields: ... +// allow: +// role1: +// - read +// - delete func unmarshalNestedRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, err error) { return out, y7s.EachMap(n, func(role, op *yaml.Node) error { out = append(out, &envoyx.Node{ @@ -2437,10 +2438,11 @@ func unmarshalNestedRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, // Example: // // allow: -// role1: -// corteza::system/: -// - users.search -// - users.create +// +// role1: +// corteza::system/: +// - users.search +// - users.create func unmarshalFlatRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, err error) { // Handles role return out, y7s.EachMap(n, func(role, perm *yaml.Node) error { diff --git a/server/compose/service/main_test.go b/server/compose/service/main_test.go index 5855f41c1..1d95dbf0d 100644 --- a/server/compose/service/main_test.go +++ b/server/compose/service/main_test.go @@ -1,11 +1,10 @@ package service import ( - "context" - + "github.com/cortezaproject/corteza/server/pkg/cli" "github.com/cortezaproject/corteza/server/pkg/id" ) func init() { - id.Init(context.Background()) + id.Init(cli.Context()) } diff --git a/server/pkg/id/sonyflake.go b/server/pkg/id/sonyflake.go index b489d140c..c97f87acb 100644 --- a/server/pkg/id/sonyflake.go +++ b/server/pkg/id/sonyflake.go @@ -38,8 +38,11 @@ const ( var ( initialized bool - idQueue = make(chan uint64, 512) - makerCount = 20 + idQueue = make(chan uint64, 8000) + // Keep this to 1 for now as we need to enforce that any later ID is larger + // than any previous one. + // If we use different deviceIDs for routines, this isn't guaranteed to hold. + makerCount = 1 ) func Init(ctx context.Context) { @@ -56,6 +59,10 @@ func Init(ctx context.Context) { } wg.Wait() + + // Give it some time to warm up with some ids + // Arbitrarily picked a good timeout based on benchmark runs + time.Sleep(time.Second * 1) } func makeIDer(ctx context.Context, wg *sync.WaitGroup, qq chan uint64, thr uint64) { diff --git a/server/pkg/id/sonyflake_test.go b/server/pkg/id/sonyflake_test.go index f327864a8..f0dab575e 100644 --- a/server/pkg/id/sonyflake_test.go +++ b/server/pkg/id/sonyflake_test.go @@ -6,10 +6,15 @@ import ( "github.com/cortezaproject/corteza/server/pkg/cli" ) +// goos: darwin +// goarch: arm64 +// pkg: github.com/cortezaproject/corteza/server/pkg/id +// BenchmarkGenerator-12 162234 39011 ns/op 0 B/op 0 allocs/op func BenchmarkGenerator(b *testing.B) { ctx := cli.Context() Init(ctx) + b.ResetTimer() for n := 0; n < b.N; n++ { Next() } diff --git a/server/pkg/options/options.gen.go b/server/pkg/options/options.gen.go index b6f1b408c..34d6dbeb8 100644 --- a/server/pkg/options/options.gen.go +++ b/server/pkg/options/options.gen.go @@ -252,6 +252,7 @@ type ( ExecDebug bool `env:"WORKFLOW_EXEC_DEBUG"` CallStackSize int `env:"WORKFLOW_CALL_STACK_SIZE"` StackTraceEnabled bool `env:"WORKFLOW_STACK_TRACE_ENABLED"` + StackTraceFull bool `env:"WORKFLOW_STACK_TRACE_FULL"` } DiscoveryOpt struct { @@ -1024,6 +1025,7 @@ func Workflow() (o *WorkflowOpt) { Register: true, CallStackSize: 16, StackTraceEnabled: true, + StackTraceFull: true, } // Custom defaults diff --git a/server/pkg/wfexec/main_test.go b/server/pkg/wfexec/main_test.go index a68242469..4824d1b4d 100644 --- a/server/pkg/wfexec/main_test.go +++ b/server/pkg/wfexec/main_test.go @@ -1,11 +1,10 @@ package wfexec import ( - "context" - + "github.com/cortezaproject/corteza/server/pkg/cli" "github.com/cortezaproject/corteza/server/pkg/id" ) func init() { - id.Init(context.Background()) + id.Init(cli.Context()) } diff --git a/server/pkg/wfexec/session.go b/server/pkg/wfexec/session.go index 97eca5466..819c5a041 100644 --- a/server/pkg/wfexec/session.go +++ b/server/pkg/wfexec/session.go @@ -63,8 +63,6 @@ type ( // This keeps track of workflow calls callStack []uint64 - - Statko chan SessionStatus } StateChangeHandler func(SessionStatus, *State, *Session) diff --git a/server/store/adapters/rdbms/rdbms.gen.go b/server/store/adapters/rdbms/rdbms.gen.go index 4a8336eda..717844f79 100644 --- a/server/store/adapters/rdbms/rdbms.gen.go +++ b/server/store/adapters/rdbms/rdbms.gen.go @@ -580,13 +580,13 @@ func (s *Store) SearchApigwFilters(ctx context.Context, f systemType.ApigwFilter // fetchFullPageOfApigwFilters collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfApigwFilters( @@ -1178,13 +1178,13 @@ func (s *Store) SearchApigwRoutes(ctx context.Context, f systemType.ApigwRouteFi // fetchFullPageOfApigwRoutes collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfApigwRoutes( @@ -1780,13 +1780,13 @@ func (s *Store) SearchApplications(ctx context.Context, f systemType.Application // fetchFullPageOfApplications collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfApplications( @@ -2337,13 +2337,13 @@ func (s *Store) SearchAttachments(ctx context.Context, f systemType.AttachmentFi // fetchFullPageOfAttachments collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfAttachments( @@ -2889,13 +2889,13 @@ func (s *Store) SearchAuthClients(ctx context.Context, f systemType.AuthClientFi // fetchFullPageOfAuthClients collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfAuthClients( @@ -4628,13 +4628,13 @@ func (s *Store) SearchAutomationSessions(ctx context.Context, f automationType.S // fetchFullPageOfAutomationSessions collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfAutomationSessions( @@ -5195,13 +5195,13 @@ func (s *Store) SearchAutomationTriggers(ctx context.Context, f automationType.T // fetchFullPageOfAutomationTriggers collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfAutomationTriggers( @@ -5758,13 +5758,13 @@ func (s *Store) SearchAutomationWorkflows(ctx context.Context, f automationType. // fetchFullPageOfAutomationWorkflows collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfAutomationWorkflows( @@ -6383,13 +6383,13 @@ func (s *Store) SearchComposeAttachments(ctx context.Context, f composeType.Atta // fetchFullPageOfComposeAttachments collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfComposeAttachments( @@ -6939,13 +6939,13 @@ func (s *Store) SearchComposeCharts(ctx context.Context, f composeType.ChartFilt // fetchFullPageOfComposeCharts collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfComposeCharts( @@ -7536,13 +7536,13 @@ func (s *Store) SearchComposeModules(ctx context.Context, f composeType.ModuleFi // fetchFullPageOfComposeModules collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfComposeModules( @@ -8622,13 +8622,13 @@ func (s *Store) SearchComposeNamespaces(ctx context.Context, f composeType.Names // fetchFullPageOfComposeNamespaces collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfComposeNamespaces( @@ -9244,13 +9244,13 @@ func (s *Store) SearchComposePages(ctx context.Context, f composeType.PageFilter // fetchFullPageOfComposePages collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfComposePages( @@ -9890,13 +9890,13 @@ func (s *Store) SearchComposePageLayouts(ctx context.Context, f composeType.Page // fetchFullPageOfComposePageLayouts collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfComposePageLayouts( @@ -10877,13 +10877,13 @@ func (s *Store) SearchDalConnections(ctx context.Context, f systemType.DalConnec // fetchFullPageOfDalConnections collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfDalConnections( @@ -11502,13 +11502,13 @@ func (s *Store) SearchDalSchemaAlterations(ctx context.Context, f systemType.Dal // fetchFullPageOfDalSchemaAlterations collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfDalSchemaAlterations( @@ -12045,13 +12045,13 @@ func (s *Store) SearchDalSensitivityLevels(ctx context.Context, f systemType.Dal // fetchFullPageOfDalSensitivityLevels collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfDalSensitivityLevels( @@ -12600,13 +12600,13 @@ func (s *Store) SearchDataPrivacyRequests(ctx context.Context, f systemType.Data // fetchFullPageOfDataPrivacyRequests collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfDataPrivacyRequests( @@ -13162,13 +13162,13 @@ func (s *Store) SearchDataPrivacyRequestComments(ctx context.Context, f systemTy // fetchFullPageOfDataPrivacyRequestComments collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfDataPrivacyRequestComments( @@ -13668,13 +13668,13 @@ func (s *Store) SearchFederationExposedModules(ctx context.Context, f federation // fetchFullPageOfFederationExposedModules collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfFederationExposedModules( @@ -14218,13 +14218,13 @@ func (s *Store) SearchFederationModuleMappings(ctx context.Context, f federation // fetchFullPageOfFederationModuleMappings collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfFederationModuleMappings( @@ -14806,13 +14806,13 @@ func (s *Store) SearchFederationNodes(ctx context.Context, f federationType.Node // fetchFullPageOfFederationNodes collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfFederationNodes( @@ -15452,13 +15452,13 @@ func (s *Store) SearchFederationNodeSyncs(ctx context.Context, f federationType. // fetchFullPageOfFederationNodeSyncs collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfFederationNodeSyncs( @@ -16050,13 +16050,13 @@ func (s *Store) SearchFederationSharedModules(ctx context.Context, f federationT // fetchFullPageOfFederationSharedModules collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfFederationSharedModules( @@ -17300,13 +17300,13 @@ func (s *Store) SearchQueues(ctx context.Context, f systemType.QueueFilter) (set // fetchFullPageOfQueues collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfQueues( @@ -17892,13 +17892,13 @@ func (s *Store) SearchQueueMessages(ctx context.Context, f systemType.QueueMessa // fetchFullPageOfQueueMessages collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfQueueMessages( @@ -18679,13 +18679,13 @@ func (s *Store) SearchReminders(ctx context.Context, f systemType.ReminderFilter // fetchFullPageOfReminders collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfReminders( @@ -19240,13 +19240,13 @@ func (s *Store) SearchReports(ctx context.Context, f systemType.ReportFilter) (s // fetchFullPageOfReports collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfReports( @@ -20142,13 +20142,13 @@ func (s *Store) SearchResourceTranslations(ctx context.Context, f systemType.Res // fetchFullPageOfResourceTranslations collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfResourceTranslations( @@ -20677,13 +20677,13 @@ func (s *Store) SearchRoles(ctx context.Context, f systemType.RoleFilter) (set s // fetchFullPageOfRoles collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfRoles( @@ -21996,13 +21996,13 @@ func (s *Store) SearchTemplates(ctx context.Context, f systemType.TemplateFilter // fetchFullPageOfTemplates collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfTemplates( @@ -22631,13 +22631,13 @@ func (s *Store) SearchUsers(ctx context.Context, f systemType.UserFilter) (set s // fetchFullPageOfUsers collects all requested results. // // Function applies: -// - cursor conditions (where ...) -// - limit +// - cursor conditions (where ...) +// - limit // // Main responsibility of this function is to perform additional sequential queries in case when not enough results // are collected due to failed check on a specific row (by check fn). // -// Function then moves cursor to the last item fetched +// # Function then moves cursor to the last item fetched // // This function is auto-generated func (s *Store) fetchFullPageOfUsers( diff --git a/server/system/automation/expr_types.go b/server/system/automation/expr_types.go index 3fbe44604..fad68cf01 100644 --- a/server/system/automation/expr_types.go +++ b/server/system/automation/expr_types.go @@ -243,12 +243,12 @@ func (v *RenderedDocument) Clone() (expr.TypedValue, error) { func (v *Role) Clone() (expr.TypedValue, error) { aux := v.value.Clone() - return NewRole(&aux) + return NewRole(aux) } func (v *Template) Clone() (expr.TypedValue, error) { aux := v.value.Clone() - return NewTemplate(&aux) + return NewTemplate(aux) } func (v *TemplateMeta) Clone() (expr.TypedValue, error) { @@ -257,5 +257,5 @@ func (v *TemplateMeta) Clone() (expr.TypedValue, error) { func (v *User) Clone() (expr.TypedValue, error) { aux := v.value.Clone() - return NewUser(&aux) + return NewUser(aux) } diff --git a/server/system/envoy/yaml_decode.gen.go b/server/system/envoy/yaml_decode.gen.go index b37d44112..9b69185d4 100644 --- a/server/system/envoy/yaml_decode.gen.go +++ b/server/system/envoy/yaml_decode.gen.go @@ -3594,13 +3594,14 @@ func unmarshalRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, err e // Example: // // modules: -// module1: -// name: "module 1" -// fields: ... -// allow: -// role1: -// - read -// - delete +// +// module1: +// name: "module 1" +// fields: ... +// allow: +// role1: +// - read +// - delete func unmarshalNestedRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, err error) { return out, y7s.EachMap(n, func(role, op *yaml.Node) error { out = append(out, &envoyx.Node{ @@ -3626,10 +3627,11 @@ func unmarshalNestedRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, // Example: // // allow: -// role1: -// corteza::system/: -// - users.search -// - users.create +// +// role1: +// corteza::system/: +// - users.search +// - users.create func unmarshalFlatRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, err error) { // Handles role return out, y7s.EachMap(n, func(role, perm *yaml.Node) error { diff --git a/server/system/service/main_test.go b/server/system/service/main_test.go index 5855f41c1..1d95dbf0d 100644 --- a/server/system/service/main_test.go +++ b/server/system/service/main_test.go @@ -1,11 +1,10 @@ package service import ( - "context" - + "github.com/cortezaproject/corteza/server/pkg/cli" "github.com/cortezaproject/corteza/server/pkg/id" ) func init() { - id.Init(context.Background()) + id.Init(cli.Context()) } diff --git a/server/tests/envoy/main_test.go b/server/tests/envoy/main_test.go index a9edbcecc..6c27a93c3 100644 --- a/server/tests/envoy/main_test.go +++ b/server/tests/envoy/main_test.go @@ -30,6 +30,7 @@ var ( func init() { helpers.RecursiveDotEnvLoad() + id.Init(cli.Context()) } func TestMain(m *testing.M) { diff --git a/server/tests/workflows/0008_iterator_role_members_test.go b/server/tests/workflows/0008_iterator_role_members_test.go index f25657537..e388bac33 100644 --- a/server/tests/workflows/0008_iterator_role_members_test.go +++ b/server/tests/workflows/0008_iterator_role_members_test.go @@ -50,7 +50,7 @@ func Test0008_iterator_role_members(t *testing.T) { req.NoError(err) req.Equal(ctr, i.Get().(int64)) - usr, err := automation.NewRole(frame.Results.GetValue()["u"]) + usr, err := automation.NewUser(frame.Results.GetValue()["u"]) req.NoError(err) req.Equal(fmt.Sprintf("u%d", ctr+1), usr.GetValue().Handle) }