Add push fallback to v1 for the official registry
| ... | ... |
@@ -2,6 +2,7 @@ package graph |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"bytes" |
| 5 |
+ "errors" |
|
| 5 | 6 |
"fmt" |
| 6 | 7 |
"io" |
| 7 | 8 |
"io/ioutil" |
| ... | ... |
@@ -18,6 +19,8 @@ import ( |
| 18 | 18 |
"github.com/docker/libtrust" |
| 19 | 19 |
) |
| 20 | 20 |
|
| 21 |
+var ErrV2RegistryUnavailable = errors.New("error v2 registry unavailable")
|
|
| 22 |
+ |
|
| 21 | 23 |
// Retrieve the all the images to be uploaded in the correct order |
| 22 | 24 |
func (s *TagStore) getImageList(localRepo map[string]string, requestedTag string) ([]string, map[string][]string, error) {
|
| 23 | 25 |
var ( |
| ... | ... |
@@ -280,6 +283,10 @@ func (s *TagStore) pushV2Repository(r *registry.Session, eng *engine.Engine, out |
| 280 | 280 |
|
| 281 | 281 |
endpoint, err := r.V2RegistryEndpoint(repoInfo.Index) |
| 282 | 282 |
if err != nil {
|
| 283 |
+ if repoInfo.Index.Official {
|
|
| 284 |
+ log.Infof("Unable to push to V2 registry, falling back to v1: %s", err)
|
|
| 285 |
+ return ErrV2RegistryUnavailable |
|
| 286 |
+ } |
|
| 283 | 287 |
return fmt.Errorf("error getting registry endpoint: %s", err)
|
| 284 | 288 |
} |
| 285 | 289 |
|
| ... | ... |
@@ -454,8 +461,9 @@ func (s *TagStore) CmdPush(job *engine.Job) engine.Status {
|
| 454 | 454 |
return engine.StatusOK |
| 455 | 455 |
} |
| 456 | 456 |
|
| 457 |
- // error out, no fallback to V1 |
|
| 458 |
- return job.Errorf("Error pushing to registry: %s", err)
|
|
| 457 |
+ if err != ErrV2RegistryUnavailable {
|
|
| 458 |
+ return job.Errorf("Error pushing to registry: %s", err)
|
|
| 459 |
+ } |
|
| 459 | 460 |
} |
| 460 | 461 |
|
| 461 | 462 |
if err != nil {
|