-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Fixes #10537] Improve rules creation using GeoFence batch - more imp… #10585
Conversation
a172525
to
1263da5
Compare
83f00ff
to
f18221d
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #10585 +/- ##
==========================================
+ Coverage 62.11% 62.13% +0.01%
==========================================
Files 828 828
Lines 51144 51174 +30
Branches 6554 6554
==========================================
+ Hits 31768 31795 +27
+ Misses 17695 17694 -1
- Partials 1681 1685 +4 |
f18221d
to
a2c766b
Compare
self.api_client.client.login(username=self.user, password=self.passwd) | ||
resp = self.api_client.get(f"{list_url + str(layer.id)}/") | ||
self.assertValidJSONResponse(resp) | ||
resp = self.client.get(list_url) |
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.
We are not performing anymore the login, is something wanted?
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.
The login is on line 157, these are some more tests as unauth user
verify=False, | ||
) | ||
|
||
if r.status_code not in (200, 201): | ||
logger.debug(f"Could not insert rule: [{r.status_code}] - {r.content}") | ||
raise GeofenceException(f"Could not insert rule: [{r.status_code}]") | ||
logger.debug(f"Could not insert rule: [{r.status_code}] - {r.text}") |
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.
Since its raising an exception, it might be better to increase this log level from debug or remove it since is raising the exception
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.
Usually the detailed information should be logged when debugging.
It's not said that the exception message is displayed at higher level.
@@ -203,38 +207,64 @@ def add_insert_rule(self, rule: Rule): | |||
operation.update(rule.get_object()) | |||
self.operations.append(operation) | |||
|
|||
def get_batch_length(self): | |||
def length(self) -> int: |
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.
Isn't this a property more than a method?
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.
By leaving it as a method, it can be extended by filtering only certain types of operations
verify=False, | ||
) | ||
|
||
if r.status_code != 200: | ||
logger.debug(f"Error while running batch {batch.log_name}: [{r.status_code}] - {r.content}") | ||
logger.debug( |
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.
It might be useful to increase this log level if it shows additional information than the Exception.
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.
Usually the detailed information should be logged only when debugging
|
||
except Exception as e: | ||
logger.debug(f"Error while requesting batch execution {batch.log_name}", exc_info=e) | ||
logger.info(f"Error while requesting batch exec {batch.log_name}") | ||
logger.debug(f"Error while requesting batch exec {batch.log_name} --> {batch.get_object()}", exc_info=e) |
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.
It might be useful to increase this log level if it shows additional information than the Exception.
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.
Usually the detailed information should be logged only when debugging
for r in gs_rules["rules"]: | ||
if r["layer"] and r["layer"] == layer_name: | ||
batch.add_delete_rule(r["id"]) | ||
cnt += 1 |
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.
Isn't the count provided by the batch.length()
as soon as all the rules are added?
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.
No: if the delete operations are collected in an existing batch, lenght would be > than the delete operations inserted
if isinstance(_resource, Dataset): | ||
if settings.OGC_SERVER["default"].get("GEOFENCE_SECURITY_ENABLED", False): | ||
if settings.OGC_SERVER["default"].get("GEOFENCE_SECURITY_ENABLED", False) or getattr( | ||
settings, "GEOFENCE_SECURITY_ENABLED", False |
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.
This is redundant. The GEOFENCE_SECURITY_ENABLED
in the settings is used to populate the OGC_SERVER["default"]["GEOFENCE_SECURITY_ENABLED"]
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.
Nope, tests are only setting the GEOFENCE_SECURITY_ENABLED
entry, not the other one
if not created: | ||
gf_utils.collect_delete_layer_rules(workspace, _resource.name, batch) | ||
|
||
exist_geolimits = None |
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.
i would suggest to have it as "False" and not None since the name say "exists"
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.
We need the 3 different values:
- true -> limit exists
- false -> limit does not exist
- None -> not computed
#10585) (#10588) * [Code Formatting] Revert formatting on conflicting files * [Fixes #10537] Improve rules creation using GeoFence batch - more improvements * [#10574] Align code formatting with black Co-authored-by: afabiani <alessio.fabiani@geosolutionsgroup.com> (cherry picked from commit 36f414d) Co-authored-by: Emanuele Tajariol <etj@geo-solutions.it>
…ore imp… (GeoNode#10585) (GeoNode#10588) * [Code Formatting] Revert formatting on conflicting files * [Fixes GeoNode#10537] Improve rules creation using GeoFence batch - more improvements * [GeoNode#10574] Align code formatting with black Co-authored-by: afabiani <alessio.fabiani@geosolutionsgroup.com> (cherry picked from commit 36f414d) Co-authored-by: Emanuele Tajariol <etj@geo-solutions.it>
…ore imp… (GeoNode#10585) (GeoNode#10588) * [Code Formatting] Revert formatting on conflicting files * [Fixes GeoNode#10537] Improve rules creation using GeoFence batch - more improvements * [GeoNode#10574] Align code formatting with black Co-authored-by: afabiani <alessio.fabiani@geosolutionsgroup.com> (cherry picked from commit 36f414d) Co-authored-by: Emanuele Tajariol <etj@geo-solutions.it>
A continuation of #10538.
Replaces #10556 since it had too many conflicts.
Batch creation have been moved to caller methods (wrt previous refactoring), in order to have a single
Batch
containing all the operations needed for a full perm syncronization.Checklist
For all pull requests:
The following are required only for core and extension modules (they are welcomed, but not required, for contrib modules):
Submitting the PR does not require you to check all items, but by the time it gets merged, they should be either satisfied or inapplicable.