Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Ensure AppService Deployment Targets' health check respects proxy settings #35

Merged
merged 9 commits into from
Jun 15, 2022

Conversation

mjhilton
Copy link
Contributor

Relates to OctopusDeploy/Issues#7544

The fluent version of the Azure SDK libraries have a bug where for certain operations, the explicitly set Proxy configuration is ignored. This causes Health Checks to fail when run in environments requiring a proxy server to contact Azure.

That version of the Azure SDK libraries is no longer being maintained.

This PR rewrites the Health Check to use the new (albeit still in beta) version of the Azure SDKs, which will be the One True Library going forward.

Testing

  • I've tested locally to confirm the proxy behaviour is now fixed.
  • There are tests for health checks in Sashimi.Tests
  • I wrote a new test that indirectly ensures the proxy is being hit, by setting a non-existent proxy address and asserting that we fail to connect to that address. It's still not 100%, but better than nothing.

@mjhilton mjhilton enabled auto-merge (squash) June 15, 2022 02:01
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

LGTM, just put some questions there~

source/Calamari/HealthCheckCommand.cs Show resolved Hide resolved
/// are modifying the same shared state (eg Environment variables) across threads.
/// </remarks>
/// <typeparam name="TValue"></typeparam>
private class AutoResetMemento<TValue> : IDisposable
Copy link

Choose a reason for hiding this comment

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

This looks like an implementation of "setup - test - teardown" pattern, how does this compare with just using [Setup] and [Teardown] of the test framework?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah you're probably right, the code is cute but it's probably unnecessarily complex given the scope of what actually needs to happen here. I'll pare it back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I went to change it, I realised the reason I went for this in the first place: it allows a clean way, for a single test, to set things up and be sure that they will be restored to their original state, every time.

Setup and Teardown from the test framework apply to all tests in the fixture, so in order to achieve the same effect, I'll need to pull this test out to a separate fixture. I'll still do it... but there was some reasoning behind the implementation apart from just writing clever code ;)

Copy link

Choose a reason for hiding this comment

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

Thanks for the background~ Yep I can see why these infrastructures can be useful in enabling parameterised setups. Pulling the tests out in separate fixture may result in some repetitions in code, but that would be a little easier to understand for readers :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just pushed the changes.

@mjhilton mjhilton disabled auto-merge June 15, 2022 03:58
@mjhilton mjhilton enabled auto-merge (rebase) June 15, 2022 03:58
@mjhilton mjhilton disabled auto-merge June 15, 2022 03:58
@mjhilton mjhilton enabled auto-merge (squash) June 15, 2022 03:59
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@ghost
Copy link

ghost commented Jun 15, 2022

Hey Matt, just a note that "Relates to" is not one of the keywords supported by GitHub, so I'm not sure if it can auto close the related issue. If this PR addressed the issue entirely, perhaps we can use Fixes?

@mjhilton mjhilton merged commit 07785f5 into main Jun 15, 2022
@mjhilton mjhilton deleted the matth/7544-healthcheck-proxy-issue branch June 15, 2022 04:40
@mjhilton
Copy link
Contributor Author

"Relates to" is not one of the keywords supported by GitHub, so I'm not sure if it can auto close the related issue.

In this case, I did this intentionally. For Sashimi changes, the issue isn't actually fixed until we release the change in Server, so I intend to hold off and use the "Fixes" comment in my Server PR. But thanks for thinking about it :)

mjhilton added a commit that referenced this pull request Jul 19, 2022
…tings (#35)

* Ensure HealthCheck respects configured proxy settings
* Extract integration test base class to its own file
* Pull common variable setup down to base class
* Add test to ensure Health Check respects proxy settings
* Ensure Proxy test works on both CI and locally
* Fixes another small difference in testing between CI and local
* More tweaks to test for cross-OS assertion
* Fix up refactor in AppServiceBehaviourFixture
* Simplify Proxy test code
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant