full-setup and the host swarmctl reach the controller as a pod, not through a host socket
This commit is contained in:
parent
67bf51809a
commit
64d340e385
1 changed files with 222 additions and 157 deletions
|
|
@ -330,26 +330,40 @@ pub(crate) fn describe_error(status: hyper::StatusCode, body: &[u8]) -> String {
|
|||
|
||||
/// Message for a socket that could not be dialled.
|
||||
///
|
||||
/// Worth spelling out because the three ways this fails need three
|
||||
/// different fixes and `No such file or directory (os error 2)` names
|
||||
/// none of them: the daemon is off, it binds elsewhere, or this host is
|
||||
/// not the one running it at all. No group-membership case to mention
|
||||
/// here — `swarmctl` already runs as root.
|
||||
/// The controller runs as a pod, so the host has no socket to dial: the way in
|
||||
/// is the swarm's gateway.
|
||||
pub(crate) fn connect_hint(socket: &Path) -> String {
|
||||
format!(
|
||||
"could not connect to swarm-controller at {} — is it running on this host? \
|
||||
(`systemctl status swarm-controller`). The path comes from \
|
||||
`--controller-socket` or `SWARM_CONTROLLER_SOCKET`, which the \
|
||||
swarm-controller nix module sets from `socketPath`",
|
||||
"could not connect to a swarm-controller socket at {} — the controller runs as a pod \
|
||||
and has no socket on this host; reach it through the swarm's gateway with \
|
||||
`--swarm <domain>` (or `SWARMCTL_SWARM`) after `swarmctl login`",
|
||||
socket.display()
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{check_confirmed, describe_error, parse_ident, parse_state};
|
||||
use super::{check_confirmed, connect_hint, describe_error, parse_ident, parse_state};
|
||||
use swarm_wire::wanted::AgentState;
|
||||
|
||||
/// The controller has no socket on the host, so the hint sends the operator to the
|
||||
/// gateway and the login, not to a unit that is not there.
|
||||
#[test]
|
||||
fn the_connect_hint_names_the_gateway_and_the_login() {
|
||||
let hint = connect_hint(std::path::Path::new(
|
||||
"/run/swarm-controller/controller.sock",
|
||||
));
|
||||
assert!(
|
||||
hint.contains("/run/swarm-controller/controller.sock"),
|
||||
"{hint}"
|
||||
);
|
||||
assert!(
|
||||
hint.contains("--swarm <domain>") && hint.contains("swarmctl login"),
|
||||
"{hint}"
|
||||
);
|
||||
assert!(!hint.contains("systemctl"), "{hint}");
|
||||
}
|
||||
|
||||
/// The accepted values are the wire enum's: each spelling it writes
|
||||
/// parses back, and an unknown one names the valid ones.
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue