Skip to content

pkg/chartmuseum,cmd: introduce the new keep-chart-always-up-to-date flag and the default cache interval when not set.#593

Merged
jdolitsky merged 4 commits into
mainfrom
feat/keep-chart-up-date-option
Aug 1, 2022
Merged

pkg/chartmuseum,cmd: introduce the new keep-chart-always-up-to-date flag and the default cache interval when not set.#593
jdolitsky merged 4 commits into
mainfrom
feat/keep-chart-up-date-option

Conversation

@scbizu

@scbizu scbizu commented Jun 5, 2022

Copy link
Copy Markdown
Contributor

Closes #444

  • The flags works to always get the realtime index for the chart repository(which is the behavior before v0.13.0), it will cost more fs I/O.
  • Default interval is now set to 5m when cache-interval flag not set which we suggests in the issue list.

Signed-off-by: scnace [email protected]

@scbizu
scbizu force-pushed the feat/keep-chart-up-date-option branch 4 times, most recently from dea15fe to 44034ff Compare June 5, 2022 16:36
@scbizu
scbizu requested review from cbuto and jdolitsky June 5, 2022 16:41
Comment thread pkg/chartmuseum/server/multitenant/cache.go Outdated
Comment thread cmd/chartmuseum/main.go Outdated
Comment thread pkg/chartmuseum/server/multitenant/index.go Outdated
Comment thread pkg/chartmuseum/server/multitenant/index.go Outdated
Comment thread pkg/chartmuseum/server/multitenant/server_test.go Outdated
Comment thread pkg/chartmuseum/server/multitenant/server_test.go Outdated
@scbizu
scbizu force-pushed the feat/keep-chart-up-date-option branch 7 times, most recently from 739b0a7 to 7b02ed0 Compare June 12, 2022 18:46
@cbuto

cbuto commented Jun 15, 2022

Copy link
Copy Markdown
Contributor

looks like there is a new data race

WARNING: DATA RACE
Read at 0x00c000c2eb10 by goroutine 89:
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.(*MultiTenantServer).rebuildIndex()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/cache.go:568 +0x91
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.(*MultiTenantServer).initCacheTimer.func1()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/cache.go:481 +0xb8
Previous write at 0x00c000c2eb10 by goroutine 31:
2022-06-12T18:50:07.522Z	DEBUG	index.yaml regenerated	{"repo": ""}
2022-06-12T18:50:07.522Z	DEBUG	Entry saved in cache store	{"repo": ""}
  [failed to restore the stack]
Goroutine 89 (running) created at:
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.(*MultiTenantServer).initCacheTimer()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/cache.go:478 +0xd8
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.NewMultiTenantServer()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/server.go:190 +0xe68
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.(*MultiTenantServerTestSuite).SetupSuite()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/server_test.go:278 +0x1cf7
  github.com/stretchr/testify/suite.Run()
      /home/runner/work/chartmuseum/chartmuseum/vendor/github.com/stretchr/testify/suite/suite.go:128 +0x5b7
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.TestMultiTenantServerTestSuite()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/server_test.go:1312 +0x44
  testing.tRunner()
      /opt/hostedtoolcache/go/1.17.8/x64/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /opt/hostedtoolcache/go/1.17.8/x64/src/testing/testing.go:1306 +0x47
Goroutine 31 (finished) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.17.8/x64/src/testing/testing.go:1306 +0x726
  github.com/stretchr/testify/suite.runTests()
      /home/runner/work/chartmuseum/chartmuseum/vendor/github.com/stretchr/testify/suite/suite.go:213 +0x18f
  github.com/stretchr/testify/suite.Run()
      /home/runner/work/chartmuseum/chartmuseum/vendor/github.com/stretchr/testify/suite/suite.go:186 +0x994
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.TestMultiTenantServerTestSuite()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/server_test.go:1312 +0x44
  testing.tRunner()
      /opt/hostedtoolcache/go/1.17.8/x64/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /opt/hostedtoolcache/go/1.17.8/x64/src/testing/testing.go:1306 +0x47
==================

Comment thread pkg/config/vars.go Outdated
@scbizu

scbizu commented Jun 16, 2022

Copy link
Copy Markdown
Contributor Author

looks like there is a new data race

WARNING: DATA RACE
Read at 0x00c000c2eb10 by goroutine 89:
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.(*MultiTenantServer).rebuildIndex()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/cache.go:568 +0x91
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.(*MultiTenantServer).initCacheTimer.func1()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/cache.go:481 +0xb8
Previous write at 0x00c000c2eb10 by goroutine 31:
2022-06-12T18:50:07.522Z	DEBUG	index.yaml regenerated	{"repo": ""}
2022-06-12T18:50:07.522Z	DEBUG	Entry saved in cache store	{"repo": ""}
  [failed to restore the stack]
Goroutine 89 (running) created at:
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.(*MultiTenantServer).initCacheTimer()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/cache.go:478 +0xd8
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.NewMultiTenantServer()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/server.go:190 +0xe68
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.(*MultiTenantServerTestSuite).SetupSuite()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/server_test.go:278 +0x1cf7
  github.com/stretchr/testify/suite.Run()
      /home/runner/work/chartmuseum/chartmuseum/vendor/github.com/stretchr/testify/suite/suite.go:128 +0x5b7
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.TestMultiTenantServerTestSuite()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/server_test.go:1312 +0x44
  testing.tRunner()
      /opt/hostedtoolcache/go/1.17.8/x64/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /opt/hostedtoolcache/go/1.17.8/x64/src/testing/testing.go:1306 +0x47
Goroutine 31 (finished) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.17.8/x64/src/testing/testing.go:1306 +0x726
  github.com/stretchr/testify/suite.runTests()
      /home/runner/work/chartmuseum/chartmuseum/vendor/github.com/stretchr/testify/suite/suite.go:213 +0x18f
  github.com/stretchr/testify/suite.Run()
      /home/runner/work/chartmuseum/chartmuseum/vendor/github.com/stretchr/testify/suite/suite.go:186 +0x994
  helm.sh/chartmuseum/pkg/chartmuseum/server/multitenant.TestMultiTenantServerTestSuite()
      /home/runner/work/chartmuseum/chartmuseum/pkg/chartmuseum/server/multitenant/server_test.go:1312 +0x44
  testing.tRunner()
      /opt/hostedtoolcache/go/1.17.8/x64/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /opt/hostedtoolcache/go/1.17.8/x64/src/testing/testing.go:1306 +0x47
==================

Yes , I will try to resolve it

@scbizu
scbizu force-pushed the feat/keep-chart-up-date-option branch 8 times, most recently from 810daba to e029f4c Compare June 19, 2022 12:46
scbizu added 3 commits June 19, 2022 20:47
… flag and the default cache interval when not set.

* The flags works to always get the realtime index for the chart repository(which is the behavior before v0.13.0), it will cost more fs I/O.
* Default interval is now set to 5m when `cache-interval` flag not set which we suggests in the issue list.

The patch includes:

* increases most of the museum api throughout by wrapping the event
  emitter into goroutine since the event listener already holds on the
  concurrent lock(#396).

* adds the new server option `keep-chart-always-up-to-date` to force use
  the latest version.

* `getIndexFile` rollbacks to fully reload index only if cacheinterval
  not set for better backward compatibility before v0.13.0(#444).

Signed-off-by: scnace <[email protected]>
Signed-off-by: scbizu <[email protected]>
@scbizu
scbizu force-pushed the feat/keep-chart-up-date-option branch 2 times, most recently from 123cf9f to d8e389d Compare June 19, 2022 13:00
@scbizu

scbizu commented Jun 19, 2022

Copy link
Copy Markdown
Contributor Author

Seems like resolved it , so many lock tricks XD

PTAL @cbuto

Comment thread cmd/chartmuseum/main.go Outdated
PerChartLimit: conf.GetInt("per-chart-limit"),
WebTemplatePath: conf.GetString("web-template-path"),
ArtifactHubRepoID: conf.GetStringMapString("artifact-hub-repo-id"),
AlwaysRegenerateIndex: conf.GetBool("always-regenerate-index"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

to make sure this matches the flag name in pkg/config/vars.go

Suggested change
AlwaysRegenerateIndex: conf.GetBool("always-regenerate-index"),
AlwaysRegenerateIndex: conf.GetBool("always-regenerate-chart-index"),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

nice pickup ~

@cbuto

cbuto commented Jun 21, 2022

Copy link
Copy Markdown
Contributor

nice @scbizu! looks good aside from the one comment. is it worth running a quick loadtest locally to compare main vs these changes (mainly the new locks)?

@scbizu

scbizu commented Jun 22, 2022

Copy link
Copy Markdown
Contributor Author

@cbuto Sorry for my low local machine setup , I need your help for the loadtest xD

@cbuto

cbuto commented Jun 22, 2022

Copy link
Copy Markdown
Contributor

@cbuto Sorry for my low local machine setup , I need your help for the loadtest xD

no problem! I'll try to get some time to run a few and post the results

@cbuto

cbuto commented Jun 24, 2022

Copy link
Copy Markdown
Contributor

I ran three tests:

  1. Built from this branch - ./bin/darwin/amd64/chartmuseum --storage local --storage-local-rootdir /tmp/charts/ --always-regenerate-chart-index
  2. Built from this branch - ./bin/darwin/amd64/chartmuseum --storage local --storage-local-rootdir /tmp/charts/
  3. Built from main - ./bin/darwin/amd64/chartmuseum --storage local --storage-local-rootdir /tmp/charts/

Overall it seems like these changes without the flag set shouldn't have any affect, but setting this flags introduces a ton of latency, which I think is expected.

Screen Shot 2022-06-23 at 9 55 28 PM

@scbizu

scbizu commented Jun 24, 2022

Copy link
Copy Markdown
Contributor Author

I think so , thank you @cbuto

@cbuto cbuto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lgtm! We’ll just need to address the flag name issue in the other comment

@mikesigs

Copy link
Copy Markdown

Really eager to see this fix merged in :) The PR has been reviewed, does it need to also wait for @jdolitsky to review?

@scbizu

scbizu commented Jul 19, 2022

Copy link
Copy Markdown
Contributor Author

It would be better to be so , and I think cbuto and me also can handle it and make the canary(main) release , thoughts @cbuto ?

@cbuto

cbuto commented Jul 19, 2022

Copy link
Copy Markdown
Contributor

@scbizu I'd be good with merging this after #593 (comment) is resolved!

@scbizu

scbizu commented Jul 20, 2022

Copy link
Copy Markdown
Contributor Author

okay , I will resolve it soon ~

Co-authored-by: Casey Buto <[email protected]>

Signed-off-by: Nace Sc <[email protected]>
Signed-off-by: scbizu <[email protected]>
@scbizu
scbizu force-pushed the feat/keep-chart-up-date-option branch from d8e389d to a1cefb9 Compare July 20, 2022 01:58
@scbizu
scbizu requested a review from cbuto July 20, 2022 01:59
@scbizu

scbizu commented Jul 20, 2022

Copy link
Copy Markdown
Contributor Author

Solved

@jdolitsky jdolitsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@jdolitsky
jdolitsky merged commit 3ae6ed2 into main Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

index.yaml not regenerated when chart added to s3 bucket

4 participants