40 Commits

Author SHA1 Message Date
tehut
d709accaf5 Add nomad monitor export command (#26178)
* Add MonitorExport command and handlers
* Implement autocomplete
* Require nomad in serviceName
* Fix race in StreamReader.Read
* Add and use framer.Flush() to coordinate function exit
* Add LogFile to client/Server config and read NomadLogPath in rpcHandler instead of HTTPServer
* Parameterize StreamFixed stream size
2025-08-01 10:26:59 -07:00
hashicorp-copywrite[bot]
f005448366 [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
James Rasell
4848bfadec cli: stream both stdout and stderr when following an alloc. (#16556)
This update changes the behaviour when following logs from an
allocation, so that both stdout and stderr files streamed when the
operator supplies the follow flag. The previous behaviour is held
when all other flags and situations are provided.

Co-authored-by: Luiz Aoqui <luiz@hashicorp.com>
2023-04-04 10:42:27 +01:00
Lance Haig
0e74431b01 Update ioutil library references to os and io respectively for API and Plugins package (#16330)
No user facing changes so I assume no change log is required
2023-03-08 10:25:09 -06:00
Benjamin Buzbee
dc6b08851d Return buffered text from log endpoint if decoding fails (#15558)
To see why I think this is a good change lets look at why I am making it

My disk was full, which means GC was happening agressively. So by the
time I called the logging endpoint from the SDK, the logs were GC'd

The error I was getting before was:
```
invalid character 'i' in literal false (expecting 'l')
```

Now the error I get is:
```
failed to decode log endpoint response as JSON: "failed to list entries: open /tmp/nomad.data.4219353875/alloc/f11fee50-2b66-a7a2-d3ec-8442cb3d557a/alloc/logs: no such file or directory"
```

Still not super descriptive but much more debugable
2023-01-16 10:39:56 +01:00
Tim Gross
fccc49a5eb api: document warnings for setting api.ClientConnTimeout (#14122)
HTTP API consumers that have network line-of-sight to client nodes can connect
directly for a small number of APIs. But in environments where the consumer
doesn't have line-of-sight, there's a long pause waiting for the
`api.ClientConnTimeout` to expire. Warn about this in the API docs so that
authors can avoid the extra timeout.
2022-08-15 16:06:02 -04:00
Ryo Nakao
97dc6875e0 Ensure to close StreamFrame channel (#12248) 2022-03-28 10:28:23 -04:00
Mahmood Ali
298c528839 cli: recover from client ACL lookup failures
This fixes a bug in the CLI handling of node lookup failures when
querying allocation and FS endpoints.

Allocation and FS endpoint are handled by the client; one can query the
relevant client directly, or query a server to have it forwarded
transparently to relevant client.  Querying the client directly is
benefecial to avoid loading servers with IO.

As an optimization, the CLI attempts to query the client directly, but
then falls back to using server forwarding path if it encounters network
or connection errors (e.g. clients are locked down or in a separate
inaccessible network).

Here, we fix a bug where if the CLI fails to find to lookup the client
details because it lacks ACL capability or other unexpected reasons, the
CLI will not go through fallback path.
2019-10-04 11:23:59 -04:00
Preetha Appan
f7f41c42e6 Infer content type in alloc fs stat endpoint 2019-06-28 20:31:28 -05:00
Michael Schurter
41f05dc2c4 api: never return EOF from Logs error chan
Closing the frames chan is the only race-free way to signal to receivers
that all frames have been sent and no errors have occurred.

If EOF is sent on error chan receivers may not receive the last frame
(or frames since the chan is buffered) before receiving the error.

Closing frames is the idiomatic way of signaling there is no more data
to be read from a chan.
2018-05-02 10:46:16 -07:00
Charlie Voiselle
c728a2feb8 Changed "til" to "until"
Should be "till" or "until"; chose "until" because it is unambiguous as to meaning.
2018-04-11 12:36:28 -05:00
Alex Dadgar
4f2725bb98 Enhance API pkg to utilize Server's Client Tunnel
This PR enhances the API package by having client only RPCs route
through the server when they are low cost and for filesystem access to
first attempt a direct connection to the node and then falling back to
a server routed request.
2018-02-15 13:59:03 -08:00
Alex Dadgar
46ab2d69b1 handle errors when streaming logs 2017-09-19 10:37:49 -05:00
Alex Dadgar
26643fc141 Fix logs/fs commands
This PR fixes an assignment to a nil map in the api pkg related to
accessing logs and the filesystem of allocations.

Fixes https://github.com/hashicorp/nomad/issues/3115
2017-08-28 22:21:54 -07:00
Michael Schurter
2f30827205 Refactor GetNodeClient weirdness
- No need to for a pointer to a pointer
- Properly set and use QueryOptions.Region
2017-08-28 14:41:21 -07:00
Michael Schurter
1bb8a54ffb Fix TLS support in api pkg / cli
Fixes #3013

It's a little weird that Client now has a method for returning a
NewClient, but it's a convenient way to dedupe the logic to
connect-directly-to-a-node which is nontrivial and had sutble
differences between locations.
2017-08-28 11:46:28 -07:00
Luke Farnell
7a56971508 fixed all spelling mistakes for goreport 2017-08-07 17:13:05 -04:00
Michael Schurter
73da65d566 Fix TLS use in AllocFS API and region/dc detection 2017-03-27 17:38:16 -07:00
Diptanu Choudhury
722433b4f9 Making the cli use TLS if the client has enabled TLS 2016-10-26 11:13:53 -07:00
Alex Dadgar
fdaf530813 api.fs uses the api.Client rather than making raw requests 2016-07-28 14:27:17 -07:00
Alex Dadgar
67fe934342 control-c works 2016-07-25 11:16:54 -07:00
Alex Dadgar
b65fd2624e Support non-following logs 2016-07-25 11:16:54 -07:00
Alex Dadgar
8cb4f76a65 remove file events and last offset 2016-07-25 11:16:01 -07:00
Alex Dadgar
ac1cfd1821 unblock the readers to add liveness when using -n 2016-07-25 11:16:01 -07:00
Alex Dadgar
2530f7bd40 initial api and command 2016-07-25 11:16:01 -07:00
Alex Dadgar
a1b46b3a6d Allow following of files when cating and fix offsets 2016-07-13 15:33:17 -06:00
Alex Dadgar
991220b5c7 implement -n for tail 2016-07-13 13:26:09 -06:00
Alex Dadgar
25dd45c763 frames to reader 2016-07-12 17:34:32 -06:00
Alex Dadgar
3cc13aeca1 initial comments 2016-07-11 10:58:18 -06:00
Alex Dadgar
4f7c5fa502 StreamFramer encapsulates the sending, heartbeating and batching behavior of frames 2016-07-10 13:57:04 -04:00
Alex Dadgar
3159859949 initial command implementation 2016-07-10 13:57:04 -04:00
Diptanu Choudhury
c8f74a3d9c Added the /fs/cat/ api 2016-03-28 11:06:22 -07:00
Diptanu Choudhury
0f9657d122 Not trying to parse response if the body is not a json 2016-01-27 21:39:50 -08:00
Diptanu Choudhury
12ffecf021 Added more information about files 2016-01-27 14:20:10 -08:00
Diptanu Choudhury
a906b7747b Changed the api of the ReadAt API 2016-01-27 12:53:24 -08:00
Diptanu Choudhury
9491295027 Introducing an AllocFileInfo in the api package 2016-01-27 12:53:24 -08:00
Diptanu Choudhury
d706878112 Added the cli for fs-cat 2016-01-27 12:53:23 -08:00
Diptanu Choudhury
a2db48ec60 Added an impl for stating a file 2016-01-27 12:53:23 -08:00
Diptanu Choudhury
89452e7a9c Added some comments 2016-01-27 12:53:23 -08:00
Diptanu Choudhury
40a205f466 Added the cli for listing alloc dir 2016-01-27 12:53:23 -08:00