eve icon indicating copy to clipboard operation
eve copied to clipboard

Update task timer use duration

Open christoph-zededa opened this issue 6 months ago • 11 comments

Description

this is a follow-up of https://github.com/lf-edge/eve/pull/4967#discussion_r2142691676 pillar/updateTaskTimer: switch to less-error prone

time.Duration

How to test and validate this PR

same as https://github.com/lf-edge/eve/pull/4967

Changelog notes

No user-visible changes.

PR Backports

  • 14.5-stable: no
  • 13.4-stable: no

Checklist

  • [x] I've provided a proper description
  • [x] I've added the proper documentation
  • [x] I've tested my PR on amd64 device
  • [ ] I've tested my PR on arm64 device
  • [x] I've written the test verification instructions
  • [x] I've set the proper labels to this PR
  • [x] I've checked the boxes above, or I've provided a good reason why I didn't check them.

christoph-zededa avatar Jun 26 '25 16:06 christoph-zededa

regarding spdx check:

Checking pkg/pillar/zedcloud/proxy.go
  - SPDX-License-Identifier: missing SPDX-License-Identifier!
  - Copyright: does not have the copyright!

seems the tool is wrong @OhmSpectator as I see this in this file:

    1  // Copyright 2017 The Go Authors. All rights reserved.                                                                                                                 
    2  // Use of this source code is governed by a BSD-style                                                                                                                  
    3  // license that can be found in the LICENSE file.                                                                                                                      
    4                                                                                                                                                                         
    5  // Package httpproxy provides support for HTTP proxy determination                                                                                                     
    6  // based on environment variables, as provided by net/http's                                                                                                           
    7  // ProxyFromEnvironment function.                                                                                                                                      
    8  //                                                                                                                                                                     
    9  // The API is not subject to the Go 1 compatibility promise and may change at                                                                                          
   10  // any time.                                                                                                                                                           
   11  // package httpproxy                                                                                                                                                   
   12  package zedcloud                 

christoph-zededa avatar Jun 27 '25 11:06 christoph-zededa

I'm now curious, where did we take this file from? The tool checks for a proper SPDX-formatted license (https://spdx.github.io/spdx-spec/v3.0.1/annexes/spdx-license-expressions/). I'll think what to do in this case. One option I see is to format it properly.

OhmSpectator avatar Jun 27 '25 11:06 OhmSpectator

I'm now curious, where did we take this file from? The tool checks for a proper SPDX-formatted license (https://spdx.github.io/spdx-spec/v3.0.1/annexes/spdx-license-expressions/). I'll think what to do in this case. One option I see is to format it properly.

And I am curious what this PR has to do with proxy.go ...

christoph-zededa avatar Jun 27 '25 11:06 christoph-zededa

I'm now curious, where did we take this file from? The tool checks for a proper SPDX-formatted license (https://spdx.github.io/spdx-spec/v3.0.1/annexes/spdx-license-expressions/). I'll think what to do in this case. One option I see is to format it properly.

And I am curious what this PR has to do with proxy.go ...

ah, rebase helped

christoph-zededa avatar Jun 27 '25 11:06 christoph-zededa

I'm now curious, where did we take this file from? The tool checks for a proper SPDX-formatted license (https://spdx.github.io/spdx-spec/v3.0.1/annexes/spdx-license-expressions/). I'll think what to do in this case. One option I see is to format it properly.

There clearly isn't a SPDX license in that header. I wonder if our copyright check looks for (c) or (C).

eriknordmark avatar Jul 07 '25 22:07 eriknordmark

@christoph-zededa, are you planning to address the comments? This one? https://github.com/lf-edge/eve/pull/5023/files#r2169484219

OhmSpectator avatar Jul 30 '25 16:07 OhmSpectator

EVE Upgrade fails all the time... It's better to check the logs.

OhmSpectator avatar Jul 31 '25 04:07 OhmSpectator

@europaul

I think it's also a good idea to add multiple types like DurationSeconds, DurationMinutes, DurationHours, DurationDays... and use them accordingly to what is expected from a parameter

I don't understand why you need this? F.e. for hours you can just do: c.GlobalValueDuration("mykey").Hours()

christoph-zededa avatar Jul 31 '25 11:07 christoph-zededa

/rerun red

(hoping to gather collect-info this time)

christoph-zededa avatar Jul 31 '25 12:07 christoph-zededa

@europaul

I think it's also a good idea to add multiple types like DurationSeconds, DurationMinutes, DurationHours, DurationDays... and use them accordingly to what is expected from a parameter

I don't understand why you need this? F.e. for hours you can just do: c.GlobalValueDuration("mykey").Hours()

you have to know how to convert the integer that you get out of the config to time.Duration for each parameter (because it could mean mins, secs, hours etc).

I'll try to create a PR for this soon

europaul avatar Jul 31 '25 12:07 europaul

should we also define Seconds as a type in global.go

No, because it will fail during upgrade as /persist/status/zedagent/ConfigItemValueMap/global.json is at one point storing Integer and later trying to retrieve Seconds/Duration.

So, I think I should reset this PR to https://github.com/lf-edge/eve/commit/ce032ad0b15ed62bdea2b4984d88928d6f455926 .


Stacktrace:

goroutine 2730 [running]:
github.com/lf-edge/eve/pkg/pillar/agentlog.getStacks(0x0)
	/pillar/agentlog/agentlog.go:467 +0x4a
github.com/lf-edge/eve/pkg/pillar/agentlog.printStack(0xc0006dc6a8, {0x7ffc6464af6f, 0x6}, 0x915)
	/pillar/agentlog/agentlog.go:235 +0x45
github.com/lf-edge/eve/pkg/pillar/agentlog.initImpl.func1()
	/pillar/agentlog/agentlog.go:550 +0x25
github.com/sirupsen/logrus.runHandler(0xc000059e28?)
	/pillar/vendor/github.com/sirupsen/logrus/alt_exit.go:39 +0x33
github.com/sirupsen/logrus.runHandlers(...)
	/pillar/vendor/github.com/sirupsen/logrus/alt_exit.go:44
github.com/sirupsen/logrus.(*Logger).Exit(0x4c99ae0, 0x1)
	/pillar/vendor/github.com/sirupsen/logrus/logger.go:343 +0x47
github.com/sirupsen/logrus.(*Logger).Fatalf(0x4c99ae0, {0x34ca0f1?, 0x1d?}, {0xc000059e28?, 0xc000c1fe30?, 0x130f55f?})
	/pillar/vendor/github.com/sirupsen/logrus/logger.go:191 +0x45
github.com/sirupsen/logrus.Fatalf(...)
	/pillar/vendor/github.com/sirupsen/logrus/exported.go:224
github.com/lf-edge/eve/pkg/pillar/types.(*ConfigItemValueMap).GlobalValueInt(0xc0001f4a08?, {0x34b70be, 0x1d})
	/pillar/types/global.go:769 +0x125
github.com/lf-edge/eve/pkg/pillar/cmd/zedagent.hardwareHealthTimerTask(0xc0001f4a08, 0xc000dc1ab0)
	/pillar/cmd/zedagent/handlemetrics.go:1017 +0x9b
created by github.com/lf-edge/eve/pkg/pillar/cmd/zedagent.Run in goroutine 20
	/pillar/cmd/zedagent/zedagent.go:540 +0x1429

christoph-zededa avatar Jul 31 '25 13:07 christoph-zededa