Skip to content

Commit ce522f3

Browse files
committed
Get rid of circuit breaker, which just causes an (on-purpose) failure that confuses people
1 parent 836859e commit ce522f3

File tree

5 files changed

+4
-83
lines changed

5 files changed

+4
-83
lines changed

README.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,6 @@ examples.
225225
* The name of this role is `iris3`by default, but may be set by passing env variable `IRIS_CUSTOM_ROLE` in calling `deploy.sh` or `uninstall.sh`
226226

227227
# Testing
228-
## Circuit-breaker
229-
Warning: A circuit breaker will cause scheduled labeling to fail with an exception if you are running in "development/test mode" and scheduled-labeling finds more than 3 projects to label. This is meant to protect from accidentally flooding thousands of projects with labels when you are testing. (Though if so, the worst that happens is some useful labels 😉 )
230-
231-
* "Development/test mode" means that at least one of these is true:
232-
* The project ID has in it `dev`, `qa`, `playground`, or `test`, or whatever is configured. You can change or remove these strings in the configuration under key `test_or_dev_project_markers`)
233-
* or `config-test.yaml` exists, so that Iris is using it rather than `config.yaml`
234-
* or Iris is running in your local machine (rather than App Engine)
235228

236229
## Integration test
237230

@@ -240,19 +233,6 @@ Warning: A circuit breaker will cause scheduled labeling to fail with an excepti
240233
* It's an easy sanity check to be sure that, for example, that you have the right permissions.
241234
* It works against two test projects that you specify.
242235

243-
## Testing the Cloud Scheduler scheduled labeling
244-
245-
- This testing is less automated than `integration_test.sh`, so do it only if you have special need to test this functionality.
246-
- Deploy some cloud resources like Cloud SQL instance. Or deploy an unattached disk and attach it.
247-
- Configuration
248-
* Optionally edit the configuration file to set `label_all_on_cron: True` or `False`.
249-
* `True` will cause all resources to be labeled on the Cloud Scheduler cron job,
250-
* and `False` will cause only Cloud SQL and GCE Disks to be labeled.
251-
* Edit the configuration file to set `iris_prefix` to a unique value, so you can track the labels generated by this test.
252-
- Deploy the app
253-
* Use the `-c` switch at the end of the line (after the project ID). This disables event-based labeling, keeping only the Cloud Scheduler cron functionality.
254-
* Trigger Cloud Scheduler from the App Engine GUI, and check that labels were added.
255-
256236
# Next steps
257237

258238
See `TODO.md` and GitHub issues for potential future improvements.

main.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -74,50 +74,13 @@ def index():
7474
increment_invocation_count("index")
7575
with gae_memory_logging("index"):
7676
msg = iris_homepage_text()
77-
if dev_or_test_mode():
78-
msg += "\nI'm running in test or dev mode. " + explain_dev_or_test_mode()
7977

8078
logging.info(
8179
"index(); invocations of GAE instance : %s", count_invocations_by_path()
8280
)
8381
return Response(msg, mimetype="text/plain", status=200)
8482

8583

86-
from util.config_utils import (
87-
is_in_test_or_dev_project,
88-
is_test_configuration,
89-
config_test_file,
90-
)
91-
from util.gcp.detect_gae import detect_gae
92-
from util.gcp.gcp_utils import current_project_id
93-
94-
95-
def dev_or_test_mode():
96-
return (
97-
not detect_gae()
98-
or is_test_configuration()
99-
or is_in_test_or_dev_project(current_project_id())
100-
)
101-
102-
103-
def explain_dev_or_test_mode():
104-
explain = []
105-
if not detect_gae():
106-
explain.append("Not running in App Engine")
107-
if is_test_configuration():
108-
explain.append("Using a test configuration file " + config_test_file())
109-
if is_in_test_or_dev_project(current_project_id()):
110-
explain.append(
111-
"Running a project "
112-
+ current_project_id()
113-
+ " which has one of the markers of a test project"
114-
+ " configured under key test_or_dev_project_markers"
115-
)
116-
if not explain:
117-
explain.append("NOT in dev or test mode")
118-
return "; ".join(explain)
119-
120-
12184
@app.route("/_ah/warmup")
12285
def warmup():
12386
increment_invocation_count("warmup")
@@ -175,26 +138,9 @@ def __get_enabled_projects():
175138
if not enabled_projs:
176139
raise Exception("No projects enabled at all")
177140

178-
__circuit_breaker_in_devmode(enabled_projs) # Can throw exception
179141
return enabled_projs
180142

181143

182-
def __circuit_breaker_in_devmode(enabled_projs):
183-
if dev_or_test_mode():
184-
max_proj_in_dev = 8
185-
if len(enabled_projs) > max_proj_in_dev:
186-
raise Exception(
187-
"When running Iris in development/testing mode, "
188-
+ f"we support no more than "
189-
+ str(max_proj_in_dev)
190-
+ " projects, to avoid accidentally flooding the system. "
191-
+ str(len(enabled_projs))
192-
+ " projects are available, which exceeds that. "
193-
+ "This server is in development/testing mode because: "
194-
+ explain_dev_or_test_mode()
195-
)
196-
197-
198144
def __send_pubsub_per_projectplugin(configured_projects):
199145
msg_count = 0
200146
for project_id in configured_projects:

test_scripts/integration_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,5 +419,5 @@ def create_resources(test_project, run_id, gce_zone):
419419
assert_root_path()
420420

421421
main()
422-
print("Status", "failure" if global_exit_code else "success")
422+
print("Exit Status:", "failure" if global_exit_code else "success")
423423
sys.exit(global_exit_code)

uninstall.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ while getopts 'poh' opt; do
6565
This is useful if you deployed Iris to two projects
6666
in an org and want to delete it on one of those.
6767
-o: Uninstall org-level elements like Log Sink
68+
Environment variable:
69+
IRIS_CUSTOM_ROLE (Optional, default is iris3) An identifier for
70+
the Iris custom role that you want to delete.
6871
EOF
6972
exit 1
7073
;;

util/config_utils.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,3 @@ def is_test_configuration():
104104

105105
def config_test_file():
106106
return get_config()["config_file"]
107-
108-
109-
def is_in_test_or_dev_project(project_id):
110-
markers = get_config().get("test_or_dev_project_markers", [])
111-
for marker in markers:
112-
if marker and marker in project_id:
113-
return True
114-
return False

0 commit comments

Comments
 (0)