这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@edigaryev
Copy link
Collaborator

Resolves #39.

@edigaryev edigaryev requested a review from fkorotkov May 24, 2022 22:43
defaultLogger.appendNewLine("caching \(localName) as \(pushedToRemoteName)...")

let ociVMDir = try VMStorageOCI().create(pushedToRemoteName, overwrite: true)
try localVMDir.clone(to: ociVMDir, generateMAC: false)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think Tart should only clone once into the shaXXX folder and then create symlinks for all the pushed fully qualified remote names. 🤔

Copy link
Collaborator Author

@edigaryev edigaryev May 26, 2022

Choose a reason for hiding this comment

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

Good catch! See c5de388.

@edigaryev edigaryev force-pushed the tart-push-populate-cache branch from c00fc09 to eb35fa5 Compare May 26, 2022 09:24
@edigaryev edigaryev requested a review from fkorotkov May 26, 2022 10:39
@edigaryev edigaryev force-pushed the tart-push-populate-cache branch from 6cc5402 to b9432be Compare May 26, 2022 10:40
@edigaryev edigaryev force-pushed the tart-push-populate-cache branch from b9432be to c5de388 Compare May 26, 2022 11:03
Comment on lines 45 to 56
let manifestDigest = try await localVMDir.pushToRegistry(registry: registry, references: remoteNamesForRegistry.map{ $0.reference.value })

try await localVMDir.pushToRegistry(registry: registry, references: remoteNamesForRegistry.map{ $0.reference })
// Populate the local cache (if requested)
if populateCache {
for remoteName in remoteNamesForRegistry {
defaultLogger.appendNewLine("caching \(localName) as \(remoteName)...")

if let cacheToVMDir = try VMStorageOCI().cache(name: remoteName, digest: manifestDigest) {
try localVMDir.clone(to: cacheToVMDir, generateMAC: false)
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic looks a bit too complex. And I still think there is too much cloning is going on. What if pushToRegistry will return a RemoteName with the shaXXX` then the cache population logic might be much simpler:

let digestRemoteName = try await localVMDir.pushToRegistry(registry: registry, references: remoteNamesForRegistry.map{ $0.reference.value })

if populateCache {
  let ociStorage = VMStorageOCI()
  let digestVMDir = ociStorage.create(digestRemoteName)
  try localVMDir.clone(to: digestVMDir, generateMAC: false)
  for remoteName in remoteNamesForRegistry {
    ociStorage.link(from: remoteName, to: digestVMDir)
  }
}

Copy link
Collaborator Author

@edigaryev edigaryev May 26, 2022

Choose a reason for hiding this comment

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

And I still think there is too much cloning is going on.

It only clones if the "digest" directory doesn't exist, otherwise creates a symbolic link. This is achieved by re-using the pull() code.

What if pushToRegistry will return a RemoteName with the shaXXX` then the cache population logic might be much simpler:

I see two downsides to this:

  1. It seems that the localVMDir.clone() will always clone.
  2. Not reusing the pull()'s logic results in needless duplication.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there will much "needless duplication". 🤷‍♂️ Here is my take #107

@edigaryev edigaryev requested a review from fkorotkov May 26, 2022 14:24

struct Set: AsyncParsableCommand {
static var configuration = CommandConfiguration(abstract: "Modify VM's configuration")
struct SetCommand: AsyncParsableCommand {
Copy link
Contributor

Choose a reason for hiding this comment

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

All the files in Commands folder doesn't have Command suffix. What's the reasoning for this particular rename?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What's the reasoning for this particular rename?

Set command collides with the Set collection.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's in the scope of this PR. There is no usage of Set. IMO we shouild either rename all the commands or wait util there will be a collision.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reverted in d59f4ec.

@edigaryev edigaryev requested a review from fkorotkov May 27, 2022 15:42
@edigaryev edigaryev enabled auto-merge (squash) May 27, 2022 18:36
@edigaryev edigaryev merged commit 5446164 into main May 29, 2022
@edigaryev edigaryev deleted the tart-push-populate-cache branch May 29, 2022 03:20
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.

Pushing of an image should populate local cache

3 participants