Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add a paramter labels to CreateSnapshot #2569

Closed
wants to merge 3 commits into from

Conversation

firjest
Copy link

@firjest firjest commented Dec 18, 2018

Signed-off-by: yifang.jy yifang.jy@alibaba-inc.com

Ⅰ. Describe what this PR did

snapshot interface has labels parameter, so add this parameter to pouch CreateSnapshot In some case use can pass labels.

Ⅱ. Does this pull request fix one issue?

NO

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

NO

Ⅳ. Describe how to verify it

NO

Ⅴ. Special notes for reviews

Signed-off-by: yifang.jy <yifang.jy@alibaba-inc.com>
@codecov
Copy link

codecov bot commented Dec 18, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@3470d89). Click here to learn what that means.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2569   +/-   ##
=========================================
  Coverage          ?   69.17%           
=========================================
  Files             ?      278           
  Lines             ?    18687           
  Branches          ?        0           
=========================================
  Hits              ?    12926           
  Misses            ?     4284           
  Partials          ?     1477
Flag Coverage Δ
#criv1alpha1test 31.45% <60%> (?)
#criv1alpha2test 35.7% <60%> (?)
#integrationtest 40.75% <60%> (?)
#nodee2etest 32.75% <60%> (?)
#unittest 26.66% <0%> (?)
Impacted Files Coverage Δ
daemon/mgr/container_upgrade.go 65.09% <0%> (ø)
daemon/mgr/container.go 59% <0%> (ø)
ctrd/snapshot.go 71.42% <100%> (ø)

@pouchrobot
Copy link
Collaborator

We found this is your first time to contribute to Pouch, @firjest
👏 We really appreciate it.
Just remind that you have read the contribution guide: https://github.com/alibaba/pouch/blob/master/CONTRIBUTING.md
If you didn't, you should do that first. If done, welcome again and please enjoy hacking! 🍻

@CLAassistant
Copy link

CLAassistant commented Dec 18, 2018

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ yifang.jy
❌ firjest


yifang.jy seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -93,7 +93,7 @@ type ImageAPIClient interface {
// SnapshotAPIClient provides access to containerd snapshot features
type SnapshotAPIClient interface {
// CreateSnapshot creates a active snapshot with image's name and id.
CreateSnapshot(ctx context.Context, id, ref string) error
CreateSnapshot(ctx context.Context, id, ref string, labels *map[string]string) error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we should use *map[string]string

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

ctrd/snapshot.go Outdated
@@ -31,8 +31,13 @@ func (c *Client) CreateSnapshot(ctx context.Context, id, ref string) error {
return err
}

var opts []snapshots.Opt
if labels != nil && len(*labels) > 0 {
opts = append(opts, snapshots.WithLabels(*labels))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just opts := []snapshots.Opt{snapshots.WithLabels(labels)}, of course, not use *map here, see last comment

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -383,7 +383,7 @@ func (mgr *ContainerManager) Create(ctx context.Context, name string, config *ty

snapID := id
// create a snapshot with image.
if err := mgr.Client.CreateSnapshot(ctx, snapID, config.Image); err != nil {
if err := mgr.Client.CreateSnapshot(ctx, snapID, config.Image, nil); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we should get somewhere to pass the label, or it will always be nil

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add a snapshot-opt which keep options for snapshotter

Signed-off-by: yifang.jy <yifang.jy@alibaba-inc.com>
@wangforthinker
Copy link
Contributor

To support this feature, containerd should make some changes like this! https://github.com/alibaba/containerd/pull/5/files#diff-491f07c28eb851b720f11ce0d3dbb4f8R331
. In current version of v1.0.3, containerd do not pass these opts to snapshotter when call method Prepare.

@pouchrobot
Copy link
Collaborator

@firjest Thanks for your contribution. 🍻
Please sign off in each of your commits.

@Ace-Tang
Copy link
Contributor

@wangforthinker , we should consider do not effect containerd, let's hold on this pr

@allencloud allencloud changed the title add a paramter labels to CreateSnapshot feature: add a paramter labels to CreateSnapshot Jan 2, 2019
@pouchrobot
Copy link
Collaborator

ping @firjest
Conflict happens after merging a previous commit.
Please rebase the branch against master and push it back again. Thanks a lot.

@firjest firjest closed this Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants