Merge pull request #428 from ywk253100/dev

1.order jobs by create time desc 2.open job log in browser 3.update s…
This commit is contained in:
Wenkai Yin 2016-06-28 11:38:45 +08:00 committed by GitHub
commit 62d8614be9
3 changed files with 30 additions and 8 deletions

View File

@ -117,11 +117,8 @@ func (ra *RepJobAPI) GetLog() {
}
if resp.StatusCode == http.StatusOK {
for key, values := range resp.Header {
for _, value := range values {
ra.Ctx.ResponseWriter.Header().Set(key, value)
}
}
ra.Ctx.ResponseWriter.Header().Set(http.CanonicalHeaderKey("Content-Length"), resp.Header.Get(http.CanonicalHeaderKey("Content-Length")))
ra.Ctx.ResponseWriter.Header().Set(http.CanonicalHeaderKey("Content-Type"), "text/plain")
if _, err = io.Copy(ra.Ctx.ResponseWriter, resp.Body); err != nil {
log.Errorf("failed to write log to response; %v", err)

View File

@ -17,6 +17,7 @@ package dao
import (
"fmt"
"time"
"strings"
@ -253,8 +254,16 @@ func UpdateRepPolicyEnablement(id int64, enabled int) error {
o := GetOrmer()
p := models.RepPolicy{
ID: id,
Enabled: enabled}
_, err := o.Update(&p, "Enabled")
Enabled: enabled,
}
var err error
if enabled == 1 {
p.StartTime = time.Now()
_, err = o.Update(&p, "Enabled", "StartTime")
} else {
_, err = o.Update(&p, "Enabled")
}
return err
}
@ -315,7 +324,7 @@ func FilterRepJobs(policyID int64, repository, status string) ([]*models.RepJob,
if len(status) != 0 {
qs = qs.Filter("Status__icontains", status)
}
qs = qs.OrderBy("CreationTime")
qs = qs.OrderBy("-CreationTime")
var jobs []*models.RepJob
_, err := qs.All(&jobs)

View File

@ -68,6 +68,7 @@ type BaseHandler struct {
dstClient *registry.Repository
manifest distribution.Manifest // manifest of tags[0]
digest string //digest of tags[0]'s manifest
blobs []string // blobs need to be transferred for tags[0]
blobsExistence map[string]bool //key: digest of blob, value: existence
@ -329,6 +330,7 @@ func (m *ManifestPuller) Enter() (string, error) {
m.logger.Errorf("an error occurred while pulling manifest of %s:%s from %s: %v", name, tag, m.srcURL, err)
return "", err
}
m.digest = digest
m.logger.Infof("manifest of %s:%s pulled successfully from %s: %s", name, tag, m.srcURL, digest)
if strings.Contains(mediaType, "application/json") {
@ -426,6 +428,19 @@ func (m *ManifestPusher) Enter() (string, error) {
m.logger.Infof("manifest of %s:%s does not exist on source registry %s, cancel manifest pushing", name, tag, m.srcURL)
} else {
m.logger.Infof("manifest of %s:%s exists on source registry %s, continue manifest pushing", name, tag, m.srcURL)
_, manifestExist, err := m.dstClient.ManifestExist(m.digest)
if manifestExist {
m.logger.Infof("manifest of %s:%s exists on destination registry %s, skip manifest pushing", name, tag, m.dstURL)
m.tags = m.tags[1:]
m.manifest = nil
m.digest = ""
m.blobs = nil
return StatePullManifest, nil
}
mediaType, data, err := m.manifest.Payload()
if err != nil {
m.logger.Errorf("an error occurred while getting payload of manifest for %s:%s : %v", name, tag, err)
@ -441,6 +456,7 @@ func (m *ManifestPusher) Enter() (string, error) {
m.tags = m.tags[1:]
m.manifest = nil
m.digest = ""
m.blobs = nil
return StatePullManifest, nil