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

task: Add banner encouraging edge upgrade #6018

Merged
merged 4 commits into from
Jan 24, 2024
Merged

Conversation

chriswk
Copy link
Member

@chriswk chriswk commented Jan 24, 2024

Only triggers if there is any rows in client instances that have

sdk_version: unleash-edge with version < 17.0.0

The function that checks this memoizes the check for 10 minutes to avoid scanning the client instances table too often.

@chriswk chriswk self-assigned this Jan 24, 2024
Copy link

vercel bot commented Jan 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 24, 2024 0:23am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2024 0:23am

@chriswk chriswk force-pushed the task/addUpgradeEdgeBanner branch from e24be66 to 847d570 Compare January 24, 2024 09:01
Only triggers if there is any rows in client instances that have
sdk_version: unleash-edge with version < 17.0.0

The function that checks this memoizes the check for 10 minutes at the
time to avoid scanning the client instances table too often.
@chriswk
Copy link
Member Author

chriswk commented Jan 24, 2024

Don't approve yet, I'm fixing the possible SQL Injection first.

<ConditionallyRender
condition={displayUpgradeEdgeBanner}
show={<Banner key={'upgradeEdge'} banner={upgradeEdgeBanner} />}
/>
Copy link
Member

Choose a reason for hiding this comment

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

Similarly to #5239 (comment) - I would recommend we create a new EdgeUpgradeBanner (or similar) component and add it directly to App.tsx. I don't think it makes much sense to add it here, especially as it is not an internal banner.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. Will fix

Copy link
Contributor

@gastonfournier gastonfournier left a comment

Choose a reason for hiding this comment

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

Looks good just a small thing around handling SemVer I think it's a safety check that's not hurtful to add. But Granting the approval as I don't expect that to happen, but just being extra cautious could be a good thing here

Comment on lines 233 to 242
const semver = new SemVer(sdkVersion);
const instancesOfSdk =
await this.clientInstanceStore.getBySdkName(sdkName);
return instancesOfSdk.some((instance) => {
if (instance.sdkVersion) {
const [_sdkName, sdkVersion] = instance.sdkVersion.split(':');
const instanceUsedSemver = new SemVer(sdkVersion);
return instanceUsedSemver < semver;
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I was just checking that SemVer can throw some exceptions: https://github.com/npm/node-semver/blob/main/classes/semver.js and we have a helper class that does the try catch: https://github.com/Unleash/unleash/blob/chore/update-features-created-by-user-id/src/lib/util/semver.ts maybe we should just try catch here

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. Good point. I'll have a look

@@ -79,6 +79,7 @@ export type UiFlags = {
executiveDashboard?: boolean;
changeRequestConflictHandling?: boolean;
feedbackComments?: Variant;
displayUpgradeEdgeBanner?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Might be worth considering making this a Variant flag instead. That way we can control not only whether the banner is shown, but also its contents through the flag.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is something we'd like to have in OSS deploys as well, and hopefully not for very long.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, I think having it as a normal flag is fine.

Copy link
Member

@nunogois nunogois left a comment

Choose a reason for hiding this comment

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

LG, but like mentioned in https://github.com/Unleash/unleash/pull/6018/files#r1464683982, I don't think it belongs inside InternalBanners.

@chriswk
Copy link
Member Author

chriswk commented Jan 24, 2024

LG, but like mentioned in https://github.com/Unleash/unleash/pull/6018/files#r1464683982, I don't think it belongs inside InternalBanners.

It's no longer in InternalBanners.

@chriswk chriswk enabled auto-merge (squash) January 24, 2024 13:10
<>
<ConditionallyRender
condition={displayUpgradeEdgeBanner}
show={<Banner key={'upgradeEdge'} banner={upgradeEdgeBanner} />}
Copy link
Member

Choose a reason for hiding this comment

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

No need for key here, since it's only 1 element.

Copy link
Member

@nunogois nunogois left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for addressing my comment 🙌

@chriswk chriswk merged commit 17d826d into main Jan 24, 2024
13 checks passed
@chriswk chriswk deleted the task/addUpgradeEdgeBanner branch January 24, 2024 14:22
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