Skip to content

Commit

Permalink
Remove Disconnected link state
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fosterseth committed Aug 4, 2023
1 parent 12a9fe4 commit a775222
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 36 deletions.
2 changes: 1 addition & 1 deletion awx/main/migrations/0187_hop_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion awx/main/models/ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
13 changes: 6 additions & 7 deletions awx/main/tasks/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,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:
Expand All @@ -474,18 +478,13 @@ 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'])


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')

Expand Down
16 changes: 0 additions & 16 deletions awx/ui/src/screens/TopologyView/Legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
8 changes: 0 additions & 8 deletions awx/ui/src/screens/TopologyView/MeshGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ function MeshGraph({
.data([
'end',
'end-active',
'end-disconnected',
'end-adding',
'end-removing',
])
Expand All @@ -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
Expand All @@ -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)';
}
Expand Down Expand Up @@ -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)';
}
Expand Down
1 change: 0 additions & 1 deletion awx/ui/src/screens/TopologyView/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const NODE_STATE_COLOR_KEY = {

export const LINK_STATE_COLOR_KEY = {
established: '#6A6E73',
disconnected: '#CCC',
adding: '#3E8635',
removing: '#C9190B',
};
Expand Down
3 changes: 1 addition & 2 deletions awx/ui/src/screens/TopologyView/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export function redirectToDetailsPage(selectedNode, history) {
export function renderLinkState(linkState) {
const linkPattern = {
established: null,
disconnected: 3,
adding: 3,
removing: 3,
};
Expand All @@ -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)
];
}
Expand Down

0 comments on commit a775222

Please sign in to comment.