Skip to content

Commit

Permalink
Add details to error operator log (#375)
Browse files Browse the repository at this point in the history
* Add details to error operator log

* Update test for new error log reporting
  • Loading branch information
THUzxj authored Mar 28, 2024
1 parent d22fa25 commit 92fb7c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions acto/checker/impl/operator_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def check(
)
if is_invalid:
return InvalidInputResult(
message=value,
responsible_property=invalid_field_path
)
# We reported error if we found error in the operator log
Expand Down
3 changes: 3 additions & 0 deletions acto/checker/impl/tests/test_operator_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ def checker_func(s: Snapshot, prev_s: Snapshot) -> Optional[InvalidInputResult]:
enumerate(
[
InvalidInputResult(
message="StatefulSet.apps \"test-cluster-server\" is invalid: spec.template.spec.restartPolicy: Unsupported value: \"OnFailure\": supported values: \"Always\"",
responsible_property=PropertyPath([]),
),
None,
InvalidInputResult(
message="tidb cluster acto-namespace/test-cluster is not valid and must be fixed first, aggregated error: spec.tidb.volumeName: Invalid value: \"lsgqejeydt\": Can not find volumeName: lsgqejeydt in storageVolumes or additionalVolumes/additionalVolumeMounts",
responsible_property=PropertyPath([]),
),
InvalidInputResult(
message="github.com/rabbitmq/cluster-operator/controllers.(*RabbitmqClusterReconciler).Reconcile\n\t/workspace/controllers/rabbitmqcluster_controller.go:260\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:298\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:253\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:214",
responsible_property=PropertyPath(
[
"spec",
Expand Down
6 changes: 4 additions & 2 deletions acto/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,13 @@ def invalid_input_message(
- when log indicates invalid input: the responsible field path for the invalid input
"""
logger = get_thread_logger(with_prefix=True)
is_invalid = False

for regex in INVALID_INPUT_LOG_REGEX:
if re.search(regex, log_msg):
logger.info("Recognized invalid input through regex: %s", log_msg)
return True, PropertyPath([])
is_invalid = True
break

# Check if the log line contains the field or value
# If so, also return True
Expand Down Expand Up @@ -621,7 +623,7 @@ def invalid_input_message(
)
return True, delta.path

return False, PropertyPath([])
return is_invalid, PropertyPath([])


def canonicalize(s: str):
Expand Down

0 comments on commit 92fb7c3

Please sign in to comment.