-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add a thread to recreate the IPv6 firewall rule every 30 seconds to counteract the enforcer deleting it. #120
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,13 @@ | |
# limitations under the License. | ||
import datetime as dt | ||
import logging | ||
import threading | ||
import time | ||
from typing import Final | ||
|
||
from absl import flags | ||
from absl.testing import absltest | ||
from typing_extensions import TypeAlias, override | ||
from typing_extensions import override | ||
|
||
from framework import xds_k8s_flags | ||
from framework import xds_k8s_testcase | ||
|
@@ -39,6 +41,8 @@ | |
class DualStackTest(xds_k8s_testcase.RegularXdsKubernetesTestCase): | ||
v4_server_runner: _KubernetesServerRunner = None | ||
v6_server_runner: _KubernetesServerRunner = None | ||
fr_recreater: threading.Thread = None | ||
firewall_rule_creation_should_stop: bool = False | ||
|
||
@staticmethod | ||
@override | ||
|
@@ -95,6 +99,8 @@ def setUp(self): | |
) | ||
|
||
def cleanup(self): | ||
self.firewall_rule_creation_should_stop = True | ||
|
||
self.td.cleanup(force=self.force_cleanup) | ||
self.client_runner.cleanup( | ||
force=self.force_cleanup, force_namespace=self.force_cleanup | ||
|
@@ -128,6 +134,22 @@ def test_dualstack(self) -> None: | |
self.server_xds_host, self.server_xds_port | ||
) | ||
|
||
with self.subTest("_start_firewall_rule_creation_thread"): | ||
|
||
def recreate_firewall_rule(): | ||
time.sleep(30) | ||
while self.firewall_rule_creation_should_stop is False: | ||
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. Please use |
||
self.td.create_firewall_rules( | ||
allowed_ports=self.firewall_allowed_ports, | ||
source_range=self.firewall_source_range, | ||
source_range_ipv6=self.firewall_source_range_ipv6, | ||
) | ||
time.sleep(30) | ||
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. Seems like this could be done with a single call to 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. Can the delay be pulled to a module-level constant? Also, 30 seems a bit slow to me. Maybe 10? |
||
|
||
self.fr_recreater = threading.Thread( | ||
target=recreate_firewall_rule, args=(self,), daemon=True | ||
) | ||
|
||
test_servers: list[_XdsTestServer] = [] | ||
with self.subTest("03_start_test_server-dualstack"): | ||
test_servers.append( | ||
|
@@ -155,6 +177,7 @@ def test_dualstack(self) -> None: | |
|
||
logger.info("Test servers: %s", test_servers) | ||
|
||
# Start recreating the firewall rule every 15 seconds | ||
with self.subTest("04_add_server_backends_to_backend_services"): | ||
( | ||
neg_name, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this functionality is generally useful. Can we just incorporate it into the
--ensure_firewall
flag?