Remove Disconnected link state

Dynamically flipping from Established
to Disconnected is not the intended
usage of InstanceLink State.

- Link state starts in Adding and becomes
Established once any control node first sees the link
is in the status KnownConnectionCosts
This commit is contained in:
Seth Foster 2023-08-04 12:02:03 -04:00 committed by Seth Foster
parent ad96a72ebe
commit 3e8202590c
7 changed files with 8 additions and 36 deletions

View File

@ -36,7 +36,7 @@ class Migration(migrations.Migration):
model_name='instancelink',
name='link_state',
field=models.CharField(
choices=[('adding', 'Adding'), ('established', 'Established'), ('disconnected', 'Disconnected'), ('removing', 'Removing')],
choices=[('adding', 'Adding'), ('established', 'Established'), ('removing', 'Removing')],
default='adding',
help_text='Indicates the current life cycle stage of this peer link.',
max_length=16,

View File

@ -68,7 +68,6 @@ class InstanceLink(BaseModel):
class States(models.TextChoices):
ADDING = 'adding', _('Adding')
ESTABLISHED = 'established', _('Established')
DISCONNECTED = 'disconnected', _('Disconnected')
REMOVING = 'removing', _('Removing')
link_state = models.CharField(

View File

@ -514,11 +514,15 @@ def execution_node_health_check(node):
def inspect_established_receptor_connections(mesh_status):
'''
detect active/inactive receptor links
Flips link state from ADDING to ESTABLISHED
If the InstanceLink source and target match the entries
in Known Connection Costs, flip to Established.
'''
from awx.main.models import InstanceLink
all_links = InstanceLink.objects.all()
all_links = InstanceLink.objects.filter(link_state=InstanceLink.States.ADDING)
if not all_links.exists():
return
active_receptor_conns = mesh_status['KnownConnectionCosts']
update_links = []
for link in all_links:
@ -527,10 +531,6 @@ def inspect_established_receptor_connections(mesh_status):
if link.link_state is not InstanceLink.States.ESTABLISHED:
link.link_state = InstanceLink.States.ESTABLISHED
update_links.append(link)
else:
if link.link_state is not InstanceLink.States.DISCONNECTED:
link.link_state = InstanceLink.States.DISCONNECTED
update_links.append(link)
InstanceLink.objects.bulk_update(update_links, ['link_state'])
@ -538,7 +538,6 @@ def inspect_established_receptor_connections(mesh_status):
def inspect_execution_and_hop_nodes(instance_list):
with advisory_lock('inspect_execution_and_hop_nodes_lock', wait=False):
node_lookup = {inst.hostname: inst for inst in instance_list}
ctl = get_receptor_ctl()
mesh_status = ctl.simple_command('status')

View File

@ -252,22 +252,6 @@ function Legend() {
</DescriptionListTerm>
<DescriptionListDescription>{t`Established`}</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>
<svg width="20" height="15" xmlns="http://www.w3.org/2000/svg">
<line
x1="0"
y1="9"
x2="20"
y2="9"
stroke="#ccc"
strokeWidth="4"
strokeDasharray="6"
/>
</svg>
</DescriptionListTerm>
<DescriptionListDescription>{t`Disconnected`}</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>
<svg width="20" height="15" xmlns="http://www.w3.org/2000/svg">

View File

@ -181,7 +181,6 @@ function MeshGraph({
.data([
'end',
'end-active',
'end-disconnected',
'end-adding',
'end-removing',
])
@ -197,7 +196,6 @@ function MeshGraph({
mesh.select('#end').attr('refX', 23).attr('fill', '#6A6E73');
mesh.select('#end-removing').attr('refX', 23).attr('fill', '#C9190B');
mesh.select('#end-adding').attr('refX', 23).attr('fill', '#3E8635');
mesh.select('#end-disconnected').attr('refX', 23).attr('fill', '#CCC');
mesh.select('#end-active').attr('refX', 18).attr('fill', '#0066CC');
// Add links
@ -214,9 +212,6 @@ function MeshGraph({
.attr('x2', (d) => d.target.x)
.attr('y2', (d) => d.target.y)
.attr('marker-end', (d) => {
if (d.link_state === 'disconnected') {
return 'url(#end-disconnected)';
}
if (d.link_state === 'adding') {
return 'url(#end-adding)';
}
@ -366,9 +361,6 @@ function MeshGraph({
.style('stroke', (d) => renderLinkStatusColor(d.link_state))
.style('stroke-width', '2px')
.attr('marker-end', (d) => {
if (d.link_state === 'disconnected') {
return 'url(#end-disconnected)';
}
if (d.link_state === 'adding') {
return 'url(#end-adding)';
}

View File

@ -29,7 +29,6 @@ export const NODE_STATE_COLOR_KEY = {
export const LINK_STATE_COLOR_KEY = {
established: '#6A6E73',
disconnected: '#CCC',
adding: '#3E8635',
removing: '#C9190B',
};

View File

@ -95,7 +95,6 @@ export function redirectToDetailsPage(selectedNode, history) {
export function renderLinkState(linkState) {
const linkPattern = {
established: null,
disconnected: 3,
adding: 3,
removing: 3,
};
@ -111,7 +110,7 @@ export function getRandomInt(min, max) {
const generateRandomLinks = (n, r) => {
const links = [];
function getRandomLinkState() {
return ['established', 'adding', 'removing', 'disconnected'][
return ['established', 'adding', 'removing'][
getRandomInt(0, 3)
];
}