registry/storage/driver: add test call to Stat on "/"
Stat(ctx, "/") is called by the registry healthcheck. Also fixes blob name building in the Azure driver so it no longer returns empty blob names. This was causing errors in the healthcheck call to Stat for Azure. Signed-off-by: Flavian Missi <fmissi@redhat.com>
This commit is contained in:
parent
983358f8e2
commit
90ece48d77
2 changed files with 18 additions and 1 deletions
|
@ -63,7 +63,8 @@ func New(params *Parameters) (*Driver, error) {
|
|||
d := &driver{
|
||||
azClient: azClient,
|
||||
client: client,
|
||||
rootDirectory: params.RootDirectory}
|
||||
rootDirectory: params.RootDirectory,
|
||||
}
|
||||
return &Driver{baseEmbed: baseEmbed{Base: base.Base{StorageDriver: d}}}, nil
|
||||
}
|
||||
|
||||
|
@ -420,6 +421,13 @@ func (d *driver) listBlobs(ctx context.Context, virtPath string) ([]string, erro
|
|||
}
|
||||
|
||||
func (d *driver) blobName(path string) string {
|
||||
// avoid returning an empty blob name.
|
||||
// this will happen when rootDirectory is unset, and path == "/",
|
||||
// which is what we get from the storage driver health check Stat call.
|
||||
if d.rootDirectory == "" && path == "/" {
|
||||
return path
|
||||
}
|
||||
|
||||
return strings.TrimLeft(strings.TrimRight(d.rootDirectory, "/")+path, "/")
|
||||
}
|
||||
|
||||
|
|
|
@ -824,6 +824,15 @@ func (suite *DriverSuite) TestStatCall(c *check.C) {
|
|||
c.Assert(fi.Path(), check.Equals, dirPath)
|
||||
c.Assert(fi.Size(), check.Equals, int64(0))
|
||||
c.Assert(fi.IsDir(), check.Equals, true)
|
||||
|
||||
// The storage healthcheck performs this exact call to Stat.
|
||||
// PathNotFoundErrors are not considered health check failures.
|
||||
_, err = suite.StorageDriver.Stat(suite.ctx, "/")
|
||||
// Some drivers will return a not found here, while others will not
|
||||
// return an error at all. If we get an error, ensure it's a not found.
|
||||
if err != nil {
|
||||
c.Assert(err, check.FitsTypeOf, storagedriver.PathNotFoundError{})
|
||||
}
|
||||
}
|
||||
|
||||
// TestPutContentMultipleTimes checks that if storage driver can overwrite the content
|
||||
|
|
Loading…
Reference in a new issue