Skip to content

bugreport: if used cache, when delete a repository, should clear the cache, otherwise, can not push this repository again. #3322

Closed as not planned

Description

@dk-lockdown
func (repo *repository) Manifests(ctx context.Context, options ...distribution.ManifestServiceOption) (distribution.ManifestService, error) {
	manifestLinkPathFns := []linkPathFunc{
		// NOTE(stevvooe): Need to search through multiple locations since
		// 2.1.0 unintentionally linked into  _layers.
		manifestRevisionLinkPath,
		blobLinkPath,
	}

	manifestDirectoryPathSpec := manifestRevisionsPathSpec{name: repo.name.Name()}

	var statter distribution.BlobDescriptorService = &linkedBlobStatter{
		blobStore:   repo.blobStore,
		repository:  repo,
		linkPathFns: manifestLinkPathFns,
	}

	// ......

	blobStore := &linkedBlobStore{
		ctx:                  ctx,
		blobStore:            repo.blobStore,
		repository:           repo,
		deleteEnabled:        repo.registry.deleteEnabled,
		blobAccessController: statter,

		// TODO(stevvooe): linkPath limits this blob store to only
		// manifests. This instance cannot be used for blob checks.
		linkPathFns:           manifestLinkPathFns,
		linkDirectoryPathSpec: manifestDirectoryPathSpec,
	}

	// ......

	ms := &manifestStore{
                 // ......
		blobStore:      blobStore,
                 // ......
		
	}

       // ......

	return ms, nil
}

when delete

// Delete removes the revision of the specified manifest.
func (ms *manifestStore) Delete(ctx context.Context, dgst digest.Digest) error {
	dcontext.GetLogger(ms.ctx).Debug("(*manifestStore).Delete")
	return ms.blobStore.Delete(ctx, dgst)
}

this func will call

func (lbs *linkedBlobStore) Delete(ctx context.Context, dgst digest.Digest) error {
	if !lbs.deleteEnabled {
		return distribution.ErrUnsupported
	}

	// Ensure the blob is available for deletion
	_, err := lbs.blobAccessController.Stat(ctx, dgst)
	if err != nil {
		return err
	}

	err = lbs.blobAccessController.Clear(ctx, dgst)
	if err != nil {
		return err
	}

	return nil
}

the blobAccessController which is a linkedBlobStatter, will only call
lbs.blobStore.driver.Delete(ctx, blobLinkPath) except clear cache.

Activity

  1. milosgajdos commented on Apr 20, 2021

    @milosgajdos
    Member

    Can you provide a way how to reproduce this behavior?

  2. dk-lockdown commented on Apr 21, 2021

    @dk-lockdown
    Author

    Can you provide a way how to reproduce this behavior?

    delete a repository,run registry gc,then push again, it will success, because there is a cache,but the data file is not uploaded,so when you pull that repository, will meet "manifests unknown"

  3. milosgajdos commented on Apr 21, 2021

    @milosgajdos
    Member

    Does this mean this bug appears only when the GC has run post-delete?

  4. dk-lockdown commented on Apr 21, 2021

    @dk-lockdown
    Author

    Does this mean this bug appears only when the GC has run post-delete?

    yes,gc remove the data file,the cache not clear

  5. deleteriousEffect commented on Apr 21, 2021

    @deleteriousEffect
    Member

    The garbage collector won't be able to clear the inmemory cache for the registry as that's in a separate process with its own memory region.

  6. dk-lockdown commented on Apr 22, 2021

    @dk-lockdown
    Author

    The garbage collector won't be able to clear the inmemory cache for the registry as that's in a separate process with its own memory region.

    when use api delete the image repository file,that problem will reproduce too。

  7. dk-lockdown commented on Apr 22, 2021

    @dk-lockdown
    Author

    The garbage collector won't be able to clear the inmemory cache for the registry as that's in a separate process with its own memory region.

    when call delete api,clear the cache,can solve this problem.

  8. deleteriousEffect commented on Apr 22, 2021

    @deleteriousEffect
    Member

    when call delete api,clear the cache,can solve this problem.

    We'd have to make API calls and auth against a remote registry, which isn't impossible, but it's a significant departure. This solution also wouldn't work for deployments using multiple registries since they'll each have their own cache, and it will only clear the cache of the registry the request happened to get routed to.

    This solution is clever, but I'm not sure it's worth the effort to set it up in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions