Skip to content

Conversation

wdbaruni
Copy link
Member

@wdbaruni wdbaruni commented Mar 24, 2025

Today we set a default network config in the client side before sending requests to the orchestrator while we normalize the job. This is breaking backward compatibility across bacalhau versions since new default NetworkDefault is not known to older bacalhau versions.

The fix is to avoid normalizing requests in the client side in general, allow requests to land in the orchestrator with undefined (nil) networks which allows the orchestrator to dfifferentaite between explicit definition of network configs

Summary by CodeRabbit

  • Refactor
    • Streamlined the job submission process by removing redundant normalization steps.
    • Enhanced configuration validation for network, resource, spec, and timeout settings to improve overall stability.
    • Adjusted the application’s handling of default versus custom configuration values to ensure smoother, backward-compatible operations.
    • Simplified expectations around network and publisher configurations in tests by allowing nil values.

Copy link
Contributor

coderabbitai bot commented Mar 24, 2025

Walkthrough

The changes adjust how network configurations and job specifications are handled. In the job-building process, the network field is now conditionally assigned based on a default check. Multiple validation methods across models have been updated to include nil checks and simplified error handling. Additionally, several normalization steps in job processing and testing flows have been removed, with only validation remaining. These updates affect helper, job, network, resource, spec, timeout, public API, and scenario runner modules.

Changes

File(s) Change Summary
cmd/cli/helpers/helpers.go Modified BuildJobFromFlags to conditionally assign the Network field if taskSettings.Network is not equal to models.NetworkDefault, with accompanying comments for backward compatibility.
pkg/models/{network.go,resource.go,spec_config.go,timeout.go} Updated validation methods to add nil checks and simplify error handling by returning nil instead of errors for uninitialized receivers.
cmd/cli/{job/run.go,job/validate.go,serve/serve_test.go}, pkg/publicapi/apimodels/job.go, pkg/test/scenario/suite.go Removed normalization steps from job specification handling and job request objects, retaining only validation during processing.
cmd/cli/docker/docker_run_cli_test.go, cmd/cli/wasm/wasm_run_cli_test.go Changed expectedDefaultNetworkConfig to be a nil pointer instead of initialized, and updated assertions for Publisher to check for nil instead of empty values.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as CLI
  participant BF as BuildJobFromFlags
  participant TS as TaskSettings
  participant NC as NetworkConfig

  CLI->>BF: Build job from flags
  BF->>TS: Retrieve network configuration
  alt Network is not default
    BF->>NC: Create & assign new NetworkConfig (Type & Domains)
    NC-->>BF: Network config assigned
  else Network is default
    BF-->>BF: Skip assignment of network config
  end
  BF-->>CLI: Return built job
Loading
sequenceDiagram
  participant CLI as CLI
  participant JR as JobRunner
  participant V as Validator
  
  CLI->>JR: Submit Job
  JR->>V: Validate job specification (normalization removed)
  V-->>JR: Return validation result
  JR-->>CLI: Proceed with job submission
Loading

Possibly related PRs

Poem

Oh, I hop in code so bright,
Fields and checks now set just right,
No more normalization hops around,
With cleaner paths and bugs unbound,
A bunny cheer for changes found! 🐰✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 golangci-lint (1.64.8)

{"Issues":[{"FromLinter":"typecheck","Text":"pattern build/: no matching files found","Severity":"","SourceLines":["//go:embed build/"],"Pos":{"Filename":"webui/webui.go","Offset":0,"Line":23,"Column":12},"ExpectNoLint":false,"ExpectedNoLintLinter":""}],"Report":{"Linters":[{"Name":"asasalint"},{"Name":"asciicheck"},{"Name":"bidichk"},{"Name":"bodyclose","Enabled":true},{"Name":"canonicalheader"},{"Name":"containedctx"},{"Name":"contextcheck"},{"Name":"copyloopvar","Enabled":true},{"Name":"cyclop"},{"Name":"decorder"},{"Name":"deadcode"},{"Name":"depguard","Enabled":true},{"Name":"dogsled","Enabled":true},{"Name":"dupl"},{"Name":"dupword"},{"Name":"durationcheck"},{"Name":"errcheck","Enabled":true,"EnabledByDefault":true},{"Name":"errchkjson"},{"Name":"errname"},{"Name":"errorlint"},{"Name":"execinquery"},{"Name":"exhaustive"},{"Name":"exhaustivestruct"},{"Name":"exhaustruct"},{"Name":"exportloopref"},{"Name":"exptostd"},{"Name":"forbidigo","Enabled":true},{"Name":"forcetypeassert"},{"Name":"fatcontext"},{"Name":"funlen","Enabled":true},{"Name":"gci"},{"Name":"ginkgolinter"},{"Name":"gocheckcompilerdirectives"},{"Name":"gochecknoglobals"},{"Name":"gochecknoinits","Enabled":true},{"Name":"gochecksumtype"},{"Name":"gocognit"},{"Name":"goconst","Enabled":true},{"Name":"gocritic"},{"Name":"gocyclo","Enabled":true},{"Name":"godot"},{"Name":"godox"},{"Name":"err113"},{"Name":"gofmt","Enabled":true},{"Name":"gofumpt"},{"Name":"goheader"},{"Name":"goimports","Enabled":true},{"Name":"golint"},{"Name":"mnd","Enabled":true},{"Name":"gomnd"},{"Name":"gomoddirectives"},{"Name":"gomodguard"},{"Name":"goprintffuncname","Enabled":true},{"Name":"gosec","Enabled":true},{"Name":"gosimple","Enabled":true,"EnabledByDefault":true},{"Name":"gosmopolitan"},{"Name":"govet","Enabled":true,"EnabledByDefault":true},{"Name":"grouper"},{"Name":"ifshort"},{"Name":"iface"},{"Name":"importas"},{"Name":"inamedparam"},{"Name":"ineffassign","Enabled":true,"EnabledByDefault":true},{"Name":"interfacebloat"},{"Name":"interfacer"},{"Name":"intrange"},{"Name":"ireturn"},{"Name":"lll","Enabled":true},{"Name":"loggercheck"},{"Name":"maintidx"},{"Name":"makezero"},{"Name":"maligned"},{"Name":"mirror"},{"Name":"misspell"},{"Name":"musttag"},{"Name":"nakedret","Enabled":true},{"Name":"nestif"},{"Name":"nilerr"},{"Name":"nilnesserr"},{"Name":"nilnil"},{"Name":"nlreturn"},{"Name":"noctx","Enabled":true},{"Name":"nonamedreturns"},{"Name":"nosnakecase"},{"Name":"nosprintfhostport"},{"Name":"paralleltest"},{"Name":"perfsprint"},{"Name":"prealloc"},{"Name":"predeclared"},{"Name":"promlinter"},{"Name":"protogetter"},{"Name":"reassign"},{"Name":"recvcheck"},{"Name":"revive"},{"Name":"rowserrcheck"},{"Name":"sloglint"},{"Name":"scopelint"},{"Name":"sqlclosecheck"},{"Name":"spancheck"},{"Name":"staticcheck","Enabled":true,"EnabledByDefault":true},{"Name":"structcheck"},{"Name":"stylecheck","Enabled":true},{"Name":"tagalign"},{"Name":"tagliatelle"},{"Name":"tenv"},{"Name":"testableexamples"},{"Name":"testifylint"},{"Name":"testpackage"},{"Name":"thelper"},{"Name":"tparallel"},{"Name":"typecheck","Enabled":true,"EnabledByDefault":true},{"Name":"unconvert","Enabled":true},{"Name":"unparam"},{"Name":"unused","Enabled":true,"EnabledByDefault":true},{"Name":"usestdlibvars"},{"Name":"usetesting"},{"Name":"varcheck"},{"Name":"varnamelen"},{"Name":"wastedassign"},{"Name":"whitespace","Enabled":true},{"Name":"wrapcheck"},{"Name":"wsl"},{"Name":"zerologlint"},{"Name":"nolintlint","Enabled":true}]}}


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between d583681 and 9eaee90.

📒 Files selected for processing (2)
  • cmd/cli/docker/docker_run_cli_test.go (3 hunks)
  • cmd/cli/wasm/wasm_run_cli_test.go (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: testcontainers-suite / tests
🔇 Additional comments (5)
cmd/cli/wasm/wasm_run_cli_test.go (2)

43-43: Approving change to support backward compatibility

Changed the default network config to nil instead of initializing it with default values, which aligns with the PR objective of avoiding setting default network configs when nil.


473-473: Simplified publisher check to match new expectations

Updated assertion to check for nil publisher rather than checking properties on an empty publisher object, which is consistent with the change in network configuration handling.

cmd/cli/docker/docker_run_cli_test.go (3)

47-47: Approving change to support backward compatibility

Changed the default network config to nil instead of initializing it with default values, which aligns with the PR objective of avoiding setting default network configs when nil.


373-373: Updated test expectations for nil network configuration

Modified assertion to check for nil network rather than checking for a specific network type, which properly tests the new behavior where default network config is not automatically set.


735-735: Simplified publisher check to match new expectations

Updated assertion to check for nil publisher rather than checking properties on an empty publisher object, which is consistent with the change in network configuration handling.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@wdbaruni wdbaruni merged commit 9d9cbfa into main Mar 24, 2025
14 checks passed
@wdbaruni wdbaruni deleted the no-normalize-in-client branch March 24, 2025 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant