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

Adding version check to startup #2567

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Adding version check to startup #2567

wants to merge 12 commits into from

Conversation

JerryNixon
Copy link
Contributor

Closes #3292

Why make this change?

It is easy to continue running an outdated version of Data API builder after a newer version has been released to NuGet. This PR updates the startup process, checking the current version against the latest version available on NuGet.

What is this change?

  1. Introducing Azure.DataApiBuilder.Product.VersionChecker.
  2. Validating the versions during Program.Main().
  3. Write out a log message only; this does NOT exit the engine.

How was this tested?

  • Integration Tests
  • Unit Tests

Sample Request(s)

  • Example REST and/or GraphQL request to demonstrate modifications
  • Example of CLI usage to demonstrate modifications

@@ -27,6 +27,13 @@ public class Program

public static void Main(string[] args)
{
// Compare current version of DAB with latest (non-rc) version in NuGet.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this change work for the docker scenario too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'd need to test to be sure. My gut says no.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it fails to reach NuGet it does not emit a warning.

@@ -27,6 +28,13 @@ public class Program

public static void Main(string[] args)
{
// Compare current version of DAB with latest (non-rc) version in NuGet.
VersionChecker.GetVersions(out string? latestVersion, out string? currentVersion);
if (!string.IsNullOrEmpty(latestVersion) && latestVersion != currentVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

what if people clone the repo, their currentVersion might be > latestVersion. Saying newer version is available doesn't make sense in that scenario, we should check for latestVersion > currentVersion

Copy link
Contributor

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

Great idea, but left some questions and suggestions to consider.

latestVersion = FetchLatestNuGetVersion();
currentVersion = GetCurrentVersionFromAssembly(Assembly.GetCallingAssembly());
nugetVersion = FetchLatestNuGetVersion();
localVersion = ProductInfo.GetProductVersion(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: name the argument that is passed to GetProductVersion with value false for better readability..

currentVersion = GetCurrentVersionFromAssembly(Assembly.GetCallingAssembly());
nugetVersion = FetchLatestNuGetVersion();
localVersion = ProductInfo.GetProductVersion(false);
return string.IsNullOrEmpty(nugetVersion) || nugetVersion == localVersion;
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the localVersion is > than the nugetVersion? Could happen when people clone our repo and we are in the process of developing 1.5, But nuget version will be 1.4 in that timeframe.

public class VersionCheckTests
{
[TestMethod]
public void GetVersions_LatestVersionNotNull()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public void GetVersions_LatestVersionNotNull()
public void GetVersions_NugetVersionNotNull()

Copy link
Contributor

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

Good to move to dab validate for starters. PR description needs to be updated accordingly.

Still waiting for checking what happens if currentVersion > nugetVersion - could happen when people clone the repo and use the cli from the cloned build.

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.

4 participants