Skip to content
This repository has been archived by the owner on Apr 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #217 from jtomasek/host-ssh-troubleshooting
Browse files Browse the repository at this point in the history
Add Host discovery troubleshooting modal
  • Loading branch information
mareklibra authored Jun 15, 2020
2 parents d5a7784 + b336fb6 commit b75a91f
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"netmask": "^1.0.6",
"node-sass": "^4.13.1",
"prettier": "^2.0.1",
"prism-react-renderer": "^1.1.1",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-redux": "^7.2.0",
Expand Down
6 changes: 5 additions & 1 deletion src/components/clusterConfiguration/BaremetalInventory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Text, TextContent, Button } from '@patternfly/react-core';
import HostsTable from '../hosts/HostsTable';
import { Cluster } from '../../api/types';
import { DiscoveryImageModalButton } from './discoveryImageModal';
import { DiscoveryTroubleshootingModalButton } from './discoveryTroubleshootingModal';

interface BareMetalInventoryProps {
cluster: Cluster;
Expand All @@ -18,7 +19,10 @@ const BaremetalInventory: React.FC<BareMetalInventoryProps> = ({ cluster }) => {
</Text>
<Text component="p">
Boot the discovery ISO on hardware that should become part of this bare metal cluster.
Hosts connected to the internet will be inspected and automatically appear below.
Hosts connected to the internet will be inspected and automatically appear below.{' '}
<DiscoveryTroubleshootingModalButton>
Hosts not showing up?
</DiscoveryTroubleshootingModalButton>
</Text>
<Text component="p">
Three master hosts are required with at least 4 CPU cores, 16 GB of RAM, and 120 GB of
Expand Down
7 changes: 5 additions & 2 deletions src/components/clusterConfiguration/discoveryImageModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export const DiscoveryImageModalButton: React.FC<DiscoveryImageModalButtonProps>

const validationSchema = Yup.object().shape({
proxyUrl: Yup.string().url('Provide a valid URL.'),
sshPublicKey: sshPublicKeyValidationSchema,
sshPublicKey: sshPublicKeyValidationSchema.required(
'SSH key is required for debugging the host registration.',
),
});

type DiscoveryImageModalProps = {
Expand Down Expand Up @@ -153,7 +155,8 @@ export const DiscoveryImageModal: React.FC<DiscoveryImageModalProps> = ({
<TextAreaField
label="SSH public key"
name="sshPublicKey"
helperText="SSH public key for debugging the installation"
helperText="SSH public key for debugging the host registration/installation"
isRequired
/>
<ModalBoxFooter>
<Button key="submit" type="submit">
Expand Down
136 changes: 136 additions & 0 deletions src/components/clusterConfiguration/discoveryTroubleshootingModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import React from 'react';
import {
Button,
Modal,
ButtonVariant,
ModalVariant,
TextContent,
Text,
TextVariants,
} from '@patternfly/react-core';
import { ToolbarButton } from '../ui/Toolbar';
import PrismCode from '../ui/PrismCode';

type DiscoveryTroubleshootingModalButtonProps = React.ComponentProps<typeof Button> & {
ButtonComponent?: typeof Button | typeof ToolbarButton;
onClick?: () => void;
};

export const DiscoveryTroubleshootingModalButton: React.FC<DiscoveryTroubleshootingModalButtonProps> = ({
ButtonComponent = Button,
onClick,
children,
...props
}) => {
const [isModalOpen, setIsModalOpen] = React.useState(false);
const closeModal = () => setIsModalOpen(false);
const handleClick = onClick || (() => setIsModalOpen(true));
return (
<>
<ButtonComponent variant={ButtonVariant.link} {...props} onClick={handleClick} isInline>
{children}
</ButtonComponent>
<DiscoveryTroubleshootingModal isOpen={isModalOpen} onClose={closeModal} />
</>
);
};

type DiscoveryTroubleshootingModalProps = {
onClose: () => void;
isOpen: boolean;
};

export const DiscoveryTroubleshootingModal: React.FC<DiscoveryTroubleshootingModalProps> = ({
onClose,
isOpen,
}) => {
return (
<Modal
title="Host Discovery Troubleshooting"
isOpen={isOpen}
actions={[
<Button key="close" variant={ButtonVariant.primary} onClick={onClose}>
Close
</Button>,
]}
onClose={onClose}
variant={ModalVariant.large}
>
<TextContent>
<Text component={TextVariants.p}>
Booting up an ISO might take a few minutes, and might depend heavily on your hardware and
network configuration, however, if you have verified that your host is on, DHCP is enabled
and yet the host does not appear in the UI, you may try to login over SSH to the host in
order to troubleshoot, for that you would need to know your machine IP-address, or use a
console such as BMC, virtual machine console etc.
</Text>
<Text component={TextVariants.h2}>SSH into your machine</Text>
<PrismCode code={`ssh core@<machine-ip>`} />
<Text component={TextVariants.p}>
The SSH key provided when generating the discovery ISO is used to authenticate the user.
It should not be required to provide the password.
</Text>
<Text component={TextVariants.h2}>
Verify that the discovery agent is running correctly
</Text>
<Text component={TextVariants.p}>Execute</Text>
<PrismCode code={`ps -ef | grep agent`} />
<Text component={TextVariants.p}>
and see whether the agent runs with correct parameters. The result should look similar to
this:
</Text>
<PrismCode
code={`root 1342 1 0 09:56 ? 00:00:00 /usr/local/bin/agent --host 192.168.39.162 --port 30956 --cluster-id a8142e14-8bfe-46bd-bfbd-4bd1a126892b core 2063 2003 0 10:41 pts/0 00:00:00 grep --color=auto agent`}
/>
<Text component={TextVariants.p}>
See that logs are indicating that agent was run successfully:
</Text>
<PrismCode
code={`[core@vm-11-47 ~]$ sudo journalctl -u agent
-- Logs begin at Mon 2020-05-25 14:02:10 UTC, end at Mon 2020-05-25 19:50:52 UTC. --
May 25 14:02:25 localhost systemd[1]: Starting agent.service...
May 25 14:02:31 vm-11-47 docker[957]: Unable to find image locally
May 25 14:02:33 vm-11-47 docker[957]: latest: Pulling from agent
May 25 14:02:33 vm-11-47 docker[957]: 5d20c808ce19: Pulling fs layer
May 25 14:02:33 vm-11-47 docker[957]: 1b657f4d2d40: Pulling fs layer
May 25 14:02:33 vm-11-47 docker[957]: 8843662234e1: Pulling fs layer
May 25 14:02:35 vm-11-47 docker[957]: 5d20c808ce19: Download complete
May 25 14:02:35 vm-11-47 docker[957]: 5d20c808ce19: Pull complete
May 25 14:02:43 vm-11-47 docker[957]: 8843662234e1: Verifying Checksum
May 25 14:02:43 vm-11-47 docker[957]: 8843662234e1: Download complete
May 25 14:03:32 vm-11-47 docker[957]: 1b657f4d2d40: Download complete
May 25 14:03:33 vm-11-47 docker[957]: 1b657f4d2d40: Pull complete
May 25 14:03:34 vm-11-47 docker[957]: 8843662234e1: Pull complete
May 25 14:03:34 vm-11-47 docker[957]: Digest: sha256:a6024573526db8ddff7ba796df29b61e09ca5ca0f1c47356088c2203d5872d16
May 25 14:03:34 vm-11-47 docker[957]: Status: Downloaded newer image
May 25 14:03:34 vm-11-47 systemd[1]: Started agent.service.`}
/>
<Text component={TextVariants.p}>If you see something like this:</Text>
<PrismCode
code={`May 17 14:01:14 localhost systemd[1]: Starting agent.service...
May 17 14:01:18 localhost docker[1013]: Unable to find image locally
May 17 14:01:33 localhost docker[1013]: /usr/bin/docker: Error response from daemon: Get https://quay.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
May 17 14:01:33 localhost docker[1013]: See '/usr/bin/docker run --help'.
May 17 14:01:33 localhost systemd[1]: agent.service: Control process exited, code=exited, status=125/n/a
May 17 14:01:33 localhost systemd[1]: agent.service: Failed with result 'exit-code'.
May 17 14:01:33 localhost systemd[1]: Failed to start agent.service.`}
/>
<Text component={TextVariants.p}>
That implies you have a networking issue, perhaps a wrong proxy or no connection to the
assisted installation service.You can use the nmcli to get additional information about
your network configuration.
</Text>
<Text component={TextVariants.h2}>Check agent logs</Text>
<PrismCode code={`[core@vm-11-47 ~]$ less /var/log/agent.log`} />
<Text component={TextVariants.h2}>Check assisted-installer logs</Text>
<PrismCode
code={`[core@vm-11-47 ~]$ sudo su
[core@vm-11-47 ~]$ podman ps -a | grep assisted-installer
[core@vm-11-47 ~]$ podman logs <container id>`}
/>
<Text component={TextVariants.h2}>Check bootkube logs</Text>
<PrismCode code={`[core@vm-11-47 ~]$ journalctl -u bootkube`} />
</TextContent>
</Modal>
);
};
4 changes: 4 additions & 0 deletions src/components/ui/PrismCode.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pre.prism-code {
padding: var(--pf-global--spacer--sm) var(--pf-global--spacer--md);
overflow-x: auto;
}
29 changes: 29 additions & 0 deletions src/components/ui/PrismCode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import Highlight, { defaultProps, Language, PrismTheme } from 'prism-react-renderer';
import { Text, TextVariants } from '@patternfly/react-core';
import defaultTheme from 'prism-react-renderer/themes/nightOwl';
import './PrismCode.css';

type PrismCodeProps = {
code: string;
language?: Language;
theme?: PrismTheme;
};

const PrismCode: React.FC<PrismCodeProps> = ({ code, language = 'bash', theme = defaultTheme }) => (
<Highlight {...defaultProps} code={code} language={language} theme={theme}>
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<Text component={TextVariants.pre} className={className} style={style}>
{tokens.map((line, i) => (
<div key={i} {...getLineProps({ line, key: i })}>
{line.map((token, key) => (
<span key={key} {...getTokenProps({ token, key })} />
))}
</div>
))}
</Text>
)}
</Highlight>
);

export default PrismCode;
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11040,6 +11040,11 @@ pretty-format@^25.5.0:
ansi-styles "^4.0.0"
react-is "^16.12.0"

prism-react-renderer@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/prism-react-renderer/-/prism-react-renderer-1.1.1.tgz#1c1be61b1eb9446a146ca7a50b7bcf36f2a70a44"
integrity sha512-MgMhSdHuHymNRqD6KM3eGS0PNqgK9q4QF5P0yoQQvpB6jNjeSAi3jcSAz0Sua/t9fa4xDOMar9HJbLa08gl9ug==

private@^0.1.6, private@^0.1.8:
version "0.1.8"
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
Expand Down

0 comments on commit b75a91f

Please sign in to comment.