mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 20:17:41 +00:00
Merge pull request #128967 from liggitt/datatimestampfloat
Record dataTimestamp as float
This commit is contained in:
commit
46623bcf21
@ -116,8 +116,8 @@ func RecordTokenGenAttempt(err error) {
|
|||||||
tokenGenReqTotal.WithLabelValues(getErrorCode(err)).Inc()
|
tokenGenReqTotal.WithLabelValues(getErrorCode(err)).Inc()
|
||||||
}
|
}
|
||||||
|
|
||||||
func RecordKeyDataTimeStamp(timestamp int64) {
|
func RecordKeyDataTimeStamp(timestamp float64) {
|
||||||
dataTimeStamp.WithLabelValues().Set(float64(timestamp))
|
dataTimeStamp.WithLabelValues().Set(timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
type gRPCError interface {
|
type gRPCError interface {
|
||||||
|
@ -195,13 +195,13 @@ func TestTokenGenMetrics(t *testing.T) {
|
|||||||
|
|
||||||
func TestRecordKeyDataTimeStamp(t *testing.T) {
|
func TestRecordKeyDataTimeStamp(t *testing.T) {
|
||||||
|
|
||||||
dataTimeStamp1 := time.Now().Unix()
|
dataTimeStamp1 := float64(time.Now().Unix())
|
||||||
dataTimeStamp2 := time.Now().Add(time.Second * 1200).Unix()
|
dataTimeStamp2 := float64(time.Now().Add(time.Second * 1200).Unix())
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
desc string
|
desc string
|
||||||
metrics []string
|
metrics []string
|
||||||
want int64
|
want float64
|
||||||
emit func()
|
emit func()
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
@ -156,7 +156,7 @@ func (p *keyCache) syncKeys(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p.verificationKeys.Store(newPublicKeys)
|
p.verificationKeys.Store(newPublicKeys)
|
||||||
externaljwtmetrics.RecordKeyDataTimeStamp(newPublicKeys.DataTimestamp.Unix())
|
externaljwtmetrics.RecordKeyDataTimeStamp(float64(newPublicKeys.DataTimestamp.UnixNano()) / float64(1000000000))
|
||||||
|
|
||||||
if keysChanged(oldPublicKeys, newPublicKeys) {
|
if keysChanged(oldPublicKeys, newPublicKeys) {
|
||||||
p.broadcastUpdate()
|
p.broadcastUpdate()
|
||||||
|
@ -160,9 +160,10 @@ func (m *MockSigner) FetchKeys(ctx context.Context, req *v1alpha1.FetchKeysReque
|
|||||||
m.supportedKeysFetched.Broadcast()
|
m.supportedKeysFetched.Broadcast()
|
||||||
m.supportedKeysLock.RUnlock()
|
m.supportedKeysLock.RUnlock()
|
||||||
|
|
||||||
|
now := time.Now()
|
||||||
return &v1alpha1.FetchKeysResponse{
|
return &v1alpha1.FetchKeysResponse{
|
||||||
RefreshHintSeconds: 5,
|
RefreshHintSeconds: 5,
|
||||||
DataTimestamp: ×tamppb.Timestamp{Seconds: time.Now().Unix()},
|
DataTimestamp: ×tamppb.Timestamp{Seconds: now.Unix(), Nanos: int32(now.Nanosecond())},
|
||||||
Keys: keys,
|
Keys: keys,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user