Skip to content

Fix concurrency error in registry's pull-through - #14476

Merged
openshift-bot merged 2 commits into
openshift:masterfrom
miminar:registry-allow-for-concurrent-map-writes
Jun 10, 2017
Merged

openshift-bot merged 2 commits into
openshift:masterfrom
miminar:registry-allow-for-concurrent-map-writes

Conversation

@miminar

@miminar miminar commented Jun 5, 2017

Copy link
Copy Markdown

Avoid the use of not thread-safe structures in the pull-through code. The mirroring code spawns a new go-routine that needs to have its own instances of thread-dangerous data.

Resolves: #14434

@miminar

miminar commented Jun 5, 2017

Copy link
Copy Markdown
Author

@dmage, @legionus PTAL

@miminar

miminar commented Jun 5, 2017 •

Copy link
Copy Markdown
Author

[test][testextended][extended:core(registry)]

// The function assumes that localBlobStore is thread-safe.
func storeLocalInBackground(ctx context.Context, repo *repository, localBlobStore distribution.BlobStore, dgst digest.Digest) {
// leave only the essential entries in the context
newCtx := context.WithValue(context.Background(), "instance.id", ctx.Value("instance.id"))

@dmage dmage Jun 5, 2017 •

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.

docker/distribution/context.Background already provides "instance.id".
I would like to preserve "trace.id", although we don't use distribution/context.WithTrace yet.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

docker/distribution/context.Background already provides "instance.id".

My intention was to make it possible to associate this job with the original request, but a better way to do that would probably be based on http.request.id instead, which is already logged by the logger.

I'll ditch the instance.id and instance.jobid and let the context generate new instance.id instead.

I would like to preserve "trace.id", although we don't use distribution/context.WithTrace yet.

We don't use it yet so I don't see a point in preserving it. Once we start to use it, this function will set the trace.* attributes on its own anyway.

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.

instance.id is an id of the instance, it is the same across all requests. It is changed only when the application is restarted.

Avoid the use of not thread-safe structures in the pull-through code.
The mirroring code spawns a new go-routine that needs to have its own
instances of thread-dangerous data.

Signed-off-by: Michal Minář <[email protected]>
@miminar
miminar force-pushed the registry-allow-for-concurrent-map-writes branch from b6b8b18 to 1fd9b77 Compare June 6, 2017 07:40

@soltysh soltysh 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

@miminar

miminar commented Jun 6, 2017 •

Copy link
Copy Markdown
Author

There's an extended test failure in @mfojtik's signing workflow test:

• Failure [310.874 seconds]
[imageapis][registry] image signature workflow
/openshifttmp/openshift/build-rpm-release/tito/rpmbuild-originuPn0fV/BUILD/origin-3.6.0/_output/local/go/src/github.com/openshift/origin/test/extended/registry/signature.go:110
  can push a signed image to openshift registry and verify it [It]
  /openshifttmp/openshift/build-rpm-release/tito/rpmbuild-originuPn0fV/BUILD/origin-3.6.0/_output/local/go/src/github.com/openshift/origin/test/extended/registry/signature.go:109

  Expected error:
      <*errors.errorString | 0xc4215b0030>: {
          s: "timed out while waiting of an image stream tag extended-test-registry-signing-ktm0k-v5tjz/signer:latest",
      }
      timed out while waiting of an image stream tag extended-test-registry-signing-ktm0k-v5tjz/signer:latest
  not to have occurred

  /openshifttmp/openshift/build-rpm-release/tito/rpmbuild-originuPn0fV/BUILD/origin-3.6.0/_output/local/go/src/github.com/openshift/origin/test/extended/registry/signature.go:30

It fails every time. Not sure if my changes are to be blamed. I'll try to reproduce locally.

Update: fixed.

@miminar
miminar force-pushed the registry-allow-for-concurrent-map-writes branch 7 times, most recently from 1ea95a2 to 56fdb9b Compare June 7, 2017 12:10
@miminar

miminar commented Jun 7, 2017

Copy link
Copy Markdown
Author

Flake #14496

@miminar
miminar force-pushed the registry-allow-for-concurrent-map-writes branch from 56fdb9b to 68c0029 Compare June 7, 2017 13:33
@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin testextended up to 68c0029

@openshift-bot

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/testextended SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended/574/) (Base Commit: 6473593) (Extended Tests: core(registry))

@miminar

miminar commented Jun 7, 2017

Copy link
Copy Markdown
Author

@soltysh merge please.

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 68c0029

@soltysh

soltysh commented Jun 7, 2017

Copy link
Copy Markdown
Contributor

Got @dmage approval on IRC.

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 68c0029

@openshift-bot

Copy link
Copy Markdown
Contributor

@openshift-bot

openshift-bot commented Jun 10, 2017 •

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/949/) (Base Commit: d79627d) (Image: devenv-rhel7_6338)

@openshift-bot
openshift-bot merged commit a659cf7 into openshift:master Jun 10, 2017
@miminar
miminar deleted the registry-allow-for-concurrent-map-writes branch July 25, 2017 14:59
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