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

App upgrade notification shown for incorrect app (corrected filters and added further tests) #10180

Closed
wants to merge 13 commits into from

Conversation

cnotv
Copy link
Member

@cnotv cnotv commented Dec 18, 2023

Summary

Fixes #9613

Changes are the same of #9806, except that repoType, repoName, chartName are not mandatory anymore, as they will just return no charts if none of the criteria is provided.
If parameters are provided, only charts with all of them will be returned.

Occurred changes and/or fixed issues

Technical notes summary

Added tests for:

  • Chart match logic
    • Check given only all matching parameters if provided for Epinio case.
    • Check given any matching parameter for returning always charts if anything matches (reason this is reopened).
  • Chart install view version selection

Kubewarden installation

I have a 2 breaking errors when I try locally with master to install Kubewarden to reproduce the mentioned case:

  • Copy to clipboard says function does not exists
  • addChart says the repo is actually null

After setting conditional variables it works, although I keep it for another time, since my PR covered already more than needed and the error is on master as well (also just when running locally).

Areas or cases that should be tested

Areas which could experience regressions

Screenshot/Video

Screenshot 2023-12-18 at 19 59 31

@github-actions github-actions bot added this to the v2.8.next1 milestone Dec 18, 2023
@cnotv cnotv marked this pull request as draft December 20, 2023 13:03
@cnotv cnotv force-pushed the feature/9613-chart-upgrade-mixup branch 2 times, most recently from 313d3a8 to 4496e57 Compare January 10, 2024 17:40
@cnotv cnotv requested a review from richard-cox January 11, 2024 21:55
@cnotv cnotv marked this pull request as ready for review January 11, 2024 21:55
@cnotv
Copy link
Member Author

cnotv commented Jan 12, 2024

Also I noticed that we had already a talk about tests for Kubewarden here:
#9232

Copy link
Member

@richard-cox richard-cox left a comment

Choose a reason for hiding this comment

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

@jordojordo Can you validate kube warden side is fine? In the description Giuseppe mentions some kubewarden strageness

version: string,
}

export interface IChart {
Copy link
Member

Choose a reason for hiding this comment

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

The chart in our store represented by this interlaces comes from https://github.com/rancher/dashboard/blob/master/shell/store/catalog.js#L505. Via comment i think this should reference that, and vice versa

Copy link
Member Author

Choose a reason for hiding this comment

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

I am aware of the JS file which I'm not going to touch 😄
What are you suggesting about the interface? I did not get it.

Copy link
Member

Choose a reason for hiding this comment

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

This would just be to link the two together. So if someone updates the object they also know to update the interface, or want to know where the object is instantiated.

/* 
 * ...
 * Created in `addChart` shell/store/catalog.js
 */
export interface IChart
// Instance of `IChart`
obj = classify(ctx, {

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh but I have absolutely no idea what do we have there, so I have just put what I know and then later someone will have to update just as I did, otherwise nobody would ever write anything, no?

Copy link
Member

Choose a reason for hiding this comment

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

That's fine, but can you still add the suggested comments?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah absolutely, just taking time :)

@@ -0,0 +1,30 @@
export interface IChartVersions {
Copy link
Member

Choose a reason for hiding this comment

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

The object this interface represents in from the entries collection from catalog.cattle.io.clusterrepos.

I think this should be called something like IClusterRepoChart

The object IChart if for is constructed locally (https://github.com/rancher/dashboard/blob/master/shell/store/catalog.js#L505.). Suggest this one is called IDashboardChart.

That makes it cleared what each one is.

chartNameDisplay: string;
}

export interface IChartOptions {
Copy link
Member

Choose a reason for hiding this comment

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

Suggest this one be renamed to something like 'IFilterChartOptions` to differentiate it from other options to do with charts

const newestChart = versions?.[0];
const newestVersion = newestChart?.version;

if ( !thisVersion || !newestVersion ) {
Copy link
Member

Choose a reason for hiding this comment

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

this check, for truthy currentChartVersion and newestVersion, has been lost. i noticed that compare now has

if (in1 === undefined && in2 === undefined) {
    return null;
}

if that was meant for a replacement, would vote to keep compare untouched and to bring it back to this context (as compare is used in other places). So it would be

if (!currentChartVersion || !newestVersion) {
    return null;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

It fails if I keep as it is, I'll try to check what I can do.
Ideally would be convenient to have real data to understand better the suggestion.

const newestChart = versions?.[0];
const newestVersion = newestChart?.version;

if ( !thisVersion || !newestVersion ) {
Copy link
Member

Choose a reason for hiding this comment

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

Apart from the check for undefined above, the other changes in upgradeAvailable are just tidying up? just want to be sure i haven't missed something

@@ -40,69 +41,48 @@ export default class CatalogApp extends SteveModel {
}

matchingChart(includeHidden) {
const chart = this.spec?.chart;

if ( !chart ) {
Copy link
Member

Choose a reason for hiding this comment

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

this early exit has been lost

});

describe('as latest version', () => {
it('excluding pre-releases', () => {
Copy link
Member

Choose a reason for hiding this comment

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

the title of this test is wrong, it returns the success case where there is an upgrade available

expect(catalogApp.upgradeAvailable).toStrictEqual(expectation);
});

it('if no version is available', () => {
Copy link
Member

Choose a reason for hiding this comment

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

this is the same as above (should it include catalogApp.spec = { chart: { metadata: { } } };?)

Copy link
Member Author

Choose a reason for hiding this comment

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

No it's not necessary for computation.

Copy link
Member

Choose a reason for hiding this comment

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

to check explicitly for a missing version it would need to get passed the check for a missing chart and spec. so by providing the object above the test should hit the code that it's aiming to check.

as it stands the test is the same as for if no chart and doesn't exercise anything different

Copy link
Member Author

Choose a reason for hiding this comment

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

but the test is passing, otherwise we are missing one and I did not realize it.

Copy link
Member

Choose a reason for hiding this comment

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

the two tests if no chart and if no version is available are exactly the same. both tests should provide and env such that only the condition referenced in the test title is exercised

repoName: 'rancher-charts',
},
{ chartName: 'rancher-alerting-drivers' },
{ repoType: 'cluster' },
Copy link
Member

Choose a reason for hiding this comment

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

given only repo type or repo name i don't think we should match any chart in that repo. feels like the minimum would be the chart name

@cnotv
Copy link
Member Author

cnotv commented Jan 19, 2024

@jordojordo Can you validate kube warden side is fine? In the description Giuseppe mentions some kubewarden strageness

It seems to crash just in case of lack of charts, so I omitted it.

@jordojordo
Copy link
Member

jordojordo commented Jan 19, 2024

The sections where I previously had trouble with the catalog/chart getter have been resolved as I've added the repoName and repoType to each instance of those calls.

addChart says the repo is actually null

I didn't notice any issues here.

Copy to clipboard says function does not exists

I did run into the issue with the $copyText method not existing where I have used the CopyCode component here. I'm not sure how that's related to this PR, it's possible this was created/fixed somewhere else.

copy-code.mp4

@cnotv
Copy link
Member Author

cnotv commented Sep 5, 2024

Closing since is outdated and replaced by a new issue: #11465

@cnotv cnotv closed this Sep 5, 2024
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.

App upgrade notification shown for incorrect app
4 participants