Skip to content
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

[ZK filter] Remove EnvoyException on data plane #30438

Conversation

Winbobob
Copy link
Member

@Winbobob Winbobob commented Oct 23, 2023

Commit Message: [ZK filter] Remove EnvoyException on data plane
Additional Description: The Envoy style guideline suggests "Exceptions are allowed on the control plane, though now discouraged in new code. Adding exceptions is disallowed on the data plane", details in #10878 and #27412. This diff tries to remove EnvoyException on the ZK proxy filter data plane and paves path for per-opcode decoder error metrics.
Risk Level: Low
Testing: Unit tests
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Zhewei Hu <zhu@pinterest.com>
@repokitteh-read-only
Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #30438 was opened by Winbobob.

see: more, trace.

Winbobob and others added 10 commits October 23, 2023 16:12
Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Signed-off-by: Zhewei Hu <zhu@pinterest.com>
@Winbobob
Copy link
Member Author

/retest

Signed-off-by: Zhewei Hu <zhu@pinterest.com>
@Winbobob
Copy link
Member Author

/retest

@Winbobob Winbobob marked this pull request as ready for review November 14, 2023 06:14
@Winbobob
Copy link
Member Author

Winbobob commented Nov 14, 2023

Hi @JuniorHsu, please review whenever you have a chance, thanks!

Copy link
Contributor

@JuniorHsu JuniorHsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i need more time to deliberate on the macro but put an immediate comment first

Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Copy link
Contributor

@JuniorHsu JuniorHsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try to reduce the number of macro

if macros are zk specific, probably introduce a enum

enum class ReportPolicy {
 // comment 
 None, 
 // comment
 DecodeError
}

then ReportPolicy could be a parameter of macro
let's make ENVOY_LOG always happen in debug level if it applies

source/extensions/filters/network/zookeeper_proxy/utils.h Outdated Show resolved Hide resolved

#define RETURN_INVALID_ARG_ERR_IF_STATUS_NOT_OK(status, message) \
if (!status.ok()) { \
return absl::InvalidArgumentError(message); \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we just return status then we can save a pair of macros?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the function return type is absl::Status, we could return status directly.
If the function return type is absl::StatusOr<T>, we cannot return status directly, so I make it return absl::InvalidArgumentError instead.

Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Signed-off-by: Zhewei Hu <zhu@pinterest.com>
@Winbobob
Copy link
Member Author

let's try to reduce the number of macro

if macros are zk specific, probably introduce a enum

enum class ReportPolicy {
 // comment 
 None, 
 // comment
 DecodeError
}

then ReportPolicy could be a parameter of macro let's make ENVOY_LOG always happen in debug level if it applies

I tried, but had some issues.

After adding the above enum, I converted the marcos sth like below

#define ABSL_STATUS_RETURN_IF_STATUS_NOT_OK(status, report_policy)                                 \
  if (!status.ok()) {                                                                              \
    if (report_policy == ReportPolicy::DecodeError) {                                              \
      callbacks_.onDecodeError();                                                                  \
    }                                                                                              \
    return status;                                                                                 \
  }

#define RETURN_INVALID_ARG_ERR_IF_STATUS_NOT_OK(status, report_policy, message)                    \
  if (!status.ok()) {                                                                              \
    if (report_policy == ReportPolicy::DecodeError) {                                              \
      callbacks_.onDecodeError();                                                                  \
    }                                                                                              \
    return absl::InvalidArgumentError(message);                                                    \
  }

utils.cc also needs to access these marcos, but it cannot identify callbacks_, which defines in decode.h.
Since decode.h already imported utils.h, if I try to make utils.h import decode.h, there will be circular dependency.

@JuniorHsu
Copy link
Contributor

let's try to reduce the number of macro
if macros are zk specific, probably introduce a enum

enum class ReportPolicy {
 // comment 
 None, 
 // comment
 DecodeError
}

then ReportPolicy could be a parameter of macro let's make ENVOY_LOG always happen in debug level if it applies

I tried, but had some issues.

After adding the above enum, I converted the marcos sth like below

#define ABSL_STATUS_RETURN_IF_STATUS_NOT_OK(status, report_policy)                                 \
  if (!status.ok()) {                                                                              \
    if (report_policy == ReportPolicy::DecodeError) {                                              \
      callbacks_.onDecodeError();                                                                  \
    }                                                                                              \
    return status;                                                                                 \
  }

#define RETURN_INVALID_ARG_ERR_IF_STATUS_NOT_OK(status, report_policy, message)                    \
  if (!status.ok()) {                                                                              \
    if (report_policy == ReportPolicy::DecodeError) {                                              \
      callbacks_.onDecodeError();                                                                  \
    }                                                                                              \
    return absl::InvalidArgumentError(message);                                                    \
  }

utils.cc also needs to access these marcos, but it cannot identify callbacks_, which defines in decode.h. Since decode.h already imported utils.h, if I try to make utils.h import decode.h, there will be circular dependency.

I was thinking

#define RETURN_INVALID_ARG_ERR_IF_STATUS_NOT_OK(status, action)  \
  if (!status.ok()) {                      \
    action;                                \
    return status;                         \
  }

but seems to introduce more repetition.

Let's not keep the dedicate macro for onDecodeError for now. Thanks for investigating on this

@Winbobob
Copy link
Member Author

You mean "let's keep ..."?

@JuniorHsu
Copy link
Contributor

keep ..."?

Yes 🤦

Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Signed-off-by: Zhewei Hu <zhu@pinterest.com>
@Winbobob
Copy link
Member Author

The PR is ready for review again, cc @JuniorHsu , thanks!

Copy link
Contributor

@JuniorHsu JuniorHsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this approach. Over to maintainers' round @mattklein123

@mattklein123 mattklein123 merged commit 8d15ca7 into envoyproxy:main Nov 21, 2023
105 checks passed
lizan pushed a commit that referenced this pull request Dec 12, 2023
…31245)

This is the prerequisite of reverting #30438 in order to fix the ZK proxy filter "Uncaught Exception" issue.

Risk Level: Low
Testing: Unit test
Docs Changes: Revert doc changes in #31138
Release Notes: Revert release notes in #31138
Platform Specific Features: N/A

Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Winbobob added a commit to Winbobob/envoy that referenced this pull request Dec 12, 2023
…0438)"

This reverts commit 8d15ca7.

Signed-off-by: Zhewei Hu <zhu@pinterest.com>
KBaichoo pushed a commit that referenced this pull request Dec 21, 2023
…1314)

This reverts commit 8d15ca7.

Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Winbobob added a commit to Winbobob/envoy that referenced this pull request Dec 21, 2023
Signed-off-by: Zhewei Hu <zhu@pinterest.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants