Skip to content

Conversation

@iwankgb
Copy link
Collaborator

@iwankgb iwankgb commented May 8, 2023

Reasoning behind this proposal:

  • Kubernetes requires 1.20 on main anyway
  • We run tests on 1.19 and 1.20 only
  • Versions in / and /cmd shall be the same.

Note for the reviewers: take a look at utils.sysfs.toFileInfo() - this the only addition/change that was not performed using replace functionality in my IDE.

@iwankgb iwankgb force-pushed the go-1.19 branch 3 times, most recently from d6277f9 to 6078378 Compare May 8, 2023 13:31
@iwankgb iwankgb force-pushed the go-1.19 branch 3 times, most recently from bc2f0ba to f4c2421 Compare May 8, 2023 14:52
Comment on lines 41 to 40
testDir, err := ioutil.TempDir("", "")
testDir, err := os.MkdirTemp(os.TempDir(), "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better to use t.TemDir() here.

fs/fs_test.go Outdated
fsInfo, err := NewFsInfo(Context{})
as.NoError(err)
dir, err := ioutil.TempDir(os.TempDir(), "")
dir, err := os.MkdirTemp(os.TempDir(), "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use t.TempDir() here.

func (fs *realSysFs) GetCaches(id int) ([]os.FileInfo, error) {
cpuPath := fmt.Sprintf("%s%d/cache", cacheDir, id)
return ioutil.ReadDir(cpuPath)
dir, err := os.ReadDir(cpuPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is an incompatible change, but it would make sense to convert this to return []os.DirEntry instead.

Otherwise, practically, what happens here, is a stat(2) call to every entry, which is kinda expensive. More to say, it seems the only user of this function is in utils/sysinfo (I checked), so while this is a public API, apparently it has no users.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are three other uses of toFileInfo() that would have to be fixed. While I understand you concern and I believe that it's valid, I'm hesitant to do this as part of this PR and I would prefer to address it in future.

@iwankgb
Copy link
Collaborator Author

iwankgb commented Jun 8, 2023

/assign @bobbypage

Copy link
Contributor

@Creatone Creatone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Will you handle the @kolyshkin proposal on the t.TempDir?

@iwankgb
Copy link
Collaborator Author

iwankgb commented Jun 15, 2023

I did in 814bb27

@Creatone
Copy link
Contributor

I did in 814bb27

I miss that, sorry

@Creatone Creatone merged commit 5a0fe19 into google:master Jun 16, 2023
@bobbypage
Copy link
Contributor

delayed lgtm, thank you for the fixes!

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