Skip to content

feat: Implement Finch container client - #8285

Merged
vicheey merged 5 commits into
developfrom
finch-fix
Oct 14, 2025
Merged

vicheey merged 5 commits into
developfrom
finch-fix

Conversation

@vicheey

@vicheey vicheey commented Sep 25, 2025 •

Copy link
Copy Markdown
Contributor

Which issue(s) does this change fix?

Adds Finch container runtime support for AWS SAM CLI local development and testing.

Why is this change necessary?

This change enables SAM CLI users to leverage Finch as container engine for local Lambda function development, testing, and debugging without manual configuration of socket path from users. This PR also implement separate client wrappers for Finch and Docker client.

How does it address the issue?

  • Container Runtime Abstraction: Implements a unified container client system that supports both Docker and Finch through a factory pattern
  • Automatic Detection: Adds enterprise detection mechanism to automatically identify and configure Finch socket path.
  • API Compatibility: Ensures all existing SAM CLI container operations work seamlessly with Finch
  • Test Infrastructure: Updates integration and unit tests to support both container runtimes
  • Error Handling: Provides Finch-specific error messages and fallback mechanisms
  • Performance Optimizations: Implements file locking and build caching to prevent race conditions

What side effects does this change have?

  • Positive: Users can now use Finch as a Docker alternative, potentially improving performance and
    reducing resource usage
  • Minimal Breaking Changes: Existing Docker workflows remain unchanged; Finch support is additive
  • Test Coverage: Comprehensive test suite ensures compatibility across both container runtimes
  • Configuration: New telemetry metrics track container runtime preferences for usage analytics

Mandatory Checklist

PRs will only be reviewed after checklist is complete

• [ ] Add input/output [type hints](https://
docs.python.org/3/library/typing.html) to new
functions/methods
• [ ] Write design document if needed ([Do I need to
write a design document?](https://github.com/aws/
aws-sam-cli/blob/develop/DEVELOPMENT_GUIDE.md#design
-document))
• [x] Write/update unit tests
• [x] Write/update integration tests
• [ ] Write/update functional tests if needed
• [x] make pr passes
• [ ] make update-reproducible-reqs if dependencies
were changed
• [x] Write documentation

By submitting this pull request, I confirm that my
contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions Bot added area/package sam package command area/local/start-api sam local start-api command area/build sam build command area/local/invoke sam local invoke command area/local/start-invoke pr/internal labels Sep 25, 2025
roger-zhangg
roger-zhangg previously approved these changes Sep 25, 2025
@vicheey
vicheey marked this pull request as ready for review September 26, 2025 16:46
@vicheey
vicheey requested a review from a team as a code owner September 26, 2025 16:46
vicheey and others added 4 commits October 13, 2025 17:15
Adds Finch container runtime support as an alternative to Docker for AWS SAM CLI local development and testing.
Finch provides a lightweight, open-source container runtime that offers better performance and resource
efficiency compared to Docker Desktop, especially inenterprise environments. This change enables SAM CLI
users to leverage Finch for local Lambda function development, testing, and debugging without requiring Docker Desktop.

How does it address the issue?
- Container Runtime Abstraction: Implements a unified container client system that supports both Docker and Finch through a factory pattern
- Automatic Detection: Adds enterprise detectionmechanism to automatically identify and configure Finch installations
- API Compatibility: Ensures all existing SAM CLI container operations work seamlessly with Finch
- Test Infrastructure: Updates integration and unit tests to support both container runtimes
- Error Handling: Provides Finch-specific error messages and fallback mechanisms
- Performance Optimizations: Implements file locking and build caching to prevent race conditions
What side effects does this change have?
- Users can now use Finch as a Docker alternative, potentially improving performance and
reducing resource usage
- Existing Docker workflows remain unchanged; Finch support is additive
- New metrics track container runtime preferences for usage analytics
Issue with AppVeyor Windows instances that take longer to finishing building.

@bnusunny bnusunny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@valerena valerena left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just some small comments that can be taken as a follow-up. LGTM.

def tearDown(self):
super(TestPackageImage, self).tearDown()

def _assert_finch_docker_success(self, stderr_text, error_message):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably we can change later, but isn't this just "Finch" success?

self.assertEqual(result, {"ENV_VAR1": "2", "ENV_VAR2": "3"})


class TestArchitectureDetection(TestCase):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To change as a follow-up.. all of these should be one test only, with parameterized


# Verify telemetry was called
mock_telemetry.assert_called_once()
telemetry_instance = mock_telemetry.return_value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel like we should be setting the return_value instead of getting it.. But if it works, it works. (I see we do that a lot in other tests too, so I guess it works)

self.assertEqual(result, "docker-default")
mock_env.assert_called_once()

@patch.dict("os.environ", {}, clear=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can also be parameterized instead of individual tests

self.assertFalse(self.client.is_available())
mock_log.debug.assert_called_once()

def test_is_finch_when_runtime_is_finch(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests don't seem to relevant, but they can also be parameterized in pairs

self.session_id = "test-session-id"


class TestContainerEngineMetrics(TestCase):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Most tests in this class should definitely be parameterized, or adding more things to the setUp, or with a utility function, so you don't have to put the exact same code multiple times in all tests.

@vicheey vicheey changed the title Finch fix feat: Implement Finch container client Oct 14, 2025
@vicheey
vicheey added this pull request to the merge queue Oct 14, 2025
Merged via the queue into develop with commit 1cf01b3 Oct 14, 2025
@vicheey
vicheey deleted the finch-fix branch October 14, 2025 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build sam build command area/local/invoke sam local invoke command area/local/start-api sam local start-api command area/local/start-invoke area/package sam package command pr/internal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants