Skip to content

Add a mock-orig-dst feature flag#466

Merged
olix0r merged 11 commits intomasterfrom
ver/mock-orig-dst-feature
Mar 31, 2020
Merged

Add a mock-orig-dst feature flag#466
olix0r merged 11 commits intomasterfrom
ver/mock-orig-dst-feature

Conversation

@olix0r
Copy link
Member

@olix0r olix0r commented Mar 30, 2020

The proxy code is generic over the strategy it uses for determining the original destination address for a given connection. In integration tests, the strategy is replaced with a configured version.

The mock-orig-dst feature modifies the implementation to be swappable at compile-time via feature flag. This removes integration-test specific test code, and makes it generally possible to start the proxy outside of Kubernetes (via the compile-time flag). When this feature is enabled, runtime configuration is required via a pair of new environment variables.

There was an integration test that tested the proxy's behavior when an address could not be determined, but that test has been removed as that use case is not particularly important.

To build a proxy in this mode, one runs:

:; (cd linkerd2-proxy && cargo build --release --features=mock-orig-dst)

@olix0r olix0r requested a review from a team March 30, 2020 23:52
@olix0r olix0r changed the title Support mocking ORIG_DST_ADDR via a feature flag Add a mock-dst-addr feature flag Mar 31, 2020
@olix0r olix0r changed the title Add a mock-dst-addr feature flag Add a mock-orig-dst feature flag Mar 31, 2020
@olix0r olix0r requested a review from hawkw March 31, 2020 16:51
@hawkw
Copy link
Contributor

hawkw commented Mar 31, 2020

Technically, I don't think this should be a feature flag. Cargo features are intended to be strictly additive in nature, since they can be enabled by dependencies. It might be more correct to use cfg(mock_orig_dst) rather than cfg(feature = "mock-orig-dst"); then, we would set the configurations with RUSTFLAGS="--cfg mock-orig-dst" when building and it couldn't be enabled by a dependency.

With that said, I don't think this actually matters for linkerd. Since linkerd is a binary application rather than a library, we don't need to worry about dependent code enabling conflicting features. So, I am not sure if this actually matters at all; I just thought it was worth mentioning.

Copy link
Contributor

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

I think it seems possible to simplify things a bit more by removing the generics and the trait entirely. But, I'd be fine with merging this as is, if you don't think that's worth the extra effort.

@olix0r
Copy link
Member Author

olix0r commented Mar 31, 2020

Technically, I don't think this should be a feature flag.

I was wondering about this. The benefit to using feature flags is that the integration tests can just depend on the feature rather than requiring compiler settings. I'm going to merge as is but happy to revisit if it can be improved.

@hawkw
Copy link
Contributor

hawkw commented Mar 31, 2020

The benefit to using feature flags is that the integration tests can just depend on the feature rather than requiring compiler settings.

Ah, yeah, I hadn't thought of that. Let's do it this way, then — since Linkerd is not a library with dependents, I doubt the feature flag will cause issues.

@olix0r olix0r merged commit 883e199 into master Mar 31, 2020
@olix0r olix0r deleted the ver/mock-orig-dst-feature branch March 31, 2020 18:00
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Mar 31, 2020
This release restores the `route_actual_response_total` metric, which is
needed for `linkerd routes -o wide`.

---

* Update test certificates (linkerd/linkerd2-proxy#460)
* Use strong_count instead of upgrade on weak Arcs in cache (linkerd/linkerd2-proxy#459)
* Wire authority override coming from discovery (linkerd/linkerd2-proxy#462)
* Update integration tests certs (linkerd/linkerd2-proxy#465)
* Add a `mock-orig-dst` feature flag (linkerd/linkerd2-proxy#466)
* http-metrics: Make latency export optional (linkerd/linkerd2-proxy#467)
* Restore the route_actual_response_total metric (linkerd/linkerd2-proxy#468)
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Mar 31, 2020
This release restores the `route_actual_response_total` metric, which is
needed for `linkerd routes -o wide`.

---

* Update test certificates (linkerd/linkerd2-proxy#460)
* Use strong_count instead of upgrade on weak Arcs in cache (linkerd/linkerd2-proxy#459)
* Wire authority override coming from discovery (linkerd/linkerd2-proxy#462)
* Update integration tests certs (linkerd/linkerd2-proxy#465)
* Add a `mock-orig-dst` feature flag (linkerd/linkerd2-proxy#466)
* http-metrics: Make latency export optional (linkerd/linkerd2-proxy#467)
* Restore the route_actual_response_total metric (linkerd/linkerd2-proxy#468)
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