From f905fa16cb3b75c300698f2ee221a22cd376ec81 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Thu, 19 Dec 2024 15:21:43 +0000 Subject: [PATCH 1/6] Test / Wire in new label filtering to limited places - Wired in to - Workload detail page - pods and services (broken due to reverse selector) - Service Detail - Pods List - Service create/edit - Pod selector tab - Also - Fix showPodRestarts in random location - TODOs - Lots of testing / validation required - reverse deployment --> service selector (not services given deployment, but for each service contains pods from deployment) - workload model usages of pods getter - services model usages of pods getter - many many more.... --- shell/components/ResourceDetail/Masthead.vue | 2 +- shell/detail/service.vue | 7 +- shell/detail/workload/index.vue | 130 +++++++++++------- shell/edit/service.vue | 31 +++-- shell/models/service.js | 64 +++++++-- shell/models/workload.js | 105 ++++++++++---- shell/plugins/steve/steve-pagination-utils.ts | 108 ++++++++++++++- shell/types/kube/kube-api.ts | 19 +++ shell/types/store/pagination.types.ts | 19 ++- 9 files changed, 380 insertions(+), 105 deletions(-) create mode 100644 shell/types/kube/kube-api.ts diff --git a/shell/components/ResourceDetail/Masthead.vue b/shell/components/ResourceDetail/Masthead.vue index b92f853fe28..1c08e2a0f60 100644 --- a/shell/components/ResourceDetail/Masthead.vue +++ b/shell/components/ResourceDetail/Masthead.vue @@ -505,7 +505,7 @@ export default { class="live-date" :value="value.creationTimestamp" /> - {{ t("resourceDetail.masthead.restartCount") }}: {{ value.restartCount }} + diff --git a/shell/detail/service.vue b/shell/detail/service.vue index 6c00515b460..1fb0cb2e521 100644 --- a/shell/detail/service.vue +++ b/shell/detail/service.vue @@ -37,7 +37,8 @@ export default { }, async fetch() { - await this.value.fetchPods(); + // TODO: RC test (blocked given services bug in dev image) + this.matchingPods = await this.value.fetchPods(); }, data() { @@ -83,7 +84,7 @@ export default { return { servicePortInfoHeaders, - pods: [], + matchingPods: [], podTableHeaders: this.$store.getters['type-map/headersFor']( this.$store.getters['cluster/schemaFor'](POD) ), @@ -155,7 +156,7 @@ export default { :weight="4" > { - const { status:{ containerStatuses = [] } } = pod; + // Not used anywhere! + // podRestarts() { + // return this.value.pods.reduce((total, pod) => { + // const { status:{ containerStatuses = [] } } = pod; - if (containerStatuses.length) { - total += containerStatuses.reduce((tot, container) => { - tot += container.restartCount; + // if (containerStatuses.length) { + // total += containerStatuses.reduce((tot, container) => { + // tot += container.restartCount; - return tot; - }, 0); - } + // return tot; + // }, 0); + // } - return total; - }, 0); - }, + // return total; + // }, 0); + // }, podHeaders() { return this.$store.getters['type-map/headersFor'](this.podSchema).filter((h) => !h.name || h.name !== NAMESPACE_COL.name); @@ -213,15 +237,19 @@ export default { }, showPodGaugeCircles() { - const podGauges = Object.values(this.value.podGauges); - const total = this.value.pods.length; + const podGauges = Object.values(this.podGauges); + const total = this.matchingPods.length; return !podGauges.find((pg) => pg.count === total); }, + podGauges() { + return this.value.calcPodGauges(this.matchingPods); + }, + showJobGaugeCircles() { const jobGauges = Object.values(this.value.jobGauges); - const total = this.isCronJob ? this.totalRuns : this.value.pods.length; + const total = this.isCronJob ? this.totalRuns : this.matchingPods.length; return !jobGauges.find((jg) => jg.count === total); }, @@ -252,30 +280,30 @@ export default { async scaleUp() { await this.scale(true); }, - findMatchingServices() { - if (!this.serviceSchema) { - return []; - } - const matchingPods = this.value.pods; - - // Find Services that have selectors that match this - // workload's Pod(s). - const matchingServices = this.allServices.filter((service) => { - const selector = service.spec.selector; - - for (let i = 0; i < matchingPods.length; i++) { - const pod = matchingPods[i]; - - if (service.metadata?.namespace === this.value.metadata?.namespace && matches(pod, selector)) { - return true; - } - } - - return false; - }); - - this.matchingServices = matchingServices; - }, + // findMatchingServices() { + // if (!this.serviceSchema) { + // return []; + // } + // const matchingPods = this.value.pods; + + // // Find Services that have selectors that match this + // // workload's Pod(s). + // const matchingServices = this.allServices.filter((service) => { + // const selector = service.spec.selector; + + // for (let i = 0; i < matchingPods.length; i++) { + // const pod = matchingPods[i]; + + // if (service.metadata?.namespace === this.value.metadata?.namespace && matches(pod, selector)) { + // return true; + // } + // } + + // return false; + // }); + + // this.matchingServices = matchingServices; + // }, findMatchingIngresses() { if (!this.ingressSchema) { return []; @@ -341,15 +369,15 @@ export default { {{ isJob || isCronJob ? t('workload.detailTop.runs') :t('workload.detailTop.pods') }}