Revert "[#1262] sdnotify: Get rid of go:linkname for nanotime"
All checks were successful
DCO action / DCO (pull_request) Successful in 1m22s
Tests and linters / Run gofumpt (pull_request) Successful in 1m28s
Build / Build Components (1.21) (pull_request) Successful in 2m25s
Build / Build Components (1.22) (pull_request) Successful in 2m23s
Vulncheck / Vulncheck (pull_request) Successful in 2m9s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m45s
Tests and linters / Staticcheck (pull_request) Successful in 3m1s
Tests and linters / Tests (1.22) (pull_request) Successful in 3m5s
Tests and linters / Tests (1.21) (pull_request) Successful in 3m10s
Tests and linters / Lint (pull_request) Successful in 3m24s
Tests and linters / Tests with -race (pull_request) Successful in 3m29s
Tests and linters / gopls check (pull_request) Successful in 3m39s

This reverts commit 327d364f34.

Reverted due to the problem with reload signal sent by systemd.
`frostfs-ir` service reconfigures correctly and service's
statuses are being reported to systemd. However, since we
replaced `go:linkname` & `nanotime()` with `time.Since()`,
systemd refuses to accept reload signal response from
`frostfs-ir`. To maintain correct behaviour it was decided to
revevrt systemd-related changes until a better solution is
found.

Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
Ekaterina Lebedeva 2024-08-14 13:55:34 +03:00
parent d055168e2a
commit 5da41f1fe5
3 changed files with 13 additions and 3 deletions

View file

@ -0,0 +1,10 @@
package sdnotify
import (
// For go:linkname to work.
_ "unsafe"
)
//go:noescape
//go:linkname nanotime runtime.nanotime
func nanotime() int64

View file

@ -0,0 +1,2 @@
// The file is intentionally empty.
// It is a workaround for https://github.com/golang/go/issues/15006

View file

@ -6,7 +6,6 @@ import (
"net" "net"
"os" "os"
"strings" "strings"
"time"
) )
const ( const (
@ -17,7 +16,6 @@ const (
var ( var (
socket *net.UnixAddr socket *net.UnixAddr
start = time.Now()
errSocketVariableIsNotPresent = errors.New("\"NOTIFY_SOCKET\" environment variable is not present") errSocketVariableIsNotPresent = errors.New("\"NOTIFY_SOCKET\" environment variable is not present")
errSocketIsNotInitialized = errors.New("socket is not initialized") errSocketIsNotInitialized = errors.New("socket is not initialized")
@ -53,7 +51,7 @@ func FlagAndStatus(status string) error {
// must be sent, containing "READY=1". // must be sent, containing "READY=1".
// //
// For MONOTONIC_USEC format refer to https://www.man7.org/linux/man-pages/man3/sd_notify.3.html // For MONOTONIC_USEC format refer to https://www.man7.org/linux/man-pages/man3/sd_notify.3.html
status += fmt.Sprintf("\nMONOTONIC_USEC=%d", uint64(time.Since(start))/1e3 /* microseconds in nanoseconds */) status += fmt.Sprintf("\nMONOTONIC_USEC=%d", uint64(nanotime())/1e3 /* microseconds in nanoseconds */)
} }
status += "\nSTATUS=" + strings.TrimSuffix(status, "=1") status += "\nSTATUS=" + strings.TrimSuffix(status, "=1")
return Send(status) return Send(status)