Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network Topology Dashboard Update #488

Closed
wants to merge 5 commits into from

Conversation

Dhruv-J
Copy link
Contributor

@Dhruv-J Dhruv-J commented Sep 27, 2023

This PR updates the Network Topology dashboard to include visualizations for
multiple networking layers. Specifically, the following has been changed:

  1. The source code of DependencyPanel has been modified to include the
    DiagramController class, which acts as a rendering controller for the
    mermaid diagram. This is needed after an update to the mermaid library,
    which changes the functionality of the existing mermaidAPI render function.

  2. The @grafana-toolkit tool will be deprecated soon, and will be replaced
    by @grafana/create-plugin. With the replacement, the directory structure of
    the plugin has been significantly changed, with a .config folder containing
    the specific configuration files for the plugin's build and run, with general
    configuration files in the base directory used to extend the default configs.

  3. A unit test for the DependencyPanel has been added, and it generates a
    simple graph and checks the DOM for the expected graph string being present.

Additionally, this PR builds upon #417, which adds additional fields for L7
visibility.

@codecov
Copy link

codecov bot commented Sep 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.60%. Comparing base (79010a7) to head (ea9b703).
Report is 24 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #488      +/-   ##
==========================================
+ Coverage   70.51%   70.60%   +0.09%     
==========================================
  Files          40       45       +5     
  Lines        5253     5511     +258     
  Branches        0       41      +41     
==========================================
+ Hits         3704     3891     +187     
- Misses       1372     1436      +64     
- Partials      177      184       +7     
Flag Coverage Δ *Carryforward flag
kind-e2e-tests 62.48% <ø> (ø) Carriedforward from 3dd2dc7
kind-multi-cluster-e2e-tests 43.17% <ø> (ø)
python-coverage 55.75% <ø> (ø) Carriedforward from 3dd2dc7
unit-tests 70.17% <ø> (+0.02%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

see 5 files with indirect coverage changes

@Dhruv-J
Copy link
Contributor Author

Dhruv-J commented Sep 27, 2023

Screenshot 2023-09-27 at 3 00 53 AM

Currently, the legend is shown as a paragraph, but I can make it more visual as well. Also looking into making the mermaid charts themselves bigger

@Dhruv-J
Copy link
Contributor Author

Dhruv-J commented Sep 27, 2023

For reviewers, a lot of files needed to be added as a result of the yarn tool being updated from toolkit to the Grafana command itself. This update comes with a lot more surrounding configuration, and is necessary for anyone wanting to build the plugin locally. The contents of the .config/ folder can be ignored, as they were automatically generated by the command yarn create @grafana/plugin migrate. The additional configuration I needed to get it working was the file webpack.config.ts file. To sum up, the code outside of the plugin directory, and both DiagramController.tsx and DependencyPanel.tsx are the main files within the PR that need to be reviewed.

@yuntanghsu
Copy link
Contributor

Why do we have duplicated connections in layer 4/7 Topology? Or are they two different connections?
For Layer 4 Topology, is svc_antrea-test-3 the endpoint of web-server-3?

@Dhruv-J
Copy link
Contributor Author

Dhruv-J commented Sep 27, 2023

Why do we have duplicated connections in layer 4/7 Topology? Or are they two different connections?

They are two different connections

For Layer 4 Topology, is svc_antrea-test-3 the endpoint of web-server-3?

Yes, the goal of the layer 4 topology is to show destination Pod and Service, I'll update the legend to reflect that.

@heanlan
Copy link
Contributor

heanlan commented Sep 27, 2023

Please correct me if I'm wrong. I remember last time we decided to use the chord diagrams to show the flows and use a table to display all the L7 fields. Did I miss anything?

@Dhruv-J
Copy link
Contributor Author

Dhruv-J commented Sep 27, 2023

Please correct me if I'm wrong. I remember last time we decided to use the chord diagrams to show the flows and use a table to display all the L7 fields. Did I miss anything?

Not wrong at all, I'm splitting them up into two PRs, with the latter having the second dashboard with the chord diagram and httpvals table. Since httpvals contains nested JSON, some massaging to the data is required.

Copy link
Contributor

@yuntanghsu yuntanghsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments:

  1. Do we need a .config folder? I don't see this folder under other plugins?
  2. Do you think we can add these changes to the e2e test or UT?
  3. Can you update network-flow-visibility.md to reflect these changes?

build/charts/theia/README.md Outdated Show resolved Hide resolved
}
},
"queryType": "sql",
"rawSql": "SELECT sourcePodName, sourcePodLabels, sourcePodNamespace, sourceNodeName, destinationPodName, destinationPodLabels, destinationNodeName, destinationServicePortName, octetDeltaCount FROM flows\nWHERE sourcePodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND destinationPodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND ( destinationPodName != '' OR sourcePodName != '' )\nAND octetDeltaCount != 0\nAND httpVals == ''\nAND $__timeFilter(flowEndSeconds)\nORDER BY flowEndSeconds DESC",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct me if I'm wrong.
I think we don't have case where destinationPodName == '' and sourcePodName == ''.?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had it as a failsafe, but I'll remove that conditional

Copy link
Contributor

@tushartathgur tushartathgur Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

"type": "grafana-clickhouse-datasource",
"uid": "PDEE91DDB90597936"
},
"description": "The different colors of the lines mean different codes, but are labelled by the content length of the flow.\nGreen: Success",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing description for other colors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove description, as the legend describes the colors anyways.

"weekStart": ""
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing empty line at the end of the file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not fixed?

@@ -212,3 +212,9 @@ ALTER TABLE tadetector_local
DROP COLUMN aggType,
DROP COLUMN direction,
DROP COLUMN podName;
ALTER TABLE flows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these changes be in 000005_0-6-0.down.sql or in next version like 000006_0-7-0.down.sql?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are changes part of Tushar's commit and PR, I just have them in this PR as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR has been updated, Please use the new fields and files

@@ -151,3 +151,9 @@ ALTER TABLE tadetector_local
ADD COLUMN aggType String,
ADD COLUMN direction String,
ADD COLUMN podName String;
ALTER TABLE flows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -211,7 +211,7 @@ grafana:
installPlugins:
- https://downloads.antrea.io/artifacts/grafana-custom-plugins/theia-grafana-sankey-plugin-1.0.2.zip;theia-grafana-sankey-plugin
- https://downloads.antrea.io/artifacts/grafana-custom-plugins/theia-grafana-chord-plugin-1.0.1.zip;theia-grafana-chord-plugin
- https://downloads.antrea.io/artifacts/grafana-custom-plugins/theia-grafana-dependency-plugin-1.0.2.zip;theia-grafana-dependency-plugin
- https://github.com/Dhruv-J/grafana-dependency-plugin/archive/refs/tags/v0.zip;theia-grafana-dependency-plugin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


# Inject livereload script into grafana index.html
USER root
RUN sed -i 's/<\/body><\/html>/<script src=\"http:\/\/localhost:35729\/livereload.js\"><\/script><\/body><\/html>/g' /usr/share/grafana/public/views/index.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing empty line here.

@@ -0,0 +1,3 @@
{
"extends": "./.config/.eslintrc"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing empty line not solved?

};
// Prettier configuration provided by Grafana scaffolding
...require("./.config/.prettierrc.js")
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@Dhruv-J
Copy link
Contributor Author

Dhruv-J commented Sep 28, 2023

  1. Do we need a .config folder? I don't see this folder under other plugins?

Yes, as I mentioned in my comment earlier, the .config folder is created as a result of upgrading the tool used to create, build, and sign plugins. The old tool will be deprecated soon, and there will be another PR that updates all the plugins to have such a configuration. Older plugins don't have this since they haven't been rebuilt or upgraded to have it, but it is a necessary folder for anyone wishing to build the plugin locally or make changes to its source code. The additional config file I added was weback.config.ts within the base grafana-dependency-plugin directory, which was provided by a Grafana dev.

  1. Do you think we can add these changes to the e2e test or UT?

The network topology dashboard already has a unit test, which I included when I originally made the dashboard. It simply checks the query to see if it returns expected values.

  1. Can you update network-flow-visibility.md to reflect these changes?

Yes, will do.

@@ -3571,11 +3626,11 @@ data:
}
},
"queryType": "sql",
"rawSql": "SELECT sourcePodName, sourcePodLabels, sourcePodNamespace, sourceNodeName, destinationPodName, destinationPodLabels, destinationNodeName, destinationServicePortName, octetDeltaCount FROM flows\nWHERE sourcePodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND destinationPodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND destinationPodName != ''\nAND sourcePodName != ''\nAND octetDeltaCount != 0\nAND $__timeFilter(flowEndSeconds)\nORDER BY flowEndSeconds DESC",
"rawSql": "SELECT sourcePodName, sourcePodLabels, sourcePodNamespace, sourceNodeName, sourceIP, sourceTransportPort, destinationPodName, destinationPodLabels, destinationNodeName, destinationServicePortName, destinationIP, destinationTransportPort, octetDeltaCount, httpVals FROM flows\nWHERE sourcePodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND destinationPodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND ( destinationPodName != '' OR sourcePodName != '' )\nAND octetDeltaCount != 0\nAND httpVals != ''\nAND $__timeFilter(flowEndSeconds)\nORDER BY flowEndSeconds DESC",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not getting l7ProtocolName? how are we checking if the flow is L7 and which protocol is used in the flow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since only http protocols are being exported, right now I only check for httpVals existing. Once new protocols are added, their JSON will need to be parsed differently as well, so a patch PR can be made.

"singleQuote": true,
"useTabs": false,
"tabWidth": 2
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve all empty line issues

} else {
graphLine = graphLine + destinationIP + ':' + destinationPort;
}
// graphLine = sourceIP + ':' + sourcePort + ' --' + frameHttpInfo.ContentLength + '--> ' + destinationIP + ':' + destinationPort + '\n';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line?

}
},
"queryType": "sql",
"rawSql": "SELECT sourcePodName, sourcePodLabels, sourcePodNamespace, sourceNodeName, destinationPodName, destinationPodLabels, destinationNodeName, destinationServicePortName, octetDeltaCount FROM flows\nWHERE sourcePodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND destinationPodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND ( destinationPodName != '' OR sourcePodName != '' )\nAND octetDeltaCount != 0\nAND httpVals == ''\nAND $__timeFilter(flowEndSeconds)\nORDER BY flowEndSeconds DESC",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use l7ProtocolName to filter L4 flows

@@ -212,3 +212,9 @@ ALTER TABLE tadetector_local
DROP COLUMN aggType,
DROP COLUMN direction,
DROP COLUMN podName;
ALTER TABLE flows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR has been updated, Please use the new fields and files

@@ -80,6 +80,8 @@ clickhouse client -n -h 127.0.0.1 <<-EOSQL
clusterUUID String,
egressName String,
egressIP String,
isL7 Bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l7ProtocolName?

@@ -60,11 +101,11 @@
}
},
"queryType": "sql",
"rawSql": "SELECT sourcePodName, sourcePodLabels, sourcePodNamespace, sourceNodeName, destinationPodName, destinationPodLabels, destinationNodeName, destinationServicePortName, octetDeltaCount FROM flows\nWHERE sourcePodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND destinationPodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND destinationPodName != ''\nAND sourcePodName != ''\nAND octetDeltaCount != 0\nAND $__timeFilter(flowEndSeconds)\nORDER BY flowEndSeconds DESC",
"rawSql": "SELECT sourcePodName, sourcePodLabels, sourcePodNamespace, sourceNodeName, sourceIP, sourceTransportPort, destinationPodName, destinationPodLabels, destinationNodeName, destinationServicePortName, destinationIP, destinationTransportPort, octetDeltaCount, httpVals FROM flows\nWHERE sourcePodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND destinationPodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND ( destinationPodName != '' OR sourcePodName != '' )\nAND octetDeltaCount != 0\nAND httpVals != ''\nAND $__timeFilter(flowEndSeconds)\nORDER BY flowEndSeconds DESC",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use l7ProtocolName
Refer to Adding L7 visibility fields

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need to check httpVals regardless, since I need to parse its JSON in a specific manner, so I assumed it was redundant to check both. If needed, I can make a later patch that checks the protocolName and parses the JSON accordingly.

}
},
"queryType": "sql",
"rawSql": "SELECT sourcePodName, sourcePodLabels, sourcePodNamespace, sourceNodeName, destinationPodName, destinationPodLabels, destinationNodeName, destinationServicePortName, octetDeltaCount FROM flows\nWHERE sourcePodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND destinationPodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND ( destinationPodName != '' OR sourcePodName != '' )\nAND octetDeltaCount != 0\nAND httpVals == ''\nAND $__timeFilter(flowEndSeconds)\nORDER BY flowEndSeconds DESC",
Copy link
Contributor

@tushartathgur tushartathgur Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@Dhruv-J
Copy link
Contributor Author

Dhruv-J commented Oct 4, 2023

Will further update README and changelog to reflect latest changes.

@@ -33,7 +33,7 @@ function print_usage {


TESTBED_CMD=$(dirname $0)"/kind-setup.sh"
FLOW_VISIBILITY_CH_ONLY_CMD=$(dirname $0)"/../../hack/generate-manifest.sh --no-grafana --node-port --secure-connection"
FLOW_VISIBILITY_CH_ONLY_CMD=$(dirname $0)"/../../hack/generate-manifest.sh --ch-only --node-port --secure-connection"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove changes not belong to this PR? Do rebase?

@@ -114,7 +143,8 @@ installed panels will appear. For more information, visit the docs on [Grafana p

Users can customize the panel by editing its options and choosing to group the
diagram based on a chosen Pod label. It is also possible to change the color
of the Pod squares in the diagram.
of the Pod squares in the diagram. Additionally, users can switch betwen layer
4 and layer 7 visualizations.

<img src="https://user-images.githubusercontent.com/10016630/233191376-7cf471b8-5e3e-473a-8696-da25ab981066.png" width="400" alt="Panel Option Editor View">

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to update the section 4 as you already migrate the dependency-plugin from grafana/toolkit to create-plugin?

@@ -217,6 +217,10 @@ jobs:
docker tag antrea/theia-clickhouse-monitor:latest projects.registry.vmware.com/antrea/theia-clickhouse-monitor:latest
docker load -i clickhouse-server.tar
docker tag antrea/theia-clickhouse-server:latest projects.registry.vmware.com/antrea/theia-clickhouse-server:latest
- name: Remove Theia images tar files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to update the typescript.yaml in workflow as well?

@Dhruv-J
Copy link
Contributor Author

Dhruv-J commented Oct 18, 2023

Unit tests are proving to be challenging to setup with updated toolkit versions, will make patch PR for them separately.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why we have these two empty files here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not solved?

Copy link
Contributor

@heanlan heanlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add more details into the PR descriptions? including the your changes from the following aspects and why we need those changes:

  1. data schema
  2. dependency plugin source code changes, with newly added diagramController
  3. dependency upgrade of dependency plugin, which introduces .config, jest folders, etc
  4. newly added UT

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not solved?

.github/workflows/typescript.yml Show resolved Hide resolved
}
},
"queryType": "sql",
"rawSql": "SELECT sourcePodName, sourcePodLabels, sourcePodNamespace, sourceNodeName, destinationPodName, destinationPodLabels, destinationNodeName, destinationServicePortName, octetDeltaCount FROM flows\nWHERE sourcePodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND destinationPodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')\nAND ( destinationPodName != '' OR sourcePodName != '' )\nAND octetDeltaCount != 0\nAND httpVals == ''\nAND $__timeFilter(flowEndSeconds)\nORDER BY flowEndSeconds DESC",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I missed something, but why we enforce ( destinationPodName != '' OR sourcePodName != '' ) for layer 4 but accept ip+port for layer 7?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove them for both, that condition should be true by default

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty file?

@@ -0,0 +1,3 @@
{
"extends": "./.config/.eslintrc"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing empty line not solved?

props.width = 600,
props.height = 600;
props.options = {};
let component = shallow(<DependencyPanel {...props} />);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yuntanghsu could you help take a look at this UT as you recently modified chord/sankey plugins UT and have some experience with how we should design react UTs? I feel like we can also reference to your latest change https://github.com/antrea-io/theia/blob/main/plugins/grafana-custom-plugins/grafana-chord-plugin/src/ChordPanel.test.tsx, but not very sure whether it's also applicable here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are doing a similar test, which verifies the input data reflected in the output component.
But I think we can also verify the context for [boxColor, layerLevelFour, themeColors]? And maybe we can add one more input for layerSeven as the format of GraphString of these two layer graphs are different?


renderCallback(svgCode: string, bindFunctions: any) {
if (this && bindFunctions) {
console.log('binding diagram functions');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug log can be removed?

let boxColor;
let layerLevel;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need an extra var layerLevel? Can we just reuse options.layerFour this boolean var?

return sourcePodName;
}

let groupByPodLabel = options.groupByPodLabel;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question, can we reuse options.groupByPodLabel without introducing new variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i can change this one

function layerSevenGraph() {
function getColorFromStatus(httpStatus: string) {
// colors that correspond to each of the types of http response code; i.e. 4xx and 5xx codes return red to symbolize errors
const colors = ['orange', 'green', 'blue', 'red', 'red'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest just use a map data structure or case switch statement for this function, rather than the status first char matching colors list index.

Copy link
Contributor Author

@Dhruv-J Dhruv-J Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of checking the first character because it would allow all response codes that are within the 100 possible codes range to be represented. Since all 4xx codes are error codes, and all 2xx are success codes, I just checked the first character. I can put the underlying logic into a case switch however, that would be cleaner.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the first char is ok. But I think the list index thing is not a common practice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we can combine the first char matching with a case switch statement.

@heanlan
Copy link
Contributor

heanlan commented Nov 1, 2023

A general note: If the pull request isn't prepared for review yet, feel free to change its status to draft. If it is ready, I suggest consolidating certain intermediate and less relevant commits that might not provide meaningful information to reviewers.

@Dhruv-J Dhruv-J force-pushed the dashboard-improvements branch 2 times, most recently from 3df3912 to 72f071e Compare November 6, 2023 19:34
This PR updates the Network Topology dashboard to include visualizations for
multiple networking layers. It also updates the legends of both graphs to
improve readability.

Signed-off-by: Dhruv-J <dhruvj@vmware.com>
Signed-off-by: Dhruv-J <dhruvj@vmware.com>
"weekStart": ""
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not fixed?

};
// Prettier configuration provided by Grafana scaffolding
...require("./.config/.prettierrc.js")
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

AND octetDeltaCount != 0
AND $__timeFilter(flowEndSeconds)
WHERE sourcePodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')
AND destinationPodNamespace NOT IN ('kube-system', 'flow-visibility', 'flow-aggregator')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Kind cluster, there will be 1 more Namespace 'local-path-storage'. Do we want to exclude that as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, how can I test this change locally?

"start": "yarn watch"
"build": "webpack -c ./webpack.config.ts --env production",
"dev": "webpack -w -c ./webpack.config.ts --env development",
"e2e": "yarn exec cypress install && yarn exec grafana-e2e run",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can follow this PR #587 to remove some unused scripts and dependencies in this PR to avoid some Vulnerability alerts bumped up after this PR is merged.
Note:
Not all dependencies detected by depcheck is unused.

props.width = 600,
props.height = 600;
props.options = {};
let component = shallow(<DependencyPanel {...props} />);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are doing a similar test, which verifies the input data reflected in the output component.
But I think we can also verify the context for [boxColor, layerLevelFour, themeColors]? And maybe we can add one more input for layerSeven as the format of GraphString of these two layer graphs are different?

renderedHtmlString.includes(expectedGraphString)
).toEqual(true);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty line.

}
}
"extends": "./.config/tsconfig.json"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

});
};

export default config;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@Dhruv-J
Copy link
Contributor Author

Dhruv-J commented Nov 14, 2023

But I think we can also verify the context for [boxColor, layerLevelFour, themeColors]?

Those are used directly into the theme, and in order to test them, the mermaid components would directly need to be tested, which doesn't seem possible because the component gets split up upon rendering in the DOM, and cannot be checked for directly.

And maybe we can add one more input for layerSeven as the format of GraphString of these two layer graphs are different?

Yes, will do

Signed-off-by: Dhruv-J <dhruvj@vmware.com>
Signed-off-by: Dhruv-J <dhruvj@vmware.com>
// colors that correspond to each of the types of http response code; i.e. 4xx and 5xx codes return red to symbolize errors
const codeToColor = {1:'orange', 2:'green', 3:'blue', 4:'red', 5:'red'};
let statusType = +httpStatus.charAt(0);
if (statusType < 1 || statusType > 5) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for us to get statusType < 1 or > 5? Is there such a http status code? I see you added it for indicating errors, but I wonder whether it is possible to happen, if it does happen, would it be better to catch this error in Flow Exporter or Flow Aggregator? cc @tushartathgur

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should, but we can double check with @tushartathgur.

ref={this.setDiagramRef}
className={`diagram-seven`}
></div>
<div><p>In this graph, each flow between a source and destination is represented by an arrow labelled with the http content length of the data being sent.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a legend/sentence to explain how the colors are mapped to http codes, e.g. 1xx(informational response), 2xx(success), etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can add a sentence below at the end.

Signed-off-by: Dhruv-J <dhruvj@vmware.com>
@Dhruv-J
Copy link
Contributor Author

Dhruv-J commented Dec 12, 2023

Instructions for those wanting to deploy the solution for themselves:

  1. pull Antrea PR #5218
  2. pull Theia PR Adding new Clickhouse fields for NP visibility #417 and this PR
  3. execute the included script for build_antrea.sh.zip
  4. deploy flow-visibility.yml from the new theia PR
  5. apply the following: pods.yaml.zip
  6. annotate the pods with the following command: kubectl pod annotate <pod-name> -n <namespace> [visibility.antrea.io/enable-l7=both](http://visibility.antrea.io/enable-l7=both)
  7. kubectl exec into the applied admin pod and run the command curl example.com to get one row, or curl example.com example.com example.com to get multiple rows (it'll take about 2 minutes to populate clickhouse)
  8. open the network topology dashboard to view http flows

Copy link
Contributor

@heanlan heanlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Let's wait for all the required PRs getting merged first and give the final approval on this

Copy link

This PR is stale because it has been open 90 days with no activity. Remove stale label or comment, or this will be closed in 90 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants