Skip to content

Commit

Permalink
Deployed 4ddd928 with MkDocs version: 1.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Eitan Suez committed Feb 6, 2024
1 parent 9d6fe89 commit 712c091
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 70 deletions.
104 changes: 35 additions & 69 deletions resilience/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">


<a href="#test-resilience-and-fallback" class="md-skip">
Skip to content
</a>

</div>
<div data-md-component="announce">

Expand Down Expand Up @@ -358,17 +353,6 @@



<label class="md-nav__link md-nav__link--active" for="__toc">


<span class="md-ellipsis">
Resilience
</span>


<span class="md-nav__icon md-icon"></span>
</label>

<a href="./" class="md-nav__link md-nav__link--active">


Expand All @@ -379,32 +363,6 @@

</a>



<nav class="md-nav md-nav--secondary" aria-label="Table of contents">




<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>

<li class="md-nav__item">
<a href="#test-resilience-and-fallback" class="md-nav__link">
<span class="md-ellipsis">
Test resilience and fallback
</span>
</a>

</li>

</ul>

</nav>

</li>


Expand Down Expand Up @@ -467,23 +425,6 @@



<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>

<li class="md-nav__item">
<a href="#test-resilience-and-fallback" class="md-nav__link">
<span class="md-ellipsis">
Test resilience and fallback
</span>
</a>

</li>

</ul>

</nav>
</div>
</div>
Expand All @@ -502,9 +443,8 @@

<h1>Resilience</h1>

<h2 id="test-resilience-and-fallback">Test resilience and fallback<a class="headerlink" href="#test-resilience-and-fallback" title="Permanent link">&para;</a></h2>
<p>The original Spring Cloud version of PetClinic used <a href="https://resilience4j.readme.io/docs">Resilience4j</a> to <a href="https://github.com/spring-petclinic/spring-petclinic-cloud/blob/master/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/ApiGatewayApplication.java#L83">configure calls to the visit service with a timeout of 4 seconds</a>, and <a href="https://github.com/spring-petclinic/spring-petclinic-cloud/blob/master/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/boundary/web/ApiGatewayController.java#L56">a fallback to return an empty list of visits</a> in the event that the request to get visits timed out (took longer).</p>
<p>Spring Cloud was removed. We can replace this configuration with an Istio Custom Resource.</p>
<p>The original Spring Cloud version of PetClinic used <a href="https://resilience4j.readme.io/docs">Resilience4j</a> to <a href="https://github.com/spring-petclinic/spring-petclinic-cloud/blob/master/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/ApiGatewayApplication.java#L83">configure calls to the visit service with a timeout of 4 seconds</a>, and <a href="https://github.com/spring-petclinic/spring-petclinic-cloud/blob/master/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/boundary/web/ApiGatewayController.java#L56">a fallback to return an empty list of visits</a> in the event that the request to get visits timed out.</p>
<p>In this version of the application, the Spring Cloud dependencies were removed. We can replace this configuration with an Istio Custom Resource.</p>
<p>The file <a href="https://github.com/spring-petclinic/spring-petclinic-istio/blob/master/manifests/config/timeouts.yaml"><code>timeouts.yaml</code></a> configures the equivalent 4s timeout on requests to the <code>visits</code> service, replacing the previous Resilience4j-based implementation.</p>
<details class="tldr">
<summary>timeouts.yaml</summary>
Expand Down Expand Up @@ -544,35 +484,61 @@ <h2 id="test-resilience-and-fallback">Test resilience and fallback<a class="head
<ol>
<li>
<p>Call <code>visits-service</code> directly:</p>
<div class="tabbed-set tabbed-alternate" data-tabs="1:2"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">bash shell</label><label for="__tabbed_1_2">fish shell</label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="highlight"><pre><span></span><code><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a>kubectl<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>deploy/sleep<span class="w"> </span>--<span class="w"> </span>curl<span class="w"> </span>-s<span class="w"> </span>visits-service:8080/pets/visits?petId<span class="o">=</span><span class="m">8</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>jq
</code></pre></div>
</div>
<div class="tabbed-block">
<div class="highlight"><pre><span></span><code><a id="__codelineno-3-1" name="__codelineno-3-1" href="#__codelineno-3-1"></a>kubectl<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>deploy/sleep<span class="w"> </span>--<span class="w"> </span>curl<span class="w"> </span>-s<span class="w"> </span>visits-service:8080/pets/visits<span class="se">\?</span><span class="nv">petId</span><span class="o">=</span><span class="m">8</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>jq
</code></pre></div>
</div>
</div>
</div>
<p>Observe the call succeed and return a list of visits for this particular pet.</p>
</li>
<li>
<p>Call the <code>petclinic-frontend</code> endpoint, and note that for each pet, we see a list of visits:</p>
<div class="highlight"><pre><span></span><code><a id="__codelineno-3-1" name="__codelineno-3-1" href="#__codelineno-3-1"></a>kubectl<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>deploy/sleep<span class="w"> </span>--<span class="w"> </span>curl<span class="w"> </span>-s<span class="w"> </span>petclinic-frontend:8080/api/gateway/owners/6<span class="w"> </span><span class="p">|</span><span class="w"> </span>jq
<div class="highlight"><pre><span></span><code><a id="__codelineno-4-1" name="__codelineno-4-1" href="#__codelineno-4-1"></a>kubectl<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>deploy/sleep<span class="w"> </span>--<span class="w"> </span>curl<span class="w"> </span>-s<span class="w"> </span>petclinic-frontend:8080/api/gateway/owners/6<span class="w"> </span><span class="p">|</span><span class="w"> </span>jq
</code></pre></div>
</li>
<li>
<p>Edit the deployment manifest for the <code>visits-service</code> so that the environment variable <code>DELAY_MILLIS</code> is set to the value "5000" (which is 5 seconds). One way to do this is to edit the file with (then save and exit):</p>
<div class="highlight"><pre><span></span><code><a id="__codelineno-4-1" name="__codelineno-4-1" href="#__codelineno-4-1"></a>kubectl<span class="w"> </span>edit<span class="w"> </span>deploy<span class="w"> </span>visits-v1
<div class="highlight"><pre><span></span><code><a id="__codelineno-5-1" name="__codelineno-5-1" href="#__codelineno-5-1"></a>kubectl<span class="w"> </span>edit<span class="w"> </span>deploy<span class="w"> </span>visits-v1
</code></pre></div>
<p>Wait until the new pod has rolled out and become ready.</p>
</li>
<li>
<p>Once the new <code>visits-service</code> pod reaches <em>Ready</em> status, make the same call again:</p>
<div class="highlight"><pre><span></span><code><a id="__codelineno-5-1" name="__codelineno-5-1" href="#__codelineno-5-1"></a>kubectl<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>deploy/sleep<span class="w"> </span>--<span class="w"> </span>curl<span class="w"> </span>-v<span class="w"> </span>visits-service:8080/pets/visits?petId<span class="o">=</span><span class="m">8</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>jq
<div class="tabbed-set tabbed-alternate" data-tabs="2:2"><input checked="checked" id="__tabbed_2_1" name="__tabbed_2" type="radio" /><input id="__tabbed_2_2" name="__tabbed_2" type="radio" /><div class="tabbed-labels"><label for="__tabbed_2_1">bash shell</label><label for="__tabbed_2_2">fish shell</label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="highlight"><pre><span></span><code><a id="__codelineno-6-1" name="__codelineno-6-1" href="#__codelineno-6-1"></a>kubectl<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>deploy/sleep<span class="w"> </span>--<span class="w"> </span>curl<span class="w"> </span>-v<span class="w"> </span>visits-service:8080/pets/visits?petId<span class="o">=</span><span class="m">8</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>jq
</code></pre></div>
</div>
<div class="tabbed-block">
<div class="highlight"><pre><span></span><code><a id="__codelineno-7-1" name="__codelineno-7-1" href="#__codelineno-7-1"></a>kubectl<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>deploy/sleep<span class="w"> </span>--<span class="w"> </span>curl<span class="w"> </span>-v<span class="w"> </span>visits-service:8080/pets/visits<span class="se">\?</span><span class="nv">petId</span><span class="o">=</span><span class="m">8</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>jq
</code></pre></div>
</div>
</div>
</div>
<p>Observe the 504 (Gateway timeout) response this time around (because it exceeds the 4-second timeout).</p>
</li>
<li>
<p>Call the <code>petclinic-frontend</code> endpoint once more, and note that for each pet, the list of visits is empty:</p>
<div class="highlight"><pre><span></span><code><a id="__codelineno-6-1" name="__codelineno-6-1" href="#__codelineno-6-1"></a>kubectl<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>deploy/sleep<span class="w"> </span>--<span class="w"> </span>curl<span class="w"> </span>-s<span class="w"> </span>petclinic-frontend:8080/api/gateway/owners/6<span class="w"> </span><span class="p">|</span><span class="w"> </span>jq
<div class="highlight"><pre><span></span><code><a id="__codelineno-8-1" name="__codelineno-8-1" href="#__codelineno-8-1"></a>kubectl<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>deploy/sleep<span class="w"> </span>--<span class="w"> </span>curl<span class="w"> </span>-s<span class="w"> </span>petclinic-frontend:8080/api/gateway/owners/6<span class="w"> </span><span class="p">|</span><span class="w"> </span>jq
</code></pre></div>
<p>That is, the call succeeds, the timeout is caught, and the fallback empty list of visits is returned in its place.</p>
</li>
<li>
<p>Tail the logs of <code>petclinic-frontend</code> and observe a log message indicating the fallback was triggered.</p>
<div class="highlight"><pre><span></span><code><a id="__codelineno-9-1" name="__codelineno-9-1" href="#__codelineno-9-1"></a>kubectl<span class="w"> </span>logs<span class="w"> </span>--follow<span class="w"> </span>svc/petclinic-frontend
</code></pre></div>
<p>That is, the call succeeds, the timeout is caught, and the fallback empty list of visits is returned in its place.
Tail the logs of <code>petclinic-frontend</code> and observe a log message indicating the fallback was triggered.</p>
</li>
</ol>
<p>To restore the original behavior with no delay, edit the <code>visits-v1</code> deployment again and set the environment variable value to "0".</p>
<p>Restore the original behavior with no delay: edit the <code>visits-v1</code> deployment again and set the environment variable value to "0".</p>
<p>Let us next turn our attention to security-related configuration.</p>



Expand Down
Loading

0 comments on commit 712c091

Please sign in to comment.