Skip to content

Commit b2dc809

Browse files
committed
Merge branch 'main' of github.com:dragonflyoss/dragonfly into feature/preheat
Signed-off-by: Gaius <gaius.qi@gmail.com>
2 parents 9499cf2 + 5f50fe7 commit b2dc809

File tree

16 files changed

+860
-102
lines changed

16 files changed

+860
-102
lines changed

MAINTAINERS.md

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
11
# Maintainers
22

3-
<!-- markdownlint-disable -->
4-
5-
| GitHub ID | Name | Email | Company |
6-
| :-----------------------------------------------: | :-------------: | :--------------------------: | :-----------------------------: |
7-
| [allencloud](https://github.com/allencloud) | Allen Sun | shlallen1990@gmail.com | Alibaba Group |
8-
| [garfield009](https://github.com/garfield009) | Zuozheng Hu | zuozheng.hzz@alibaba-inc.com | Alibaba Group |
9-
| [yyzai384](https://github.com/yyzai384) | Yuan Yang | qiguo.yy@alibaba-inc.com | Alibaba Group |
10-
| [bergwolf](https://github.com/bergwolf) | Peng Tao | bergwolf@hyper.sh | Ant Group |
11-
| [jim3ma](https://github.com/jim3ma) | Jim Ma | majinjing3@gmail.com | Ant Group |
12-
| [gaius-qi](https://github.com/gaius-qi) | Gaius Qi | gaius.qi@gmail.com | Ant Group |
13-
| [chlins](https://github.com/chlins) | Chlins Zhang | chlina.zhang@gmail.com | Ant Group |
14-
| [mfarooq-intel](https://github.com/mfarooq-intel) | Mohammed Farooq | mfarooq.ta@gmail.com | Intel |
15-
| [akashhr](https://github.com/akashhr) | Akash HR | akashhr2021@gmail.com | Intel |
16-
| [hyy0322](https://github.com/hyy0322) | Yiyang Huang | 691795636@qq.com | ByteDance |
17-
| [CormickKneey](https://github.com/CormickKneey) | Han Jiang | cormick1080@gmail.com | Kuaishou |
18-
| [yxxhero](https://github.com/yxxhero) | yxxhero | aiopsclub@163.com | Zhipu AI |
19-
| [fcgxz2003](https://github.com/fcgxz2003) | fcgxz2003 | 834756128@qq.com | Dalian University of Technology |
20-
21-
<!-- markdownlint-restore -->
3+
Please refer to the [community maintainers](https://github.com/dragonflyoss/community/blob/master/MAINTAINERS.md).

OWNERS.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,8 @@ This page lists current and emeritus maintainers. This can be used for routing P
88

99
## Maintainers
1010

11-
Please refer to our [MAINTAINERS.md](MAINTAINERS.md).
11+
Please refer to our [community maintainers](https://github.com/dragonflyoss/community/blob/master/MAINTAINERS.md).
1212

1313
## Emeritus maintainers
1414

15-
Please refer to our [emeritus_members.yaml](https://github.com/dragonflyoss/community/blob/master/ladder/emeritus_members.yaml).
16-
17-
## Community Managers
18-
19-
<!-- markdownlint-disable -->
20-
21-
| GitHub ID | Name | Email | Company |
22-
| :---------------------------------------: | :--------: | :-------------------: | :-------: |
23-
| [mingcheng](https://github.com/mingcheng) | Cheng Ming | mingcheng@outlook.com | Ant Group |
24-
25-
<!-- markdownlint-restore -->
15+
Please refer to our [community emeritus maintainers](https://github.com/dragonflyoss/community/blob/master/MAINTAINERS.md#emeritus-maintainers).

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.23.8
44

55
require (
66
cloud.google.com/go/storage v1.50.0
7-
d7y.io/api/v2 v2.1.53
7+
d7y.io/api/v2 v2.1.55
88
github.com/MysteriousPotato/go-lockable v1.0.0
99
github.com/Showmax/go-fqdn v1.0.0
1010
github.com/VividCortex/mysqlerr v1.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ cloud.google.com/go/storage v1.50.0 h1:3TbVkzTooBvnZsk7WaAQfOsNrdoM8QHusXA1cpk6Q
6363
cloud.google.com/go/storage v1.50.0/go.mod h1:l7XeiD//vx5lfqE3RavfmU9yvk5Pp0Zhcv482poyafY=
6464
cloud.google.com/go/trace v1.11.2 h1:4ZmaBdL8Ng/ajrgKqY5jfvzqMXbrDcBsUGXOT9aqTtI=
6565
cloud.google.com/go/trace v1.11.2/go.mod h1:bn7OwXd4pd5rFuAnTrzBuoZ4ax2XQeG3qNgYmfCy0Io=
66-
d7y.io/api/v2 v2.1.53 h1:WOQ0an7tx34RAXKRYu+42GICGc1tBb/BesEERwL1Y/s=
67-
d7y.io/api/v2 v2.1.53/go.mod h1:E3XBK7gLlGEGezrmQ328zYzd23js8Os3MESzaNvqrgw=
66+
d7y.io/api/v2 v2.1.55 h1:MM0Zpk6KqWAhwwHsGXfaCNt5sgJta6J8u5ewLVH03pQ=
67+
d7y.io/api/v2 v2.1.55/go.mod h1:E3XBK7gLlGEGezrmQ328zYzd23js8Os3MESzaNvqrgw=
6868
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
6969
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
7070
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=

internal/dflog/logger.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,18 @@ func WithPreheatImage(url string) *SugaredLoggerOnWith {
238238
}
239239
}
240240

241+
func WithStatImage(url string) *SugaredLoggerOnWith {
242+
return &SugaredLoggerOnWith{
243+
withArgs: []any{"url", url},
244+
}
245+
}
246+
247+
func WithStatImageAndTaskID(url, taskID string) *SugaredLoggerOnWith {
248+
return &SugaredLoggerOnWith{
249+
withArgs: []any{"url", url, "taskID", taskID},
250+
}
251+
}
252+
241253
func (log *SugaredLoggerOnWith) With(args ...any) *SugaredLoggerOnWith {
242254
args = append(args, log.withArgs...)
243255
return &SugaredLoggerOnWith{

internal/job/image.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
//go:generate mockgen -destination mocks/job_mock.go -source image.go -package mocks
18+
1719
package job
1820

1921
import (
@@ -165,10 +167,26 @@ type ManifestRequest struct {
165167
InsecureSkipVerify bool
166168
}
167169

170+
// Image implements the interface for handling container images.
171+
type Image interface {
172+
// CreatePreheatRequestsByManifestURL generates a list of preheat requests for a container image
173+
// by fetching and parsing its manifest from a registry. It handles authentication, platform-specific
174+
// manifest filtering, and layer extraction for preheating.
175+
CreatePreheatRequestsByManifestURL(ctx context.Context, req *ManifestRequest) ([]*PreheatRequest, error)
176+
}
177+
178+
// image is the implementation of the Image interface.
179+
type image struct{}
180+
181+
// NewImage creates a new instance of the Image interface.
182+
func NewImage() Image {
183+
return &image{}
184+
}
185+
168186
// CreatePreheatRequestsByManifestURL generates a list of preheat requests for a container image
169187
// by fetching and parsing its manifest from a registry. It handles authentication, platform-specific
170188
// manifest filtering, and layer extraction for preheating.
171-
func CreatePreheatRequestsByManifestURL(ctx context.Context, req *ManifestRequest) ([]PreheatRequest, error) {
189+
func (i *image) CreatePreheatRequestsByManifestURL(ctx context.Context, req *ManifestRequest) ([]*PreheatRequest, error) {
172190
ctx, span := tracer.Start(ctx, config.SpanGetLayers, trace.WithSpanKind(trace.SpanKindProducer))
173191
defer span.End()
174192

@@ -320,7 +338,7 @@ func filterManifests(manifests []manifestlist.ManifestDescriptor, platform specs
320338
// buildPreheatRequestFromManifests constructs preheat requests for container image layers from
321339
// the provided manifests. It extracts layer URLs from the manifests and builds a PreheatRequest
322340
// using the specified arguments, headers, and TLS settings.
323-
func buildPreheatRequestFromManifests(manifests []distribution.Manifest, req *ManifestRequest, header http.Header, image *preheatImage) ([]PreheatRequest, error) {
341+
func buildPreheatRequestFromManifests(manifests []distribution.Manifest, req *ManifestRequest, header http.Header, image *preheatImage) ([]*PreheatRequest, error) {
324342
var certificateChain [][]byte
325343
if req.RootCAs != nil {
326344
certificateChain = req.RootCAs.Subjects()
@@ -334,7 +352,7 @@ func buildPreheatRequestFromManifests(manifests []distribution.Manifest, req *Ma
334352
}
335353
}
336354

337-
layers := PreheatRequest{
355+
layers := &PreheatRequest{
338356
URLs: layerURLs,
339357
PieceLength: req.PieceLength,
340358
Tag: req.Tag,
@@ -352,7 +370,7 @@ func buildPreheatRequestFromManifests(manifests []distribution.Manifest, req *Ma
352370
Timeout: req.Timeout,
353371
}
354372

355-
return []PreheatRequest{layers}, nil
373+
return []*PreheatRequest{layers}, nil
356374
}
357375

358376
// imageAuthClientOption is an option for imageAuthClient.

internal/job/mocks/job_mock.go

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manager/job/job.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func New(cfg *config.Config, gdb *gorm.DB) (*Job, error) {
6262
if err != nil {
6363
return nil, err
6464
}
65-
preheat := newPreheat(j, certPool, cfg.Job.Preheat.TLS.InsecureSkipVerify)
65+
preheat := newPreheat(j, internaljob.NewImage(), certPool, cfg.Job.Preheat.TLS.InsecureSkipVerify)
6666

6767
syncPeers, err := newSyncPeers(cfg, j, gdb)
6868
if err != nil {

manager/job/preheat.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ type Preheat interface {
6161
// preheat is an implementation of Preheat.
6262
type preheat struct {
6363
job *internaljob.Job
64+
internalJobImage internaljob.Image
6465
rootCAs *x509.CertPool
6566
insecureSkipVerify bool
6667
}
6768

6869
// newPreheat creates a new Preheat.
69-
func newPreheat(job *internaljob.Job, rootCAs *x509.CertPool, insecureSkipVerify bool) Preheat {
70+
func newPreheat(job *internaljob.Job, internalJobImage internaljob.Image, rootCAs *x509.CertPool, insecureSkipVerify bool) Preheat {
7071
return &preheat{
7172
job: job,
73+
internalJobImage: internalJobImage,
7274
rootCAs: rootCAs,
7375
insecureSkipVerify: insecureSkipVerify,
7476
}
@@ -92,7 +94,7 @@ func (p *preheat) CreatePreheat(ctx context.Context, schedulers []models.Schedul
9294
return nil, errors.New("invalid params: url is required")
9395
}
9496

95-
files, err = internaljob.CreatePreheatRequestsByManifestURL(ctx, &internaljob.ManifestRequest{
97+
files, err = p.internalJobImage.CreatePreheatRequestsByManifestURL(ctx, &internaljob.ManifestRequest{
9698
URL: json.URL,
9799
PieceLength: json.PieceLength,
98100
Tag: json.Tag,

manager/service/job.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func (s *service) createPreheatRequestsByManifestURL(ctx context.Context, json t
303303
return nil, fmt.Errorf("load ca cert failed: %w", err)
304304
}
305305

306-
layers, err := internaljob.CreatePreheatRequestsByManifestURL(ctx, &internaljob.ManifestRequest{
306+
layers, err := internaljob.NewImage().CreatePreheatRequestsByManifestURL(ctx, &internaljob.ManifestRequest{
307307
URL: json.Args.URL,
308308
PieceLength: json.Args.PieceLength,
309309
Tag: json.Args.Tag,

0 commit comments

Comments
 (0)