Add continue when layer fails on store creation
Trim whitespace from layerstore files to keep trailing space from failing a layer load
Fixes #19449
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
"path/filepath" |
| 11 | 11 |
"regexp" |
| 12 | 12 |
"strconv" |
| 13 |
+ "strings" |
|
| 13 | 14 |
|
| 14 | 15 |
"github.com/Sirupsen/logrus" |
| 15 | 16 |
"github.com/docker/distribution/digest" |
| ... | ... |
@@ -154,7 +155,7 @@ func (fms *fileMetadataStore) GetParent(layer ChainID) (ChainID, error) {
|
| 154 | 154 |
return "", err |
| 155 | 155 |
} |
| 156 | 156 |
|
| 157 |
- dgst, err := digest.ParseDigest(string(content)) |
|
| 157 |
+ dgst, err := digest.ParseDigest(strings.TrimSpace(string(content))) |
|
| 158 | 158 |
if err != nil {
|
| 159 | 159 |
return "", err |
| 160 | 160 |
} |
| ... | ... |
@@ -168,7 +169,7 @@ func (fms *fileMetadataStore) GetDiffID(layer ChainID) (DiffID, error) {
|
| 168 | 168 |
return "", err |
| 169 | 169 |
} |
| 170 | 170 |
|
| 171 |
- dgst, err := digest.ParseDigest(string(content)) |
|
| 171 |
+ dgst, err := digest.ParseDigest(strings.TrimSpace(string(content))) |
|
| 172 | 172 |
if err != nil {
|
| 173 | 173 |
return "", err |
| 174 | 174 |
} |
| ... | ... |
@@ -177,16 +178,17 @@ func (fms *fileMetadataStore) GetDiffID(layer ChainID) (DiffID, error) {
|
| 177 | 177 |
} |
| 178 | 178 |
|
| 179 | 179 |
func (fms *fileMetadataStore) GetCacheID(layer ChainID) (string, error) {
|
| 180 |
- content, err := ioutil.ReadFile(fms.getLayerFilename(layer, "cache-id")) |
|
| 180 |
+ contentBytes, err := ioutil.ReadFile(fms.getLayerFilename(layer, "cache-id")) |
|
| 181 | 181 |
if err != nil {
|
| 182 | 182 |
return "", err |
| 183 | 183 |
} |
| 184 |
+ content := strings.TrimSpace(string(contentBytes)) |
|
| 184 | 185 |
|
| 185 |
- if !stringIDRegexp.MatchString(string(content)) {
|
|
| 186 |
+ if !stringIDRegexp.MatchString(content) {
|
|
| 186 | 187 |
return "", errors.New("invalid cache id value")
|
| 187 | 188 |
} |
| 188 | 189 |
|
| 189 |
- return string(content), nil |
|
| 190 |
+ return content, nil |
|
| 190 | 191 |
} |
| 191 | 192 |
|
| 192 | 193 |
func (fms *fileMetadataStore) TarSplitReader(layer ChainID) (io.ReadCloser, error) {
|
| ... | ... |
@@ -227,32 +229,34 @@ func (fms *fileMetadataStore) SetMountParent(mount string, parent ChainID) error |
| 227 | 227 |
} |
| 228 | 228 |
|
| 229 | 229 |
func (fms *fileMetadataStore) GetMountID(mount string) (string, error) {
|
| 230 |
- content, err := ioutil.ReadFile(fms.getMountFilename(mount, "mount-id")) |
|
| 230 |
+ contentBytes, err := ioutil.ReadFile(fms.getMountFilename(mount, "mount-id")) |
|
| 231 | 231 |
if err != nil {
|
| 232 | 232 |
return "", err |
| 233 | 233 |
} |
| 234 |
+ content := strings.TrimSpace(string(contentBytes)) |
|
| 234 | 235 |
|
| 235 |
- if !stringIDRegexp.MatchString(string(content)) {
|
|
| 236 |
+ if !stringIDRegexp.MatchString(content) {
|
|
| 236 | 237 |
return "", errors.New("invalid mount id value")
|
| 237 | 238 |
} |
| 238 | 239 |
|
| 239 |
- return string(content), nil |
|
| 240 |
+ return content, nil |
|
| 240 | 241 |
} |
| 241 | 242 |
|
| 242 | 243 |
func (fms *fileMetadataStore) GetInitID(mount string) (string, error) {
|
| 243 |
- content, err := ioutil.ReadFile(fms.getMountFilename(mount, "init-id")) |
|
| 244 |
+ contentBytes, err := ioutil.ReadFile(fms.getMountFilename(mount, "init-id")) |
|
| 244 | 245 |
if err != nil {
|
| 245 | 246 |
if os.IsNotExist(err) {
|
| 246 | 247 |
return "", nil |
| 247 | 248 |
} |
| 248 | 249 |
return "", err |
| 249 | 250 |
} |
| 251 |
+ content := strings.TrimSpace(string(contentBytes)) |
|
| 250 | 252 |
|
| 251 |
- if !stringIDRegexp.MatchString(string(content)) {
|
|
| 253 |
+ if !stringIDRegexp.MatchString(content) {
|
|
| 252 | 254 |
return "", errors.New("invalid init id value")
|
| 253 | 255 |
} |
| 254 | 256 |
|
| 255 |
- return string(content), nil |
|
| 257 |
+ return content, nil |
|
| 256 | 258 |
} |
| 257 | 259 |
|
| 258 | 260 |
func (fms *fileMetadataStore) GetMountParent(mount string) (ChainID, error) {
|
| ... | ... |
@@ -264,7 +268,7 @@ func (fms *fileMetadataStore) GetMountParent(mount string) (ChainID, error) {
|
| 264 | 264 |
return "", err |
| 265 | 265 |
} |
| 266 | 266 |
|
| 267 |
- dgst, err := digest.ParseDigest(string(content)) |
|
| 267 |
+ dgst, err := digest.ParseDigest(strings.TrimSpace(string(content))) |
|
| 268 | 268 |
if err != nil {
|
| 269 | 269 |
return "", err |
| 270 | 270 |
} |
| ... | ... |
@@ -86,6 +86,7 @@ func NewStoreFromGraphDriver(store MetadataStore, driver graphdriver.Driver) (St |
| 86 | 86 |
l, err := ls.loadLayer(id) |
| 87 | 87 |
if err != nil {
|
| 88 | 88 |
logrus.Debugf("Failed to load layer %s: %s", id, err)
|
| 89 |
+ continue |
|
| 89 | 90 |
} |
| 90 | 91 |
if l.parent != nil {
|
| 91 | 92 |
l.parent.referenceCount++ |
| ... | ... |
@@ -109,22 +110,22 @@ func (ls *layerStore) loadLayer(layer ChainID) (*roLayer, error) {
|
| 109 | 109 |
|
| 110 | 110 |
diff, err := ls.store.GetDiffID(layer) |
| 111 | 111 |
if err != nil {
|
| 112 |
- return nil, err |
|
| 112 |
+ return nil, fmt.Errorf("failed to get diff id for %s: %s", layer, err)
|
|
| 113 | 113 |
} |
| 114 | 114 |
|
| 115 | 115 |
size, err := ls.store.GetSize(layer) |
| 116 | 116 |
if err != nil {
|
| 117 |
- return nil, err |
|
| 117 |
+ return nil, fmt.Errorf("failed to get size for %s: %s", layer, err)
|
|
| 118 | 118 |
} |
| 119 | 119 |
|
| 120 | 120 |
cacheID, err := ls.store.GetCacheID(layer) |
| 121 | 121 |
if err != nil {
|
| 122 |
- return nil, err |
|
| 122 |
+ return nil, fmt.Errorf("failed to get cache id for %s: %s", layer, err)
|
|
| 123 | 123 |
} |
| 124 | 124 |
|
| 125 | 125 |
parent, err := ls.store.GetParent(layer) |
| 126 | 126 |
if err != nil {
|
| 127 |
- return nil, err |
|
| 127 |
+ return nil, fmt.Errorf("failed to get parent for %s: %s", layer, err)
|
|
| 128 | 128 |
} |
| 129 | 129 |
|
| 130 | 130 |
cl = &roLayer{
|