Skip to content

Conversation

wdbaruni
Copy link
Member

@wdbaruni wdbaruni commented Mar 13, 2025

Full network type has been renamed to Host in a previous release. While the orchestrator maintained backward compatibility by still accepting Full network types and transforming them to Host, this broke older clients as they couldn't parse Host network type in the job response

Summary by CodeRabbit

  • New Features

    • Enhanced network settings now support an additional mode that provides full host network capabilities, offering improved port accessibility.
  • Refactor

    • Streamlined network configuration validation and processing to ensure consistent behavior across different network modes.
  • Tests

    • Expanded test coverage to verify accurate handling of various network configurations under multiple scenarios, including new cases for NetworkFull.

Copy link

linear bot commented Mar 13, 2025

Copy link
Contributor

coderabbitai bot commented Mar 13, 2025

Walkthrough

The changes add new test cases and modify existing ones to improve coverage of network configurations—specifically for the new NetworkFull type. The modifications include updating expected outcomes in tests, refactoring the port allocation logic to use a centralized check (SupportPortAllocation), and revising network configuration in the executor to handle both NetworkHost and NetworkFull uniformly. In addition, the network model now includes a deprecated NetworkFull constant with updated string representations.

Changes

File(s) Change Summary
cmd/cli/docker/docker_run_cli_test.go
pkg/bidstrategy/semantic/networking_allowlist_test.go
pkg/bidstrategy/semantic/networking_test.go
Added new test cases for network flag parsing and expanded coverage for the NetworkFull configuration, including adjustments to expected outcomes.
pkg/compute/port_allocator.go
pkg/executor/docker/network.go
Updated control flow: refactored port allocation to use SupportPortAllocation() and expanded the network configuration to treat NetworkFull similar to NetworkHost, setting host network modes accordingly.
pkg/models/network.go
pkg/models/network_string.go
Introduced the NetworkFull constant (deprecated), added the method SupportPortAllocation(), updated parsing and validation logic, and modified network constants’ ordering and string representations.
cmd/cli/wasm/wasm_run_cli_test.go Modified test case name and flags in TestJobFlagParsing to reflect the updated network configuration.
pkg/swagger/docs.go
pkg/swagger/swagger.json
webui/lib/api/schema/swagger.json
Expanded the models.Network enumeration to include a new value for NetworkFull, updating corresponding variable names in the API documentation and schema.

Sequence Diagram(s)

sequenceDiagram
    participant CLI
    participant Executor
    participant NetworkModel
    participant Docker
    participant PortAllocator

    CLI->>Executor: Run job with network flag (--network=host/--network=full)
    Executor->>NetworkModel: Parse network type
    NetworkModel-->>Executor: Return network type (Host or Full)
    Executor->>Docker: Configure network mode
    alt If network type is Host or Full
        Docker-->>Executor: Set dockerNetworkHost and update ExtraHosts
    else
        Docker-->>Executor: Proceed with default configuration
    end
    Executor->>PortAllocator: AllocatePorts(networkCfg)
    PortAllocator->>NetworkModel: Check SupportPortAllocation()
    NetworkModel-->>PortAllocator: Return true/false
    PortAllocator-->>Executor: Return allocated ports or error
Loading

Poem

In my burrow of code, I hop with delight,
New tests and network modes make everything right.
Host and Full join the merry parade,
Port allocation now neatly conveyed.
With a twitch of my nose and a joyful little trot,
I celebrate these changes—coding magic, hot! 🐇

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.62.2)

{"Issues":[{"FromLinter":"typecheck","Text":"pattern build/: no matching files found","Severity":"","SourceLines":["//go:embed build/"],"Replacement":null,"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":"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":"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":"varcheck"},{"Name":"varnamelen"},{"Name":"wastedassign"},{"Name":"whitespace","Enabled":true},{"Name":"wrapcheck"},{"Name":"wsl"},{"Name":"zerologlint"},{"Name":"nolintlint","Enabled":true}]}}


🪧 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 changed the title maintain backward compatibility with full network type fix backward compatibility with full network type Mar 13, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
webui/lib/api/schema/swagger.json (1)

1885-1891: Confirm Enum Update with Clear Deprecation Notice

The changes in the "models.Network" definition add the new NetworkFull enum value in the enum array and its corresponding entry in x-enum-varnames. This update is intended to restore backward compatibility by ensuring that older clients that rely on the Full network type get mapped correctly.

Recommendations:

  • Ensure that the API documentation explicitly notes that NetworkFull is deprecated (or an alias for NetworkHost) so that users are aware of its limited, backward compatibility role.
  • If possible, consider adding a vendor extension (for example, "x-deprecated": true or a descriptive comment in the documentation) to clearly mark NetworkFull as non-preferred for future integrations.
📜 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 6f3ea82 and bde5fa4.

📒 Files selected for processing (4)
  • cmd/cli/wasm/wasm_run_cli_test.go (1 hunks)
  • pkg/swagger/docs.go (1 hunks)
  • pkg/swagger/swagger.json (1 hunks)
  • webui/lib/api/schema/swagger.json (1 hunks)
🔇 Additional comments (3)
cmd/cli/wasm/wasm_run_cli_test.go (1)

335-344: Test updated to use "host" network type instead of "full".

The test case has been renamed from "with network full" to "with network host" and the network flag has been updated from "--network=full" to "--network=host". This change aligns with the PR objective to address backward compatibility issues between the old "Full" network type and the renamed "Host" type.

The assertion is correctly validating that the job's network type is set to models.NetworkHost, which suggests this test will continue to function properly with the updated network type naming.

pkg/swagger/docs.go (1)

1889-1898: Good addition for backward compatibility

The changes add NetworkFull between NetworkHost and NetworkHTTP in the enum values for models.Network. This aligns perfectly with the PR objective of fixing backward compatibility with the Full network type, which was previously renamed to Host.

This approach allows older clients to continue using the NetworkFull type while newer clients can use NetworkHost, solving the issue where older clients couldn't parse the Host network type in job responses.

pkg/swagger/swagger.json (1)

1885-1894: New 'NetworkFull' Enum Entry Introduced
The updated enumeration now includes a new value (with integer value 4) for "NetworkFull" in both the "enum" array and the corresponding "x-enum-varnames" array. This change appears to address the backward compatibility issue by allowing older clients to continue interpreting the network types correctly, even as the Full network type was previously renamed in code.

Please verify that the assigned numeric values and their ordering remain consistent with the definitions in the corresponding Go source (e.g., in pkg/models/network.go) and that any deprecation handling for the legacy Full type is properly coordinated across the codebase.

@wdbaruni wdbaruni merged commit 0d331c9 into main Mar 13, 2025
13 of 14 checks passed
@wdbaruni wdbaruni deleted the eng-691-fix-submitting-jobs-with-old-full-network-type branch March 13, 2025 14:21
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