Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): use a new db worker for hot updates #2581

Merged
merged 4 commits into from
Jul 25, 2022
Merged

Conversation

afdesk
Copy link
Contributor

@afdesk afdesk commented Jul 25, 2022

Description

the first updating uses a new client instance, but hotUpdate uses the same client instance for all attempts.
we should use a new client for each update, because the client doesn't populate a new artifact.

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@afdesk afdesk marked this pull request as ready for review July 25, 2022 05:31
@afdesk afdesk requested a review from knqyf263 as a code owner July 25, 2022 05:31
@knqyf263
Copy link
Collaborator

I think we should add Refresh or something like that in db.Client. It forces to update artifact. We may want to change populateOCIArtifact() to populateOCIArtifact(false bool).

func (c *Client) populateOCIArtifact(force bool) error {
	if c.artifact == nil || force {
		repo := fmt.Sprintf("%s:%d", c.dbRepository, db.SchemaVersion)
		art, err := oci.NewArtifact(repo, dbMediaType, c.quiet, c.insecureSkipTLSVerify)
		if err != nil {
			return xerrors.Errorf("OCI artifact error: %w", err)
		}
		c.artifact = art
	}
	return nil
}

pkg/db/db.go Outdated
func (c *Client) populateOCIArtifact() error {
if c.artifact == nil {
func (c *Client) populateOCIArtifact(force bool) error {
if c.artifact == nil || force {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I found force is always true... Can we simply populate it anytime by removing the if-statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found force is always true... Can we simply populate it anytime by removing the if-statement?

yes, I wanted to write the same comment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should test it carefully, image scanning, client/server mode, Kubernetes scanning, etc. I don't remember, but there was a reason to avoid multiple initializations. It may be no longer necessary after some refactoring though.

@knqyf263 knqyf263 merged commit fa8a8ba into main Jul 25, 2022
@knqyf263 knqyf263 deleted the fix-hotupdate-artifact branch July 25, 2022 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants