Skip to content

Deployers duplicate validation because Client.Deploy does not call Function.Validate() #4055

Description

@aliok

Summary

Each deployer's Deploy method (most visibly pkg/keda/deployer.go) re-implements a large block of validation that Function.Validate() already performs (ValidateScale, ValidateKafkaSecurity, scale bounds, trigger type/dup/combination checks). Ideally a deployer is a minimal executor and only validates what is genuinely deploy-specific (k8s resource-name limits, secret/volume path resolution).

Why the duplication exists today

Client.Deploy (pkg/functions/client.go:847) does not call Function.Validate() before invoking c.deployer.Deploy(...) — it only checks Built, Name, ValidateExpose, and ValidateSwitch. So on the library path (client.Deploy(ctx, f) with an in-memory function), the deployer's own preflight is the only validation that runs. Some callers invoke deployer.Deploy directly, bypassing Client.Deploy entirely.

As a result, the keda deployer's guards are currently load-bearing: removing them would let the library path silently create partial/broken resources (a raw Deployment with no scaler, a ScaledObject that can't connect to any broker, a resource name that overflows the 63-char DNS limit and fails server-side).

Only the CLI (cmd/deploy.go:316) and Tekton (pkg/pipelines/tekton/pipelines_provider.go:201) paths call Function.Validate() up front — so for those, the deployer re-validation truly is duplication.

Proposed fix

Introduce a single validation choke point: call Function.Validate() inside Client.Deploy (once), then thin all deployers (knative / raw / keda) down to the checks that Function.Validate does not cover:

  • k8s resource-name / DNS-label length limits (validateBridgeName, validateKafkaResourceNames)
  • secret / TLS-path resolution against f.Run.Volumes (validateKafkaTLSPaths)
  • nil-client guards

This removes the duplication and closes the latent gap where library consumers of Client.Deploy skip validation entirely.

Scope / notes

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions