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

Fleet Performance Improvements #12413

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions shell/components/fleet/FleetRepos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
FLEET_REPO_PER_CLUSTER_STATE

} from '@shell/config/table-headers';
import { FLEET } from '@shell/config/labels-annotations';
import { STATES_ENUM } from '@shell/plugins/dashboard-store/resource-class';

// i18n-ignore repoDisplay
Expand Down Expand Up @@ -118,12 +117,6 @@ export default {
parseTargetMode(row) {
return row.targetInfo?.mode === 'clusterGroup' ? this.t('fleet.gitRepo.warningTooltip.clusterGroup') : this.t('fleet.gitRepo.warningTooltip.cluster');
},

clusterViewResourceStatus(row) {
return row.clusterResourceStatus.find((c) => {
return c.metadata?.labels[FLEET.CLUSTER_NAME] === this.clusterId;
});
}
},
};
</script>
Expand Down
3 changes: 0 additions & 3 deletions shell/detail/fleet.cattle.io.cluster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ export default {
},

computed: {
allBundleDeployments() {
return this.value.bundleDeployments;
},
clusterId() {
return this.value?.metadata?.labels[FLEET_LABELS.CLUSTER_NAME];
},
Expand Down
58 changes: 33 additions & 25 deletions shell/models/fleet.cattle.io.gitrepo.js
Copy link
Member

Choose a reason for hiding this comment

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

Regarding get targetClusters() { that can be overriden via fleet.yaml so this code can't really deduct the targeted clusters anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

ouch, as in the gitrepo resource has a native targetClusters property?

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
STATES_ENUM, colorForState, mapStateToEnum, primaryDisplayStatusFromCount, stateDisplay, stateSort
} from '@shell/plugins/dashboard-store/resource-class';
import { NAME } from '@shell/config/product/explorer';
import devConsole from 'utils/dev-console';

function quacksLikeAHash(str) {
if (str.match(/^[a-f0-9]{40,}$/i)) {
Expand Down Expand Up @@ -323,14 +324,18 @@ export default class GitRepo extends SteveModel {
get resourcesStatuses() {
const clusters = this.targetClusters || [];
const resources = this.status?.resources || [];
const conditions = this.status?.conditions || [];
// const conditions = this.status?.conditions || [];
// const bundleDeployments = this.bundleDeployments || [];

const out = [];

for (const c of clusters) {
Copy link
Member

Choose a reason for hiding this comment

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

This code assumes each resource is installed on every cluster. This is not always the case. Users can for example use targetCustomization to deploy resources only to some clusters. Additionally, popular charts install different resources depending on the k8s version of the cluster. Some charts even allow to deploy "extraObjects" via a helm chart value. 🤷

const clusterBundleDeploymentResources = this.bundleDeployments
.find((bd) => bd.metadata?.labels?.[FLEET_ANNOTATIONS.CLUSTER] === c.metadata.name)
?.status?.resources || [];
devConsole.warn('model', 'gitrepo', 'resourcesStatuses', c.id);

// FIXME: if we can drop this can we drop bundleDeployments entirely (and only keep for graph view)?
// const clusterBundleDeploymentResources = bundleDeployments
// .find((bd) => bd.metadata?.labels?.[FLEET_ANNOTATIONS.CLUSTER] === c.metadata.name)
// ?.status?.resources || [];

resources.forEach((r, i) => {
let namespacedName = r.name;
Expand All @@ -339,9 +344,10 @@ export default class GitRepo extends SteveModel {
namespacedName = `${ r.namespace }:${ r.name }`;
}

let state = r.state;
let state = r.state; // FIXME: why assign r.state when it's always overwritten?

const perEntry = r.perClusterState?.find((x) => x.clusterId === c.id);
const tooMany = r.perClusterState?.length >= 10 || false;
const tooMany = r.perClusterState?.length >= 10 || false; // FIXME: shouldn't we not calc perEntry if there are too many?
Copy link
Member

@manno manno Oct 30, 2024

Choose a reason for hiding this comment

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

Additionally, in the current implementation Fleet creates an incomplete flag on the resource and shouldn't add more than 10 perCluster states.


if (perEntry) {
state = perEntry.state;
Expand All @@ -366,30 +372,32 @@ export default class GitRepo extends SteveModel {
};

out.push({
key: `${ r.id }-${ c.id }-${ r.type }-${ r.namespace }-${ r.name }`,
tableKey: `${ r.id }-${ c.id }-${ r.type }-${ r.namespace }-${ r.name }-${ randomStr(8) }`,
kind: r.kind,
apiVersion: r.apiVersion,
type: r.type,
id: r.id,
namespace: r.namespace,
name: r.name,
clusterId: c.id,
clusterLabel: c.metadata.labels[FLEET_ANNOTATIONS.CLUSTER_NAME],
clusterName: c.nameDisplay,
state: mapStateToEnum(state),
stateBackground: color,
stateDisplay: display,
stateSort: stateSort(color, display),
key: `${ r.id }-${ c.id }-${ r.type }-${ r.namespace }-${ r.name }`,
tableKey: `${ r.id }-${ c.id }-${ r.type }-${ r.namespace }-${ r.name }-${ randomStr(8) }`,
kind: r.kind,
apiVersion: r.apiVersion,
type: r.type,
id: r.id,
namespace: r.namespace,
name: r.name,
clusterId: c.id,
clusterLabel: c.metadata.labels[FLEET_ANNOTATIONS.CLUSTER_NAME],
clusterName: c.nameDisplay,
state: mapStateToEnum(state),
stateBackground: color,
stateDisplay: display,
stateSort: stateSort(color, display),
namespacedName,
detailLocation,
conditions: conditions[i],
bundleDeploymentStatus: clusterBundleDeploymentResources?.[i],
creationTimestamp: clusterBundleDeploymentResources?.[i]?.createdAt
// conditions: conditions[i], // FIXME: i is index of resource in status?.resources, what relation does that have to status?.conditions
// bundleDeploymentStatus: clusterBundleDeploymentResources?.[i], // FIXME: i is index of resource in status?.resources, does that match bundledeplopyment status.resources?
// creationTimestamp: clusterBundleDeploymentResources?.[i]?.createdAt
});
});
}

devConsole.warn('model', 'gitrepo', 'resourcesStatuses', 'end');

return out;
}

Expand All @@ -404,7 +412,7 @@ export default class GitRepo extends SteveModel {
};
}

get clusterResourceStatus() {
get clusterResourceStatus() { // here
const clusterStatuses = this.resourcesStatuses.reduce((prev, curr) => {
const { clusterId, clusterLabel } = curr;

Expand Down
Loading