Merge pull request #818 from hakman/updated-coreos-systemd

Update github.com/coreos/go-systemd to v22.5.0
This commit is contained in:
Kubernetes Prow Robot
2023-09-20 16:12:01 -07:00
committed by GitHub
12 changed files with 117 additions and 11 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ require (
contrib.go.opencensus.io/exporter/stackdriver v0.13.14
github.com/acobaugh/osrelease v0.1.0
github.com/avast/retry-go v3.0.0+incompatible
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/coreos/go-systemd/v22 v22.5.0
github.com/euank/go-kmsg-parser v2.0.0+incompatible
github.com/hpcloud/tail v1.0.0
github.com/prometheus/client_model v0.4.0
+2 -2
View File
@@ -315,11 +315,11 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-systemd v0.0.0-20161114122254-48702e0da86b/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU=
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
@@ -25,7 +25,7 @@ import (
"strings"
"time"
"github.com/coreos/go-systemd/sdjournal"
"github.com/coreos/go-systemd/v22/sdjournal"
"k8s.io/klog/v2"
"k8s.io/node-problem-detector/pkg/systemlogmonitor/logwatchers/types"
@@ -24,7 +24,7 @@ import (
"testing"
"time"
"github.com/coreos/go-systemd/sdjournal"
"github.com/coreos/go-systemd/v22/sdjournal"
"github.com/stretchr/testify/assert"
"k8s.io/node-problem-detector/pkg/systemlogmonitor/logwatchers/types"
@@ -0,0 +1,57 @@
// Copyright 2015 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//go:build linux
// +build linux
package dlopen
// #include <string.h>
// #include <stdlib.h>
//
// int
// my_strlen(void *f, const char *s)
// {
// size_t (*strlen)(const char *);
//
// strlen = (size_t (*)(const char *))f;
// return strlen(s);
// }
import "C"
import (
"fmt"
"unsafe"
)
func strlen(libs []string, s string) (int, error) {
h, err := GetHandle(libs)
if err != nil {
return -1, fmt.Errorf(`couldn't get a handle to the library: %v`, err)
}
defer h.Close()
f := "strlen"
cs := C.CString(s)
defer C.free(unsafe.Pointer(cs))
strlen, err := h.GetSymbolPointer(f)
if err != nil {
return -1, fmt.Errorf(`couldn't get symbol %q: %v`, f, err)
}
len := C.my_strlen(strlen, cs)
return int(len), nil
}
@@ -16,7 +16,7 @@
package sdjournal
import (
"github.com/coreos/go-systemd/internal/dlopen"
"github.com/coreos/go-systemd/v22/internal/dlopen"
"sync"
"unsafe"
)
@@ -300,6 +300,24 @@ package sdjournal
// return sd_journal_get_catalog(j, ret);
// }
//
// int
// my_sd_id128_get_boot(void *f, sd_id128_t *boot_id)
// {
// int(*sd_id128_get_boot)(sd_id128_t *);
//
// sd_id128_get_boot = f;
// return sd_id128_get_boot(boot_id);
// }
//
// char *
// my_sd_id128_to_string(void *f, sd_id128_t boot_id, char s[SD_ID128_STRING_MAX])
// {
// char *(*sd_id128_to_string)(sd_id128_t, char *);
//
// sd_id128_to_string = f;
// return sd_id128_to_string(boot_id, s);
// }
//
import "C"
import (
"bytes"
@@ -928,7 +946,7 @@ func (j *Journal) SeekHead() error {
}
// SeekTail may be used to seek to the end of the journal, i.e. the most recent
// available entry. This call must be followed by a call to Next before any
// available entry. This call must be followed by a call to Previous before any
// call to Get* will return data about the last element.
func (j *Journal) SeekTail() error {
sd_journal_seek_tail, err := getFunction("sd_journal_seek_tail")
@@ -1118,3 +1136,34 @@ func (j *Journal) GetCatalog() (string, error) {
return catalog, nil
}
// GetBootID get systemd boot id
func (j *Journal) GetBootID() (string, error) {
sd_id128_get_boot, err := getFunction("sd_id128_get_boot")
if err != nil {
return "", err
}
var boot_id C.sd_id128_t
r := C.my_sd_id128_get_boot(sd_id128_get_boot, &boot_id)
if r < 0 {
return "", fmt.Errorf("failed to get boot id: %s", syscall.Errno(-r).Error())
}
sd_id128_to_string, err := getFunction("sd_id128_to_string")
if err != nil {
return "", err
}
id128StringMax := C.size_t(C.SD_ID128_STRING_MAX)
c := (*C.char)(C.malloc(id128StringMax))
defer C.free(unsafe.Pointer(c))
C.my_sd_id128_to_string(sd_id128_to_string, boot_id, c)
bootID := C.GoString(c)
if len(bootID) <= 0 {
return "", fmt.Errorf("get boot id %s is not valid", bootID)
}
return bootID, nil
}
+4 -4
View File
@@ -82,10 +82,10 @@ github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1
# github.com/cespare/xxhash/v2 v2.2.0
## explicit; go 1.11
github.com/cespare/xxhash/v2
# github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
## explicit
github.com/coreos/go-systemd/internal/dlopen
github.com/coreos/go-systemd/sdjournal
# github.com/coreos/go-systemd/v22 v22.5.0
## explicit; go 1.12
github.com/coreos/go-systemd/v22/internal/dlopen
github.com/coreos/go-systemd/v22/sdjournal
# github.com/davecgh/go-spew v1.1.1
## explicit
github.com/davecgh/go-spew/spew