-
Notifications
You must be signed in to change notification settings - Fork 261
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) { | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
@@ -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? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
@@ -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; | ||
} | ||
|
||
|
@@ -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; | ||
|
||
|
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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?