Skip to content

Change timeout vars to use time.Duration instead of int64#203

Merged
bharathsreekanth merged 4 commits into
mainfrom
usr/sreekb/adjust-timeout
Aug 18, 2025
Merged

Change timeout vars to use time.Duration instead of int64#203
bharathsreekanth merged 4 commits into
mainfrom
usr/sreekb/adjust-timeout

Conversation

@bharathsreekanth

@bharathsreekanth bharathsreekanth commented Aug 15, 2025

Copy link
Copy Markdown
Contributor

PR Submission checklist

GitHub Issues

List the GitHub issues impacted by this PR:

| GitHub Issue # |
https://github.com/dell/csm/issues/1961

Common PR Checklist:

  • Have you made sure that the code compiles?
  • Have you commented your code, particularly in hard-to-understand areas?
  • Did you run tests in a real Kubernetes cluster?
  • Have you maintained backward compatibility?
  • Have you updated the mocks for any Client functions that have been modified (mocks/Client.go)?

Description of your changes:

Adding these changes more for consistency and to prevent accidental type conversions that might cause timeouts to go negative and cause context deadline issues. This also makes it easier for timeouts to be passed from driver efficiently. Inherently time.Duration does use int64 to represent time in nanoseconds.
This is first step as part of making timeouts configurable.
Why do we need this?
timeout can be specified as 10s, 2m, etc. the time.ParseDuration returns time in time.Duration instead of int64 and it makes it easier to take that value and pass it in the client in gopowerstore. When creating a new client, we used time.Duration(timeout)*time.Second. This would overflow when time.Duration is passed in via the driver as int64 representation of the time in nanoseconds (which is default). overflow would cause time to be negative.
Why was this not an issue in the past?
Timeouts were hardcoded and not read in dynamically.

Unit test:

coverage: 91.7% of statements
ok      github.com/dell/gopowerstore    1.080s  coverage: 91.7% of statements
coverage: 91.4% of statements
ok      github.com/dell/gopowerstore/api        31.395s coverage: 91.4% of statements

Comment thread client.go
@bharathsreekanth bharathsreekanth force-pushed the usr/sreekb/adjust-timeout branch 2 times, most recently from eebbb5e to b4d5bf4 Compare August 18, 2025 12:43
@github-actions

Copy link
Copy Markdown

Merging this branch changes the coverage (1 decrease, 1 increase)

Impacted Packages Coverage Δ 🤖
github.com/dell/gopowerstore 91.65% (-0.09%) 👎
github.com/dell/gopowerstore/api 91.44% (+0.39%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/dell/gopowerstore/api/api.go 89.89% (+0.53%) 188 169 (+1) 19 (-1) 👍
github.com/dell/gopowerstore/api/throttling.go 92.59% (ø) 27 25 2
github.com/dell/gopowerstore/client.go 60.53% (ø) 38 23 15
github.com/dell/gopowerstore/client_options.go 90.48% (-4.76%) 21 19 (-1) 2 (+1) 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/dell/gopowerstore/api/api_test.go
  • github.com/dell/gopowerstore/api/throttling_test.go
  • github.com/dell/gopowerstore/client_options_test.go
  • github.com/dell/gopowerstore/client_test.go
  • github.com/dell/gopowerstore/limit_test.go

@bharathsreekanth bharathsreekanth merged commit 2648add into main Aug 18, 2025
6 checks passed
@bharathsreekanth bharathsreekanth deleted the usr/sreekb/adjust-timeout branch August 18, 2025 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants