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

Use dynamic client to create volume snapshots #629

Merged
merged 9 commits into from
Mar 20, 2020
Merged

Conversation

PrasadG193
Copy link
Contributor

@PrasadG193 PrasadG193 commented Mar 18, 2020

Change Overview

Use dynamic client to create volume snapshots
Remove external-snapshotter dep from snapshot pkg
New interface Snapshotter to perform snapshot operations
Remove external-snapshotter dep from kube/volume package

Pull request type

Please check the type of change your PR introduces:

  • 🚧 Work in Progress
  • 🌈 Refactoring (no functional changes, no api changes)
  • 🐹 Trivial/Minor
  • 🐛 Bugfix
  • 🌻 Feature
  • 🗺️ Documentation
  • 🤖 Test

Issues

  • #XXX

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

Remove external-snapshotter dep from snapshot pkg

Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Refactor tests to resolve import conflicts

Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
GetVolumeSnapshotClass checks if VolumeSnapshotClass exists
with given annotations

Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
@PrasadG193 PrasadG193 requested review from tdmanv and vkamra March 18, 2020 17:03
@vkamra vkamra requested a review from bathina2 March 18, 2020 17:40
Copy link
Contributor

@bathina2 bathina2 left a comment

Choose a reason for hiding this comment

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

Couple of changes

pkg/kube/snapshot/snapshot_alpha.go Outdated Show resolved Hide resolved
pkg/kube/snapshot/snapshot_alpha.go Show resolved Hide resolved
pkg/kube/snapshot/snapshot_alpha.go Outdated Show resolved Hide resolved
pkg/kube/snapshot/snapshot_alpha.go Outdated Show resolved Hide resolved
pkg/kube/snapshot/snapshot.go Outdated Show resolved Hide resolved
)

const (
pvcKind = "PersistentVolumeClaim"
Copy link
Contributor

Choose a reason for hiding this comment

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

PVCKind

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we export PVCKind though we are not using it anywhere else?

Copy link
Contributor

Choose a reason for hiding this comment

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

Its my opinion but these are well known and commonly used Kinds. Maybe they should be in a common kubernetes library, if they don't already exist. Not sure if the kubernetes client library has these defined but if it does we should use the ones they have instead of maintaining them ourselves.

pkg/kube/snapshot/snapshot_alpha.go Show resolved Hide resolved
pkg/kube/snapshot/snapshot_alpha.go Outdated Show resolved Hide resolved
pkg/kube/snapshot/snapshot_alpha.go Outdated Show resolved Hide resolved
return errors.Errorf("Failed to query target Volumesnapshot: %s, Namespace: %s: %v", cloneName, cloneNamespace, err)
}

src, err := sna.GetSource(ctx, name, namespace)
Copy link
Contributor

Choose a reason for hiding this comment

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

You already fetched the original snapshot once above, this would make a second call to get the same object. I suggest calling sna.getContent. or creating something like get source from snapshot

Copy link
Contributor

Choose a reason for hiding this comment

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

Again you are doing two snapshot.Get() calls. you already have the snapshot object.

Copy link
Contributor

Choose a reason for hiding this comment

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

Tell me why you want to resolve this. I think you can change the signature of GetSource to take a snapshot object and build a source. The only place this is used in K10 is in phase/snapshot.go line 316. and we're calling snapshot get before it there too. Theres no reason to make 2 calls to kubernetes to get the same snapshot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am sorry, I guess clicked "resolve" accidentally. I have another PR which already takes care of the optimisations. But we can address this here itself. In this PR, I have just moved the methods from snapshot.go to snapshot_alpha.go and changed the snapcli to dyncli without making any changes in existing workflow. I was thinking of handling optimisations in another PR

Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
@mergify mergify bot merged commit 8cadec7 into master Mar 20, 2020
@mergify mergify bot deleted the snapshot-dyn-client branch March 20, 2020 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants