mirror of https://github.com/rancher/dashboard.git
Clean up loadAgents
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
parent
89ee23acf6
commit
ff17acf028
|
|
@ -393,38 +393,25 @@ export default {
|
||||||
this.canViewAgents = !!this.$store.getters['cluster/schemaFor'](WORKLOAD_TYPES.DEPLOYMENT);
|
this.canViewAgents = !!this.$store.getters['cluster/schemaFor'](WORKLOAD_TYPES.DEPLOYMENT);
|
||||||
|
|
||||||
if (this.canViewAgents) {
|
if (this.canViewAgents) {
|
||||||
if (!this.currentCluster.isLocal) {
|
if (this.currentCluster.isLocal) {
|
||||||
try {
|
await this.setAgent('fleet', WORKLOAD_TYPES.DEPLOYMENT, 'cattle-fleet-system/fleet-controller');
|
||||||
this.cattle = await this.$store.dispatch('cluster/find', {
|
} else {
|
||||||
type: WORKLOAD_TYPES.DEPLOYMENT,
|
await this.setAgent('fleet', WORKLOAD_TYPES.STATEFUL_SET, 'cattle-fleet-system/fleet-agent');
|
||||||
id: 'cattle-system/cattle-cluster-agent'
|
await this.setAgent('cattle', WORKLOAD_TYPES.DEPLOYMENT, 'cattle-system/cattle-cluster-agent');
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
this.cattle = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scaling Up/Down cattle deployment causes web sockets disconnection;
|
// Scaling Up/Down cattle deployment causes web sockets disconnection;
|
||||||
this.interval = setInterval(() => {
|
this.interval = setInterval(() => {
|
||||||
this.disconnected = !!this.$store.getters['cluster/inError']({ type: NODE });
|
this.disconnected = !!this.$store.getters['cluster/inError']({ type: NODE });
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
try {
|
async setAgent(agent, type, id) {
|
||||||
this.fleet = await this.$store.dispatch('cluster/find', {
|
try {
|
||||||
/**
|
this[agent] = await this.$store.dispatch('cluster/find', { type, id });
|
||||||
* local cluster
|
} catch (err) {
|
||||||
* - deployment: cattle-fleet-system/fleet-controller
|
this[agent] = null;
|
||||||
* - statefulset: cattle-fleet-local-system/fleet-agent
|
|
||||||
* downstream rke2 cluster
|
|
||||||
* - deployment: none
|
|
||||||
* - statefulset: cattle-fleet-system/fleet-agent
|
|
||||||
*/
|
|
||||||
type: this.currentCluster.isLocal ? WORKLOAD_TYPES.DEPLOYMENT : WORKLOAD_TYPES.STATEFUL_SET,
|
|
||||||
id: `cattle-fleet-system/${ this.currentCluster.isLocal ? 'fleet-controller' : 'fleet-agent' }`,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
this.fleet = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -449,16 +436,16 @@ export default {
|
||||||
return STATES_ENUM.HEALTHY;
|
return STATES_ENUM.HEALTHY;
|
||||||
},
|
},
|
||||||
|
|
||||||
getAgentStatus(agent, disconnected = false) {
|
getAgentStatus(resource, disconnected = false) {
|
||||||
if (agent === 'loading') {
|
if (resource === 'loading') {
|
||||||
return STATES_ENUM.IN_PROGRESS;
|
return STATES_ENUM.IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!agent || disconnected || agent.status.conditions?.find((c) => c.status !== 'True') || agent.metadata.state?.error) {
|
if (!resource || disconnected || resource.status.conditions?.find((c) => c.status !== 'True') || resource.metadata.state?.error) {
|
||||||
return STATES_ENUM.UNHEALTHY;
|
return STATES_ENUM.UNHEALTHY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent.spec.replicas !== agent.status.readyReplicas || agent.status.unavailableReplicas > 0) {
|
if (resource.spec.replicas !== resource.status.readyReplicas || resource.status.unavailableReplicas > 0) {
|
||||||
return STATES_ENUM.WARNING;
|
return STATES_ENUM.WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue