Skip to content

Commit

Permalink
Msg/update chrony receiver (#13863)
Browse files Browse the repository at this point in the history
* Fixed issue with trying to read from socket

* Adding changelog

* Updated readme

* Fixing typo
  • Loading branch information
MovieStoreGuy committed Sep 7, 2022
1 parent 2db61c0 commit 3817f98
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions receiver/chronyreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ The following options can be customised:
- The allowed formats are the following
- udp://hostname:port
- unix:///path/to/chrony.sock (Please note the triple slash)
- unixgram:///path/to/chrony/sock
- The network type `unix` will be converted to `unixgram` but both are permissible
- timeout (optional) - The total amount of time allowed to read and process the data from chronyd
- Recommendation: This value should be set above 1s to allow `chronyd` time to respond
- collection_interval (optional) - how frequent this receiver should poll [chrony]
Expand Down
5 changes: 4 additions & 1 deletion receiver/chronyreceiver/internal/chrony/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ func SplitNetworkEndpoint(addr string) (network, endpoint string, err error) {
if host == "" {
return "", "", fmt.Errorf("missing hostname: %w", ErrInvalidNetwork)
}
case "unix":
case "unix", "unixgram":
if _, err := os.Stat(endpoint); err != nil {
return "", "", err
}
// Chrony uses socket type DGRAM which converts to `unixgram`,
// in order to preserve configuration of existing clients, this will overwrite the network type
network = "unixgram"
default:
return "", "", fmt.Errorf("unknown network %s: %w", network, ErrInvalidNetwork)
}
Expand Down
2 changes: 1 addition & 1 deletion receiver/chronyreceiver/internal/chrony/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestSplitNetworkEndpoint(t *testing.T) {
{
scenario: "A valid UNIX network",
in: fmt.Sprintf("unix://%s", path),
network: "unix",
network: "unixgram",
endpoint: path,
err: nil,
},
Expand Down
16 changes: 16 additions & 0 deletions unreleased/msg_update-chrony-receiver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: chronyreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: When trying to read from socket, the socket type was incorrect

# One or more tracking issues related to the change
issues: [13862]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

0 comments on commit 3817f98

Please sign in to comment.