-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Adding SSL support for online server #4677
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
franciscojavierarceo
merged 4 commits into
feast-dev:master
from
lokeshrangineni:feature/tls-support
Oct 25, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7c054f9
* Adding the SSL support for online_server.
lokeshrangineni 2b000ee
Incorporating code review comment.
lokeshrangineni f2482a9
Update docs/reference/feature-servers/python-feature-server.md
lokeshrangineni 1ca37f3
* Update docs/reference/feature-servers/python-feature-server.md
lokeshrangineni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,11 +15,13 @@ | |
| start_feature_server, | ||
| ) | ||
| from tests.utils.cli_repo_creator import CliRunner | ||
| from tests.utils.generate_self_signed_certifcate_util import generate_self_signed_cert | ||
| from tests.utils.http_server import free_port | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("ssl_mode", [True, False]) | ||
| @pytest.mark.integration | ||
| def test_remote_online_store_read(auth_config): | ||
| def test_remote_online_store_read(auth_config, ssl_mode): | ||
| with tempfile.TemporaryDirectory() as remote_server_tmp_dir, tempfile.TemporaryDirectory() as remote_client_tmp_dir: | ||
| permissions_list = [ | ||
| Permission( | ||
|
|
@@ -41,11 +43,12 @@ def test_remote_online_store_read(auth_config): | |
| actions=[AuthzedAction.READ_ONLINE], | ||
| ), | ||
| ] | ||
| server_store, server_url, registry_path = ( | ||
| server_store, server_url, registry_path, ssl_cert_path = ( | ||
| _create_server_store_spin_feature_server( | ||
| temp_dir=remote_server_tmp_dir, | ||
| auth_config=auth_config, | ||
| permissions_list=permissions_list, | ||
| ssl_mode=ssl_mode, | ||
| ) | ||
| ) | ||
| assert None not in (server_store, server_url, registry_path) | ||
|
|
@@ -54,6 +57,7 @@ def test_remote_online_store_read(auth_config): | |
| server_registry_path=str(registry_path), | ||
| feature_server_url=server_url, | ||
| auth_config=auth_config, | ||
| ssl_cert_path=ssl_cert_path, | ||
| ) | ||
| assert client_store is not None | ||
| _assert_non_existing_entity_feature_views_entity( | ||
|
|
@@ -159,21 +163,46 @@ def _assert_client_server_online_stores_are_matching( | |
|
|
||
|
|
||
| def _create_server_store_spin_feature_server( | ||
| temp_dir, auth_config: str, permissions_list | ||
| temp_dir, auth_config: str, permissions_list, ssl_mode: bool | ||
| ): | ||
| store = default_store(str(temp_dir), auth_config, permissions_list) | ||
| feast_server_port = free_port() | ||
| if ssl_mode: | ||
| certificates_path = tempfile.mkdtemp() | ||
| ssl_key_path = os.path.join(certificates_path, "key.pem") | ||
| ssl_cert_path = os.path.join(certificates_path, "cert.pem") | ||
| generate_self_signed_cert(cert_path=ssl_cert_path, key_path=ssl_key_path) | ||
| else: | ||
| ssl_key_path = "" | ||
| ssl_cert_path = "" | ||
|
|
||
| server_url = next( | ||
| start_feature_server( | ||
| repo_path=str(store.repo_path), server_port=feast_server_port | ||
| repo_path=str(store.repo_path), | ||
| server_port=feast_server_port, | ||
| ssl_key_path=ssl_key_path, | ||
| ssl_cert_path=ssl_cert_path, | ||
| ) | ||
| ) | ||
| print(f"Server started successfully, {server_url}") | ||
| return store, server_url, os.path.join(store.repo_path, "data", "registry.db") | ||
| if ssl_cert_path and ssl_key_path: | ||
| print(f"Online Server started successfully in SSL mode, {server_url}") | ||
| else: | ||
| print(f"Server started successfully, {server_url}") | ||
|
|
||
| return ( | ||
| store, | ||
| server_url, | ||
| os.path.join(store.repo_path, "data", "registry.db"), | ||
| ssl_cert_path, | ||
| ) | ||
|
|
||
|
|
||
| def _create_remote_client_feature_store( | ||
| temp_dir, server_registry_path: str, feature_server_url: str, auth_config: str | ||
| temp_dir, | ||
| server_registry_path: str, | ||
| feature_server_url: str, | ||
| auth_config: str, | ||
| ssl_cert_path: str = "", | ||
| ) -> FeatureStore: | ||
| project_name = "REMOTE_ONLINE_CLIENT_PROJECT" | ||
| runner = CliRunner() | ||
|
|
@@ -185,27 +214,35 @@ def _create_remote_client_feature_store( | |
| registry_path=server_registry_path, | ||
| feature_server_url=feature_server_url, | ||
| auth_config=auth_config, | ||
| ssl_cert_path=ssl_cert_path, | ||
| ) | ||
|
|
||
| return FeatureStore(repo_path=repo_path) | ||
|
|
||
|
|
||
| def _overwrite_remote_client_feature_store_yaml( | ||
| repo_path: str, registry_path: str, feature_server_url: str, auth_config: str | ||
| repo_path: str, | ||
| registry_path: str, | ||
| feature_server_url: str, | ||
| auth_config: str, | ||
| ssl_cert_path: str = "", | ||
| ): | ||
| repo_config = os.path.join(repo_path, "feature_store.yaml") | ||
| with open(repo_config, "w") as repo_config: | ||
| repo_config.write( | ||
| dedent( | ||
| f""" | ||
| project: {PROJECT_NAME} | ||
| registry: {registry_path} | ||
| provider: local | ||
| online_store: | ||
| path: {feature_server_url} | ||
| type: remote | ||
| entity_key_serialization_version: 2 | ||
| """ | ||
| ) | ||
| + auth_config | ||
| ) | ||
|
|
||
| config_content = "entity_key_serialization_version: 2\n" + auth_config | ||
| config_content += dedent( | ||
| f""" | ||
| project: {PROJECT_NAME} | ||
| registry: {registry_path} | ||
| provider: local | ||
| online_store: | ||
| path: {feature_server_url} | ||
| type: remote | ||
| """ | ||
| ) | ||
|
|
||
| if ssl_cert_path: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks great! |
||
| config_content += f" ssl_cert_path: {ssl_cert_path}\n" | ||
|
|
||
| with open(repo_config, "w") as repo_config_file: | ||
| repo_config_file.write(config_content) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.