mirror of https://github.com/rancher/dashboard.git
Merge pull request #7364 from richard-cox/hpa-target
Ensure HPA cannot be associated with workloads owned by others
This commit is contained in:
commit
31d97ef460
|
|
@ -156,7 +156,7 @@ export default {
|
|||
workloadRows() {
|
||||
const params = this.$route.params;
|
||||
const { id } = params;
|
||||
const rows = flatten(compact(this.allWorkloads)).filter(row => row.showAsWorkload);
|
||||
const rows = flatten(compact(this.allWorkloads)).filter(row => !row.ownedByWorkload);
|
||||
const namespacedRows = filter(rows, ({ metadata: { namespace } }) => namespace === id);
|
||||
|
||||
return namespacedRows;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,10 @@ export default {
|
|||
Object.values(SCALABLE_WORKLOAD_TYPES)
|
||||
.flatMap(type => this.$store.getters['cluster/all'](type))
|
||||
.filter(
|
||||
wl => wl.metadata.namespace === this.value.metadata.namespace
|
||||
// Filter out anything that has an owner, which should probably be the one with the HPA
|
||||
// For example ReplicaSets can be associated with a HPA (https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/#replicaset-as-a-horizontal-pod-autoscaler-target)
|
||||
// but wouldn't make sense if it's owned by a deployment
|
||||
wl => wl.metadata.namespace === this.value.metadata.namespace && !wl.ownedByWorkload
|
||||
)
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ export default {
|
|||
}
|
||||
|
||||
for ( const row of typeRows ) {
|
||||
if (!this.allTypes || row.showAsWorkload) {
|
||||
if (!this.allTypes || !row.ownedByWorkload) {
|
||||
out.push(row);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ export default class Workload extends WorkloadService {
|
|||
return ports;
|
||||
}
|
||||
|
||||
get showAsWorkload() {
|
||||
get ownedByWorkload() {
|
||||
const types = Object.values(WORKLOAD_TYPES);
|
||||
|
||||
if (this.metadata?.ownerReferences) {
|
||||
|
|
@ -507,12 +507,12 @@ export default class Workload extends WorkloadService {
|
|||
const have = (`${ owner.apiVersion.replace(/\/.*/, '') }.${ owner.kind }`).toLowerCase();
|
||||
|
||||
if ( types.includes(have) ) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
get isFromNorman() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue