Skip to content
Snippets Groups Projects

fix(handlers): disable filesystem layer link metadata if the database is enabled

Merged Hayley Swimelar requested to merge fix-blob-unknown-everywhere into master
1 unresolved thread

Fixes: gitlab-com/gl-infra/production#14260 (closed)

During a refactor, we removed migration mode, but we also removed logic which disables writing and reading for FS metadata: v3.71.0-gitlab...v3.73.0-gitlab

This caused serving blobs to fail here, since it tried to Stat their FS metadata: https://gitlab.com/gitlab-org/container-registry/-/blob/v3.73.0-gitlab/registry/storage/linkedblobstore.go#L76

Edited by Suleimi Ahmed

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Hayley Swimelar
  • 668 668 return
    669 669 }
    670 670
    671 func TestManifestAPI_Get_Schema2LayersAndConfigNotInDatabase(t *testing.T) {
    672 env := newTestEnv(t)
    673 defer env.Shutdown()
    671 func TestManifestAPI_Get_Schema2NotInDatabase(t *testing.T) {
    • Author Maintainer

      This test is changing from the 'manifest in database, but layers on FS' scenario, which is now basically impossible without migration mode and FS mirroring.

      We're now simply checking the registry has no visibility into FS metadata when the database is enabled.

    • Should this fail if I comment out the boolean?

      diff --git a/registry/handlers/app.go b/registry/handlers/app.go
      index 8d7cc30c..035a89c5 100644
      --- a/registry/handlers/app.go
      +++ b/registry/handlers/app.go
      @@ -320,7 +320,7 @@ func NewApp(ctx context.Context, config *configuration.Configuration) (*App, err
       		log.Warn("the metadata database is an experimental feature, please do not enable it in production")
       
       		// Do not write or check for repository layer link metadata on the filesystem when the database is enabled.
      -		options = append(options, storage.DisableMirrorFS)
      +		//options = append(options, storage.DisableMirrorFS)
       
       		// TODO: this function only exists to test https://gitlab.com/gitlab-org/container-registry/-/issues/890
       		// as the migration code runs on a separate container that does not output any searchable logs.

      I tried running the tests via:

      go test -tags=integration,handlers_test ./registry/handlers
    • Oh, I guess I need to have a database enabled? :smile:

    • Author Maintainer

      Oh, I guess I need to have a database enabled? @stanhu Right. Also these tests pick up the DB info from the environment. See: https://gitlab.com/gitlab-org/container-registry/-/blob/master/docs-gitlab/database-local-setup.md#integration-tests

    • @hswimelar Ok, I got the database running, but none of the tests failed when I applied the diff above. I ran:

      go run gotest.tools/gotestsum@v1.8.2 --format testname -- ./registry/handlers  -timeout 25m  --tags api_conformance_test,integration
      <snip>
      PASS registry/handlers.TestAPIConformance/manifest_Get_OCIIndex_MatchingEtag_all/by_digest_quoted_etag (0.00s)
      PASS registry/handlers.TestAPIConformance/manifest_Get_OCIIndex_MatchingEtag_all/by_tag_non_quoted_etag (0.01s)
      PASS registry/handlers.TestAPIConformance/manifest_Get_OCIIndex_MatchingEtag_all/by_digest_non_quoted_etag (0.00s)
      PASS registry/handlers.TestAPIConformance/manifest_Get_OCIIndex_MatchingEtag_all (1.27s)
      PASS registry/handlers.TestAPIConformance/manifest_Put_OCIImageIndex_ByTag_all (1.11s)
      PASS registry/handlers.TestAPIConformance/manifest_Put_OCIImageIndex_ByTag_with_notifications_enabled (1.15s)
      PASS registry/handlers.TestAPIConformance/manifest_Head_Schema2_MissingManifest_with_notifications_enabled/by_tag (0.01s)
      PASS registry/handlers.TestAPIConformance/manifest_Head_Schema2_MissingManifest_with_notifications_enabled/by_digest (0.01s)
      PASS registry/handlers.TestAPIConformance/manifest_Head_Schema2_MissingManifest_with_notifications_enabled (0.71s)
      PASS registry/handlers.TestAPIConformance/manifest_Head_Schema2_MissingManifest_all/by_tag (0.01s)
      PASS registry/handlers.TestAPIConformance/manifest_Head_Schema2_MissingManifest_all/by_digest (0.01s)
      PASS registry/handlers.TestAPIConformance/manifest_Head_Schema2_MissingManifest_all (0.80s)
      PASS registry/handlers.TestAPIConformance/manifest_Put_OCI_ByDigest_with_notifications_enabled (0.76s)
      PASS registry/handlers.TestAPIConformance/manifest_Put_OCI_ByDigest_all (0.70s)
      PASS registry/handlers.TestAPIConformance/manifest_Delete_Schema2_Reupload_with_notifications_enabled (0.73s)
      PASS registry/handlers.TestAPIConformance/manifest_Delete_Schema2_Reupload_all (0.83s)
      PASS registry/handlers.TestAPIConformance (93.39s)
      PASS registry/handlers
      
      DONE 294 tests in 110.505s
      Edited by Stan Hu
    • I'll approve for merge since the change seems fairly straightforward. I'll leave it up to you if you want to wrangle this test into shape.

    • Author Maintainer

      Fixed with !1298 (b36e49cf)

      CC: @jaime @suleimiahmed

      With this particular fix, only TestManifestAPI_Put_Schema2WritesNoFilesystemBlobLinkMetadata is expected to fail with options = append(options, storage.DisableMirrorFS) commented out. Since that's looking at the layer link metadata, the other tests are checking against visibility into manifest metadata to prevent a regression there, which isn't controlled by storage.DisableMirrorFS, which is confusing, see @jaime 's comment here for a follow-up

    • I'm not sure what's going on with my test environment, but with PostgreSQL 13 I did:

      initdb /tmp/pg
      postgres -D /tmp/pg

      Then:

      psql -U template1
      create database registry_test;

      In my env, I have:

      REGISTRY_DATABASE_ENABLED=true
      REGISTRY_DATABASE_PORT=5432
      REGISTRY_DATABASE_HOST=127.0.0.1
      REGISTRY_DATABASE_USER=stanhu
      REGISTRY_DATABASE_PASSWORD=
      REGISTRY_DATABASE_SSLMODE=disable

      I ran:

      go run gotest.tools/gotestsum@v1.8.2 --format testname -- ./... -timeout 25m  --tags handlers_test,integration

      Then I got all sorts of odd failures:

      test.txt

      Not sure if this is just a test setup or PostgreSQL issue, but I don't really have more time to spend on this.

      I recommend that this project start testing against PostgreSQL 13 since that's now the default in GitLab 16.0 and Go v1.19.8 if you aren't already.

    • Author Maintainer
      go run gotest.tools/gotestsum@v1.8.2 --format testname -- ./... -timeout 25m  --tags handlers_test,integration

      The ./... is the issue here, this is running both the API integration tests and the lower-level database tests. These tests suites handle set ups and tear downs of the single database environment differently, which is causing the issues.

      These tests are all ran in separate CI jobs with there own database and we isolate them when running locally by convention as well. Both the following worked for me on PG 13:

      go run gotest.tools/gotestsum@v1.8.2 --format testname -- github.com/docker/distribution/registry/handlers -timeout 25m  --tags handlers_test,integration
      go run gotest.tools/gotestsum@v1.8.2 --format testname -- github.com/docker/distribution/registry/datastore -timeout 25m  --tags handlers_test,integration

      I recommend that this project start testing against PostgreSQL 13 since that's now the default in GitLab 16.0 and Go v1.19.8 if you aren't already.

      The go version is covered, I'll open an issue for PostgreSQL 13

    • Please register or sign in to reply
  • Hayley Swimelar
  • Hayley Swimelar
  • Hayley Swimelar requested review from @jdrpereira

    requested review from @jdrpereira

  • Hayley Swimelar changed milestone to %16.0

    changed milestone to %16.0

  • Hayley Swimelar removed review request for @jdrpereira

    removed review request for @jdrpereira

  • Mek Stittri
  • Suleimi Ahmed approved this merge request

    approved this merge request

  • Suleimi Ahmed changed the description

    changed the description

  • Hayley Swimelar requested review from @jaime

    requested review from @jaime

  • Jaime Martinez approved this merge request

    approved this merge request

  • Hayley Swimelar mentioned in issue #1023

    mentioned in issue #1023

  • Stan Hu requested review from @stanhu

    requested review from @stanhu

  • Stan Hu approved this merge request

    approved this merge request

  • Hayley Swimelar added 1 commit

    added 1 commit

    • b36e49cf - chore: use shared driver for test environments

    Compare with previous version

  • Stan Hu approved this merge request

    approved this merge request

  • Stan Hu resolved all threads

    resolved all threads

  • merged

  • Stan Hu mentioned in commit 6c061598

    mentioned in commit 6c061598

  • mentioned in issue #1024 (closed)

  • mentioned in issue #936 (closed)

  • Jaime Martinez mentioned in merge request !1595 (merged)

    mentioned in merge request !1595 (merged)

  • Please register or sign in to reply
    Loading