Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Feb 7, 2025
1 parent 9605697 commit 381dc6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ func (c *Agent) waitingQueue(ctx context.Context, msg string, weight int, info *
return client.MessageResponse{}, fmt.Errorf("failed to create queue: %w", err)
}

if mr.Status == model.StatusPending {
if mr.Status == model.StatusPending || mr.Status == model.StatusProcessing {
c.logger.Info("watching message from queue", "msg", msg)

chMr, err := c.queueClient.Watch(ctx, mr.MessageID)
Expand Down Expand Up @@ -586,7 +586,7 @@ func (c *Agent) waitingQueue(ctx context.Context, msg string, weight int, info *
case model.StatusFailed:
return client.MessageResponse{}, fmt.Errorf("%q Queue Error: %s", msg, mr.Data.Error)
default:
return client.MessageResponse{}, fmt.Errorf("unexpected status %q for message %q", mr.Status, msg)
return client.MessageResponse{}, fmt.Errorf("unexpected status %d for message %q", mr.Status, msg)
}
}

Expand Down
18 changes: 14 additions & 4 deletions cache/cache_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func (c *Cache) RelinkManifest(ctx context.Context, host, image, tag string, blo

func (c *Cache) PutManifestContent(ctx context.Context, host, image, tagOrBlob string, content []byte) (int64, string, string, error) {
mt := struct {
MediaType string `json:"mediaType"`
MediaType string `json:"mediaType"`
Manifests json.RawMessage `json:"manifests"`
}{}
err := json.Unmarshal(content, &mt)
if err != nil {
Expand All @@ -48,7 +49,11 @@ func (c *Cache) PutManifestContent(ctx context.Context, host, image, tagOrBlob s

mediaType := mt.MediaType
if mediaType == "" {
mediaType = "application/vnd.docker.distribution.manifest.v1+json"
if len(mt.Manifests) != 0 {
mediaType = "application/vnd.oci.image.index.v1+json"
} else {
mediaType = "application/vnd.docker.distribution.manifest.v1+json"
}
}

h := sha256.New()
Expand Down Expand Up @@ -101,7 +106,8 @@ func (c *Cache) GetManifestContent(ctx context.Context, host, image, tagOrBlob s
}

mt := struct {
MediaType string `json:"mediaType"`
MediaType string `json:"mediaType"`
Manifests json.RawMessage `json:"manifests"`
}{}
err = json.Unmarshal(content, &mt)
if err != nil {
Expand All @@ -118,7 +124,11 @@ func (c *Cache) GetManifestContent(ctx context.Context, host, image, tagOrBlob s

mediaType := mt.MediaType
if mediaType == "" {
mediaType = "application/vnd.docker.distribution.manifest.v1+json"
if len(mt.Manifests) != 0 {
mediaType = "application/vnd.oci.image.index.v1+json"
} else {
mediaType = "application/vnd.docker.distribution.manifest.v1+json"
}
}

return content, digest, mediaType, nil
Expand Down

0 comments on commit 381dc6b

Please sign in to comment.