Skip to content

Commit

Permalink
Release 23.3 Artifacts | +semver: minor (#2089)
Browse files Browse the repository at this point in the history
* Release notes
* Update docs
* Twilight Texas codename
* Ocelot Core team members should not be in Top 3 Chart
  • Loading branch information
raman-m committed Jun 8, 2024
1 parent 8c1c61e commit 696fa07
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 81 deletions.
101 changes: 77 additions & 24 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,84 @@
## Hotfix release (version {0}) for #2031 issue
> Route path template placeholders and their validation rules
## Spring 2024 (version {0}) aka [Twilight Texas](https://www.timeanddate.com/eclipse/solar/2024-april-8) release
> Codenamed: **[Twilight Texas](https://www.timeanddate.com/eclipse/solar/2024-april-8)**
> Read the Docs: [Ocelot 23.3](https://ocelot.readthedocs.io/en/{0}/)
Special thanks to **[Guillaume Gnaegi](https://github.com/ggnaegi)** and [Fabrizio Mancin](https://github.com/Fabman08)!
### What's new?

### About
The bug is related to the [Placeholders](https://ocelot.readthedocs.io/en/latest/features/routing.html#placeholders) feature in [Configuration](https://ocelot.readthedocs.io/en/latest/features/configuration.html) and [Routing](https://ocelot.readthedocs.io/en/latest/features/routing.html).
The bug was introduced in version [23.2.0](https://github.com/ThreeMammals/Ocelot/releases/tag/23.2.0) as a part of PR #1927.
- **[Service Discovery](https://github.com/ThreeMammals/Ocelot/blob/main/docs/features/servicediscovery.rst)**: Introducing a new feature for "[Customization of services creation](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/servicediscovery.rst#consul-service-builder-3)" in two primary service discovery providers: [Consul](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/servicediscovery.rst#consul-service-builder-3) and [Kubernetes](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/kubernetes.rst#downstream-scheme-vs-port-names-3), developed by @raman-m.
The customization for both `Consul` and `Kube` providers in service creation is achieved through the overriding of virtual methods in default implementations. The recommendation was to separate the provider's logic and introduce `public virtual` and `protected virtual` methods in concrete classes, enabling:
- The use of `public virtual` methods as dictated by interface definitions.
- The application of `protected virtual` methods to allow developers to customize atomic operations through inheritance from existing concrete classes.
- The injection of new interface objects into the provider's constructor.
- The overriding of the default behavior of classes.

### Breaking Change
The new [validation rules](https://github.com/ThreeMammals/Ocelot/blob/23.2.0/src/Ocelot/Configuration/Validator/FileConfigurationFluentValidator.cs#L45-L50) of the `FileConfigurationFluentValidator` class do not allow the Ocelot app to start when implicit [placeholders](https://ocelot.readthedocs.io/en/latest/features/routing.html#placeholders) are defined in custom implementations, such as middlewares, delegating handlers, and replaced services in the dependency injection (DI) container.
These new rules are capable of validating explicit [placeholders](https://ocelot.readthedocs.io/en/latest/features/routing.html#placeholders) only within the `UpstreamPathTemplate` and `DownstreamPathTemplate` properties. Unfortunately, they cannot oversee implicit placeholders in custom implementations, and they do not validate early during the Ocelot app startup process.
Ultimately, customization relies on the virtual methods within the default implementation classes, providing developers the flexibility to override them as necessary for highly tailored Consul/K8s configurations in their specific environments.
For further details, refer to the respective pull requests for both providers:
- `Kube` → PR #2052
- `Consul` → PR #2067

Ensure that you avoid using version [23.2.0](https://github.com/ThreeMammals/Ocelot/releases/tag/23.2.0). If you are currently on that version, upgrade to version [{0}](https://github.com/ThreeMammals/Ocelot/releases/tag/{0}) by applying this hotfix patch.
- **[Routing](https://github.com/ThreeMammals/Ocelot/blob/main/docs/features/routing.rst)**: Introducing the new "[Routing based on Request Header](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/routing.rst#upstream-headers-3)" feature by @jlukawska.
In addition to routing via `UpstreamPathTemplate`, you can now define an `UpstreamHeaderTemplates` options dictionary. For a route to match, all headers specified in this section are required to be present in the request headers.
For more details, see PR #1312.

### Technical info
With version [23.2.0](https://github.com/ThreeMammals/Ocelot/releases/tag/23.2.0), particularly if you have overridden certain service classes or implemented custom logic that manipulates placeholders, you may encounter Ocelot app crashes accompanied by the following errors in the log:
```
One or more errors occurred. (Unable to start Ocelot, errors are: XXX)
```
where `XXX` are the following validation error messages:
- `UpstreamPathTemplate 'UUU' doesn't contain the same placeholders in DownstreamPathTemplate 'DDD'`
- `DownstreamPathTemplate 'DDD' doesn't contain the same placeholders in UpstreamPathTemplate 'UUU'`
- **[Configuration](https://github.com/ThreeMammals/Ocelot/blob/main/docs/features/configuration.rst)**: Introducing the "[Custom Default Version Policy](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/configuration.rst#downstreamhttpversionpolicy-3)" feature by @ibnuda.
The configurable `HttpRequestMessage.VersionPolicy` helps avoid HTTP protocol connection errors and stabilizes connections to downstream services, especially when you're not developing those services, documentation is scarce, or the deployed HTTP protocol version is uncertain.
For developers of downstream services, it's possible to `ConfigureKestrel` server and its endpoints with new protocol settings. However, attention to version policy is also required, and this feature provides precise version settings for HTTP connections.
Essentially, this feature promotes the use of HTTP protocols beyond 1.0/1.1, such as HTTP/2 or even HTTP/3.
For additional details, refer to PR #1673.

**Finally**, the [validation rules](https://github.com/ThreeMammals/Ocelot/blob/23.2.0/src/Ocelot/Configuration/Validator/FileConfigurationFluentValidator.cs#L45-L50) resulted from the incorrect assumption that placeholders are always explicit and can be validated early. Therefore, custom implementations and feature services in the dependency injection (DI) container, which rely on or manipulate placeholders, should validate the configuration JSON and appropriate options later, directly within their service implementations.
- **[Configuration](https://github.com/ThreeMammals/Ocelot/blob/main/docs/features/configuration.rst)**: Introducing the new "[Route Metadata](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/configuration.rst#route-metadata)" feature by @vantm. Undoubtedly, this is the standout feature of the release! :star:
Route metadata enables Ocelot developers to incorporate custom functions that address specific needs or to create their own plugins/extensions.
In versions of Ocelot prior to [{0}](https://github.com/ThreeMammals/Ocelot/releases/tag/{0}), the configuration was limited to predefined values that Ocelot used internally. This was sufficient for official extensions, but posed challenges for third-party developers who needed to implement configurations not included in the standard `FileConfiguration`. Applying an option to a specific route required knowledge of the array index and other details that might not be readily accessible using the standard `IConfiguration` or `IOptions<FileConfiguration>` models from ASP.NET. Now, metadata can be directly accessed in the `DownstreamRoute` object. Furthermore, metadata can also be retrieved from the global JSON section via the `FileConfiguration.GlobalConfiguration` property.
For more information, see the details in PR #1843 on this remarkable feature.

### Bug Artifacts
- Released in version: [23.2.0](https://github.com/ThreeMammals/Ocelot/releases/tag/23.2.0)
- Introduced in: PR #1927
- Reported bug: #2031 by @ggnaegi and tested by @Fabman08
- Hotfix PR: #2032 by @raman-m
### Focus On

<details>
<summary><b>Updates of the features</b>: Configuration, Service Discovery, Routing and Quality of Service</summary>

- [Configuration](https://github.com/ThreeMammals/Ocelot/blob/main/docs/features/configuration.rst): New features are "[Custom Default Version Policy](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/configuration.rst#downstreamhttpversionpolicy-3)" by @ibnuda and "[Route Metadata](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/configuration.rst#route-metadata)" by @vantm.

- [Service Discovery](https://github.com/ThreeMammals/Ocelot/blob/main/docs/features/servicediscovery.rst): New feature is "[Customization of services creation](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/servicediscovery.rst#consul-service-builder-3)" by @raman-m.

- [Routing](https://github.com/ThreeMammals/Ocelot/blob/main/docs/features/routing.rst): New feature is "[Routing based on Request Header](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/routing.rst#upstream-headers-3)" by @jlukawska.

- [Quality of Service](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/qualityofservice.rst): The team has decided to remove the Polly V7 policies logic and the corresponding Ocelot `AddPollyV7` extensions (referenced in PR #2079). Furthermore, the Polly V8 Circuit Breaker has been mandated as the primary strategy (as per PR #2086).
See more detaild below in "**Ocelot extra packages**" paragraph.
</details>

<details>
<summary><b>Ocelot extra packages</b></summary>

- **[Ocelot.Provider.Polly](https://www.nuget.org/packages/Ocelot.Provider.Polly)**

- Our team has resolved to eliminate the Polly V7 policies logic and the corresponding Ocelot `AddPollyV7` extensions entirely (refer to the "[Polly v7 vs v8](https://github.com/ThreeMammals/Ocelot/blob/23.2.0/docs/features/qualityofservice.rst#polly-v7-vs-v8)" documentation). In the previous [23.2](https://github.com/ThreeMammals/Ocelot/releases/tag/23.2.0) release, named [Lunar Eclipse](https://github.com/ThreeMammals/Ocelot/releases/tag/23.2.0), we included these to maintain the legacy Polly behavior, allowing development teams to transition or retain the old Polly V7 functionality. We are now confident that it is time to progress alongside Polly, shifting our focus to the new Polly V8 [resilience pipelines](https://www.pollydocs.org/pipelines/). For more details, see PR #2079.

- Additionally, we have implemented Polly v8 Circuit Breaker as the primary strategy. Our Quality of Service (QoS) relies on two main strategies: [Circuit Breaker](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/qualityofservice.rst#circuit-breaker-strategy) and [Timeout](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/qualityofservice.rst#timeout-strategy). If both Circuit Breaker and Timeout are [configured](https://github.com/ThreeMammals/Ocelot/blob/{0}/docs/features/qualityofservice.rst#configuration) with their respective properties in the `QoSOptions` of the route JSON, then the Circuit Breaker strategy will take precedence in the constructed resilience pipeline. For more details, refer to PR #2086.
</details>

<details>
<summary><b>Stabilization</b> aka bug fixing</summary>

- Fixed #2034 in PR #2045 by @raman-m
- Fixed #2039 in PR #2050 by @PaulARoy
- Fixed #1590 in PR #1592 by @sergio-str
- Fixed #2054 #2059 in PR #2058 by @thiagoloureiro
- Fixed #954 #957 #1026 in PR #2067 by @raman-m
- Fixed #2002 in PR #2003 by @bbenameur
- Fixed #2085 in PR #2086 by @RaynaldM
- See [all bugs](https://github.com/ThreeMammals/Ocelot/issues?q=is%3Aissue+milestone%3ASpring%2724+is%3Aclosed+label%3Abug) of the [Spring'24](https://github.com/ThreeMammals/Ocelot/milestone/6) milestone
</details>

<details>
<summary><b>Documentation</b> for version <a href="https://ocelot.readthedocs.io/en/{0}/">{0}</a></summary>

- [Caching](https://ocelot.readthedocs.io/en/{0}/features/caching.html): New [EnableContentHashing option](https://ocelot.readthedocs.io/en/{0}/features/caching.html#enablecontenthashing-option) and [Global Configuration](https://ocelot.readthedocs.io/en/{0}/features/caching.html#global-configuration) sections
- [Configuration](https://ocelot.readthedocs.io/en/{0}/features/configuration.html): New [DownstreamHttpVersionPolicy](https://ocelot.readthedocs.io/en/{0}/features/configuration.html#downstreamhttpversionpolicy-3) and [Route Metadata](https://ocelot.readthedocs.io/en/{0}/features/configuration.html#route-metadata)
- [Kubernetes](https://ocelot.readthedocs.io/en/{0}/features/kubernetes.html): New [Downstream Scheme vs Port Names](https://ocelot.readthedocs.io/en/{0}/features/kubernetes.html#downstream-scheme-vs-port-names-3) section
- [Metadata](https://ocelot.readthedocs.io/en/{0}/features/metadata.html): This is new chapter for [Route Metadata](https://ocelot.readthedocs.io/en/{0}/features/configuration.html#route-metadata) feature.
- [Quality of Service](https://ocelot.readthedocs.io/en/{0}/features/qualityofservice.html)
- [Rate Limiting](https://ocelot.readthedocs.io/en/{0}/features/ratelimiting.html)
- [Request Aggregation](https://ocelot.readthedocs.io/en/{0}/features/requestaggregation.html)
- [Routing](https://ocelot.readthedocs.io/en/{0}/features/routing.html): New [Upstream Headers](https://ocelot.readthedocs.io/en/{0}/features/routing.html#upstream-headers-3) section
- [Service Discovery](https://ocelot.readthedocs.io/en/{0}/features/servicediscovery.html): New [Consul Service Builder](https://ocelot.readthedocs.io/en/{0}/features/servicediscovery.html#consul-service-builder-3) section
</details>
25 changes: 16 additions & 9 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,18 @@ Task("CreateReleaseNotes")
return;
}

var shortlogSummary = GitHelper($"shortlog --no-merges --numbered --summary {lastRelease}..HEAD")
var debugUserEmail = false;
var shortlogSummary = GitHelper($"shortlog --no-merges --numbered --summary --email {lastRelease}..HEAD")
.ToList();
var re = new Regex(@"^[\s\t]*(?'commits'\d+)[\s\t]+(?'author'.*)$");
var re = new Regex(@"^[\s\t]*(?'commits'\d+)[\s\t]+(?'author'.*)[\s\t]+<(?'email'.*)>.*$");
var summary = shortlogSummary
.Where(x => re.IsMatch(x))
.Select(x => re.Match(x))
.Select(m => new
{
commits = int.Parse(m.Groups["commits"]?.Value ?? "0"),
author = m.Groups["author"]?.Value?.Trim() ?? string.Empty,
email = m.Groups["email"]?.Value?.Trim() ?? string.Empty,
})
.ToList();

Expand All @@ -192,13 +194,18 @@ Task("CreateReleaseNotes")
foreach (var contributor in summary)
{
var stars = string.Join(string.Empty, Enumerable.Repeat(":star:", contributor.commits));
starring.Add($"{stars} {contributor.author}");
var emailInfo = debugUserEmail ? ", " + contributor.email : string.Empty;
starring.Add($"{stars} {contributor.author}{emailInfo}");
}

// Honoring aka Top Contributors
const int top3 = 3; // going to create Top 3
var topContributors = new List<string>();
// Ocelot Core team members should not be in Top 3 Chart
var coreTeamNames = new List<string> { "Raman Maksimchuk", "Raynald Messié", "Guillaume Gnaegi" };
var coreTeamEmails = new List<string> { "dotnet044@gmail.com", "redbird_project@yahoo.fr", "58469901+ggnaegi@users.noreply.github.com" };
var commitsGrouping = summary
.Where(x => !coreTeamNames.Contains(x.author) && !coreTeamEmails.Contains(x.email)) // filter out Ocelot Core team members
.GroupBy(x => x.commits)
.Select(g => new
{
Expand All @@ -210,7 +217,7 @@ Task("CreateReleaseNotes")
.ToList();

// local helpers
string[] places = new[] { "1st", "2nd", "3rd" };
string[] places = new[] { "1st", "2nd", "3rd", "4", "5", "6", "7", "8", "9", "10", "11" };
static string Plural(int n) => n == 1 ? "" : "s";
static string Honor(string place, string author, int commits, string suffix = null)
=> $"{place[0]}<sup>{place[1..]}</sup> :{place}_place_medal: goes to **{author}** for delivering **{commits}** feature{Plural(commits)} {suffix ?? ""}";
Expand Down Expand Up @@ -312,11 +319,11 @@ Task("CreateReleaseNotes")
}
} // END of Top 3

// releaseNotes.Add("### Honoring :medal_sports: aka Top Contributors :clap:");
// releaseNotes.AddRange(topContributors);
// releaseNotes.Add("");
// releaseNotes.Add("### Starring :star: aka Release Influencers :bowtie:");
// releaseNotes.AddRange(starring);
releaseNotes.Add("### Honoring :medal_sports: aka Top Contributors :clap:");
releaseNotes.AddRange(topContributors);
releaseNotes.Add("");
releaseNotes.Add("### Starring :star: aka Release Influencers :bowtie:");
releaseNotes.AddRange(starring);
releaseNotes.Add("");
releaseNotes.Add($"### Features in Release {releaseVersion}");
var commitsHistory = GitHelper($"log --no-merges --date=format:\"%A, %B %d at %H:%M\" --pretty=format:\"<sub>%h by **%aN** on %ad &rarr;</sub>%n%s\" {lastRelease}..HEAD");
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
project = 'Ocelot'
copyright = ' 2016-2024 ThreeMammals Ocelot team'
author = 'Tom Pallister, Raman Maksimchuk and Ocelot Core team at ThreeMammals'
release = '23.2'
release = '23.3'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 2 additions & 0 deletions docs/features/caching.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ The **Region** represents a region of caching.
Additionally, if a header name is defined in the **Header** property, that header value is looked up by the key (header name) in the ``HttpRequest`` headers,
and if the header is found, its value will be included in caching key. This causes the cache to become invalid due to the header value changing.

.. _cch-enablecontenthashing-option:

``EnableContentHashing`` option
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 2 additions & 0 deletions docs/features/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ You can utilize these methods in the ``ConfigureAppConfiguration`` method (locat
You can find additional details in the dedicated :ref:`di-configuration-overview` section and in subsequent sections related to the :doc:`../features/dependencyinjection` chapter.

.. _config-route-metadata:

Route Metadata
--------------

Expand Down
2 changes: 2 additions & 0 deletions docs/features/kubernetes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ If your downstream service resides in a different namespace, you can override th
}
]
.. _k8s-downstream-scheme-vs-port-names:

Downstream Scheme vs Port Names [#f3]_
--------------------------------------

Expand Down
6 changes: 6 additions & 0 deletions docs/features/qualityofservice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Next, within your ``ConfigureServices`` method, to incorporate `Polly`_ services
services.AddOcelot()
.AddPolly();
.. _qos-configuration:

Configuration
-------------

Expand All @@ -40,6 +42,8 @@ Then add the following section to a Route configuration:
- ``DurationOfBreak`` means the circuit breaker will stay open for 1 second after it is tripped.
- ``TimeoutValue`` means if a request takes more than 5 seconds, it will automatically be timed out.

.. _qos-circuit-breaker-strategy:

Circuit Breaker strategy
------------------------

Expand All @@ -62,6 +66,8 @@ Alternatively, you may omit ``DurationOfBreak`` to default to the implicit 5 sec
This setup activates only the `Circuit breaker <https://www.pollydocs.org/strategies/circuit-breaker.html>`_ strategy.

.. _qos-timeout-strategy:

Timeout strategy
----------------

Expand Down
Loading

0 comments on commit 696fa07

Please sign in to comment.