Merge pull request #2558 from mrueg/release/2.6
[release/2.6] Cherry-Pick commits for release 2.6.3
This commit is contained in:
commit
49a2291398
4 changed files with 46 additions and 11 deletions
|
@ -13,7 +13,7 @@ type EndpointConfig struct {
|
||||||
Threshold int
|
Threshold int
|
||||||
Backoff time.Duration
|
Backoff time.Duration
|
||||||
IgnoredMediaTypes []string
|
IgnoredMediaTypes []string
|
||||||
Transport *http.Transport
|
Transport *http.Transport `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaults set any zero-valued fields to a reasonable default.
|
// defaults set any zero-valued fields to a reasonable default.
|
||||||
|
|
28
notifications/metrics_test.go
Normal file
28
notifications/metrics_test.go
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package notifications
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"expvar"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMetricsExpvar(t *testing.T) {
|
||||||
|
endpointsVar := expvar.Get("registry").(*expvar.Map).Get("notifications").(*expvar.Map).Get("endpoints")
|
||||||
|
|
||||||
|
var v interface{}
|
||||||
|
if err := json.Unmarshal([]byte(endpointsVar.String()), &v); err != nil {
|
||||||
|
t.Fatalf("unexpected error unmarshaling endpoints: %v", err)
|
||||||
|
}
|
||||||
|
if v != nil {
|
||||||
|
t.Fatalf("expected nil, got %#v", v)
|
||||||
|
}
|
||||||
|
|
||||||
|
NewEndpoint("x", "y", EndpointConfig{})
|
||||||
|
|
||||||
|
if err := json.Unmarshal([]byte(endpointsVar.String()), &v); err != nil {
|
||||||
|
t.Fatalf("unexpected error unmarshaling endpoints: %v", err)
|
||||||
|
}
|
||||||
|
if slice, ok := v.([]interface{}); !ok || len(slice) != 1 {
|
||||||
|
t.Logf("expected one-element []interface{}, got %#v", v)
|
||||||
|
}
|
||||||
|
}
|
|
@ -122,17 +122,20 @@ func (ts *tagStore) Untag(ctx context.Context, tag string) error {
|
||||||
name: ts.repository.Named().Name(),
|
name: ts.repository.Named().Name(),
|
||||||
tag: tag,
|
tag: tag,
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
switch err.(type) {
|
|
||||||
case storagedriver.PathNotFoundError:
|
|
||||||
return distribution.ErrTagUnknown{Tag: tag}
|
|
||||||
case nil:
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return ts.blobStore.driver.Delete(ctx, tagPath)
|
if err := ts.blobStore.driver.Delete(ctx, tagPath); err != nil {
|
||||||
|
switch err.(type) {
|
||||||
|
case storagedriver.PathNotFoundError:
|
||||||
|
return nil // Untag is idempotent, we don't care if it didn't exist
|
||||||
|
default:
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// linkedBlobStore returns the linkedBlobStore for the named tag, allowing one
|
// linkedBlobStore returns the linkedBlobStore for the named tag, allowing one
|
||||||
|
@ -179,6 +182,10 @@ func (ts *tagStore) Lookup(ctx context.Context, desc distribution.Descriptor) ([
|
||||||
tagLinkPath, err := pathFor(tagLinkPathSpec)
|
tagLinkPath, err := pathFor(tagLinkPathSpec)
|
||||||
tagDigest, err := ts.blobStore.readlink(ctx, tagLinkPath)
|
tagDigest, err := ts.blobStore.readlink(ctx, tagLinkPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
switch err.(type) {
|
||||||
|
case storagedriver.PathNotFoundError:
|
||||||
|
continue
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ func TestTagStoreUnTag(t *testing.T) {
|
||||||
desc := distribution.Descriptor{Digest: "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"}
|
desc := distribution.Descriptor{Digest: "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"}
|
||||||
|
|
||||||
err := tags.Untag(ctx, "latest")
|
err := tags.Untag(ctx, "latest")
|
||||||
if err == nil {
|
if err != nil {
|
||||||
t.Errorf("Expected error untagging non-existant tag")
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tags.Tag(ctx, "latest", desc)
|
err = tags.Tag(ctx, "latest", desc)
|
||||||
|
|
Loading…
Reference in a new issue