8000 [Processor] Add enrichment and validation for async processing by rokatyy · Pull Request #3532 · nuclio/nuclio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Processor] Add enrichment and validation for async processing #3532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 12, 2025

Conversation

rokatyy
Copy link
Contributor
@rokatyy rokatyy commented Mar 6, 2025

Adds enrichment and validation for async processing

Copy link
Contributor
@TomerShor TomerShor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments.
Also - make sure to add the new configurations to docs/reference/function-configuration/function-configuration-reference.md

Comment on lines +185 to +189
for _, supportedKind := range triggerKindsSupportAsync {
if triggerKind == supportedKind {
return true
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not:

return strings.Contains(triggerKind, triggerKindsSupportAsync)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trigger is always the same (we don't have any versions there), so it should be fine.

Comment on lines 1746 to 1747
}
if !functionconfig.TriggerKindSupportsAsync(triggerInstance.Kind) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
if !functionconfig.TriggerKindSupportsAsync(triggerInstance.Kind) {
}
// Async validations
if !functionconfig.TriggerKindSupportsAsync(triggerInstance.Kind) {

}
if !functionconfig.TriggerKindSupportsAsync(triggerInstance.Kind) {
return nuclio.NewErrBadRequest(fmt.Sprintf(
"Async processing mode is not supported for %s trigger kind",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better put variables at the end so it's easier for searching later

Suggested change
"Async processing mode is not supported for %s trigger kind",
"Async processing mode is not supported for trigger kind - %s",


if !functionconfig.RuntimeSupportsAsync(functionConfig.Spec.Runtime) {
return nuclio.NewErrBadRequest(fmt.Sprintf(
"Async processing mode is not supported for %s runtime",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Async processing mode is not supported for %s runtime",
"Async processing mode is not supported for runtime - %s",

Comment on lines 1742 to 1744
if triggerInstance.AsyncConfig != nil {
return nuclio.NewErrBadRequest("AsyncConfig should be empty when working in `sync` trigger mode")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about warning and ignoring?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomerShor both options are fine. The problem here is that user may think that only AsyncConfig must be configured, when there is also a mode to configure - that's something I am worried about here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It made me think weather we really need a "Mode" property, or just async.enabled...

Copy link
Contributor Author
@rokatyy rokatyy Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomerShor not sure about enabled, disabled. As it would mean that it's something not default (and we want to have it as default in the future probably). However on the other hand, it would be more aligned with Batching (which will never be smth we enable by default in the contrast).

And from BE side it's easier to work with mode than with enable/disable

@@ -1783,17 +1821,17 @@ func (ap *Platform) enrichTriggers(ctx context.Context, functionConfig *function
return errors.Wrap(err, "Failed to enrich batch params")
}

if err := ap.enrichProcessingMode(ctx, functionConfig); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both this function and enrichBatchParams iterate over all triggers, AND we iterate over them again 2 rows below.
Instead - Iterate once, and enrich batch and processing params, as well as name etc.

Comment on lines +125 to +129
type ConnectionCreationMode string

const (
ConnectionCreationModeStatic ConnectionCreationMode = "static"
ConnectionCreationModeDynamic ConnectionCreationMode = "dynamic"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a prep for lazy connection creation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"trigger", triggerName,
"maxConnectionsNumber", functionconfig.DefaultMaxConnectionsNumber,
)
triggerInstance.AsyncConfig.MaxConnectionsNumber = functionconfig.DefaultMaxConnectionsNumber
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a limit on this number? maybe we should set something

Copy link
Contributor Author
@rokatyy rokatyy Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomerShor the limit is defined on the python side already, we can't really manage it on client side. Python side won't open more connections than file descriptors available. So, we should fail from wrapper side in this case

@rokatyy rokatyy force-pushed the nuc-201-enrich-validate branch from 43c4e52 to 9d4715e Compare March 10, 2025 17:21
rokatyy added 2 commits March 10, 2025 18:53
…multisockets

# Conflicts:
#	pkg/processor/runtime/python/test/python_test.go
@@ -95,7 +95,8 @@ type Trigger struct {
// General attributes
Attributes map[string]interface{} `json:"attributes,omitempty"`

Mode TriggerWorkMode `json:"mode,omitempty"`
Mode TriggerWorkMode `json:"mode,omitempty"`
AsyncConfig *AsyncConfig `json:"asyncConfig,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This aligns better with the config's naming conventions (e.g. build and not buildConfig)

Suggested change
AsyncConfig *AsyncConfig `json:"asyncConfig,omitempty"`
AsyncConfig *AsyncConfig `json:"async,omitempty"`

@rokatyy rokatyy requested a review from TomerShor March 11, 2025 14:53
@rokatyy rokatyy merged commit cf7bb0a into nuclio:development Mar 12, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0