|
|
@@ -334,65 +334,43 @@ const LogSection: React.FC<Props> = ({
|
|
|
return () => clearInterval(checkForAgentInterval);
|
|
|
}, [isPorterAgentInstalling]);
|
|
|
|
|
|
- const checkForAgent = () => {
|
|
|
+ const checkForAgent = async () => {
|
|
|
const project_id = currentProject?.id;
|
|
|
const cluster_id = currentCluster?.id;
|
|
|
|
|
|
- api
|
|
|
- .detectPorterAgent("<token>", {}, { project_id, cluster_id })
|
|
|
- .then((res) => {
|
|
|
- if (res.data?.version != "v3") {
|
|
|
- setHasPorterAgent(false);
|
|
|
- } else {
|
|
|
- // next, check whether logs can be queried - if they can, we're good to go
|
|
|
- const filters = {
|
|
|
- revision: currentChart.version.toString(),
|
|
|
- match_prefix: currentChart.name,
|
|
|
- };
|
|
|
-
|
|
|
- api
|
|
|
- .getLogPodValues("<TOKEN>", filters, {
|
|
|
- project_id: currentProject.id,
|
|
|
- cluster_id: currentCluster.id,
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- setHasPorterAgent(true);
|
|
|
- setIsPorterAgentInstalling(false);
|
|
|
- setIsLoading(false);
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- // do nothing - this is expected while installing
|
|
|
- setLogsError(err);
|
|
|
- setIsLoading(false);
|
|
|
- });
|
|
|
-
|
|
|
- const agentImage = res.data?.image;
|
|
|
- if (!isAgentVersionUpdated(agentImage)) {
|
|
|
- setFilters([
|
|
|
- {
|
|
|
- name: "pod_name",
|
|
|
- displayName: "Service",
|
|
|
- default: GenericLogFilter.getDefaultOption("pod_name"),
|
|
|
- options: services?.map(s => {
|
|
|
- return GenericFilterOption.of(s.name, `${s.name}-${s.type == "worker" ? "wkr" : s.type}`)
|
|
|
- }) ?? [],
|
|
|
- setValue: (value: string) => {
|
|
|
- setSelectedFilterValues((s) => ({
|
|
|
- ...s,
|
|
|
- pod_name: value,
|
|
|
- }));
|
|
|
- }
|
|
|
- },
|
|
|
- ])
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- if (err.response?.status === 404) {
|
|
|
- setHasPorterAgent(false);
|
|
|
- setIsLoading(false);
|
|
|
- }
|
|
|
- });
|
|
|
+ if (!project_id || !cluster_id) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ const res = await api.detectPorterAgent("<token>", {}, { project_id, cluster_id });
|
|
|
+
|
|
|
+ setHasPorterAgent(true);
|
|
|
+
|
|
|
+ const agentImage = res.data?.image;
|
|
|
+ if (!isAgentVersionUpdated(agentImage)) {
|
|
|
+ setFilters([
|
|
|
+ {
|
|
|
+ name: "pod_name",
|
|
|
+ displayName: "Service",
|
|
|
+ default: GenericLogFilter.getDefaultOption("pod_name"),
|
|
|
+ options: services?.map(s => {
|
|
|
+ return GenericFilterOption.of(s.name, `${s.name}-${s.type == "worker" ? "wkr" : s.type}`)
|
|
|
+ }) ?? [],
|
|
|
+ setValue: (value: string) => {
|
|
|
+ setSelectedFilterValues((s) => ({
|
|
|
+ ...s,
|
|
|
+ pod_name: value,
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ])
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ if (err.response?.status === 404) {
|
|
|
+ setHasPorterAgent(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
const installAgent = async () => {
|