daytona 0.164.0 → 0.166.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce668bd56c2b7767f624eb0bbb347ed6144cc40782d8d27a857783a82448ae60
4
- data.tar.gz: 6587e4186ff8ee24dbf55acb5be580d71c507b8bb1d76acf9badc891778e8630
3
+ metadata.gz: a19065d8a53dd2a88abfa7062056867b4cc684faf401f6480ff6fa91c618311e
4
+ data.tar.gz: 451ace31b34a4360e70f3c5f79522c4faa0a5a3f5cd09aaf353117c2534a2953
5
5
  SHA512:
6
- metadata.gz: 8f561638b39e7cf53f5d3488ba592a3ccbd93a395ba85e5622ee7c9b7ba909dd34235ccad5947ed5565d2c116c0c7d8fe78e51f7547936839705a2b9824a2474
7
- data.tar.gz: dbf8ffab3facea88678ad36b8a8af77d8bd73087ed3c1fcf8cbe5aef11a3bd85924467227f7b0c58b90ac3540da82086dbb0cb3345be55b7677797b939cf2f85
6
+ metadata.gz: 22f3f2d140e3846532c57780774c1346c69e0575d53778e7cfda0d62cf2495d94bf79a28dd1a0c5f2779df332bc1eebf78ded0825473138b9422358638366ac1
7
+ data.tar.gz: 95044c2bae2db13b158e9530a83196cac9758711542733751c250791deeec5bbb4a7ba498be6482a63632c523feacd481692ee0d8b451fa784d30aea2cfc351c
@@ -465,12 +465,59 @@ module Daytona
465
465
  DaytonaApiClient::SandboxState::DESTROYED])
466
466
  end
467
467
 
468
+ # Forks the Sandbox, creating a new Sandbox with an identical filesystem.
469
+ # The forked Sandbox is a copy-on-write clone of the original. It starts
470
+ # with the same disk contents but operates independently from that point on.
471
+ #
472
+ # @param name [String, nil] Optional name for the forked Sandbox
473
+ # @param timeout [Numeric] Maximum wait time in seconds (defaults to 60 s)
474
+ # @return [Daytona::Sandbox] The forked Sandbox
475
+ def experimental_fork(name: nil, timeout: DEFAULT_TIMEOUT) # rubocop:disable Metrics/MethodLength
476
+ forked_dto = nil
477
+ with_timeout(
478
+ timeout:,
479
+ message: "Sandbox #{id} fork failed to become ready within the #{timeout} seconds timeout period",
480
+ setup: proc {
481
+ forked_dto = sandbox_api.fork_sandbox(id, DaytonaApiClient::ForkSandbox.new(name:))
482
+ }
483
+ ) do
484
+ forked = Sandbox.new(
485
+ sandbox_dto: forked_dto,
486
+ config:,
487
+ sandbox_api:,
488
+ code_toolbox:,
489
+ otel_state:
490
+ )
491
+ forked.send(:wait_for_states, operation: OPERATION_START,
492
+ target_states: [DaytonaApiClient::SandboxState::STARTED])
493
+ return forked
494
+ end
495
+ end
496
+
497
+ # Creates a snapshot from the current state of the Sandbox.
498
+ # The Sandbox will temporarily enter a 'snapshotting' state and return to its previous state when complete.
499
+ #
500
+ # @param name [String] Name for the new snapshot
501
+ # @param timeout [Numeric] Maximum wait time in seconds (defaults to 60 s)
502
+ # @return [void]
503
+ def experimental_create_snapshot(name:, timeout: DEFAULT_TIMEOUT)
504
+ with_timeout(
505
+ timeout:,
506
+ message: "Sandbox #{id} snapshot failed within the #{timeout} seconds timeout period",
507
+ setup: proc {
508
+ sandbox_api.create_sandbox_snapshot(id, DaytonaApiClient::CreateSandboxSnapshot.new(name:))
509
+ refresh
510
+ }
511
+ ) { wait_for_snapshot_complete }
512
+ end
513
+
468
514
  instrument :archive, :auto_archive_interval=, :auto_delete_interval=, :auto_stop_interval=,
469
515
  :create_ssh_access, :delete, :get_user_home_dir, :get_work_dir, :labels=,
470
516
  :preview_url, :create_signed_preview_url, :expire_signed_preview_url,
471
517
  :refresh, :refresh_activity, :revoke_ssh_access, :start, :recover, :stop,
472
518
  :create_lsp_server, :validate_ssh_access, :wait_for_sandbox_start,
473
519
  :wait_for_sandbox_stop, :resize, :wait_for_resize_complete,
520
+ :experimental_fork, :experimental_create_snapshot,
474
521
  component: 'Sandbox'
475
522
 
476
523
  private
@@ -593,5 +640,25 @@ module Daytona
593
640
 
594
641
  OPERATION_RESIZE = :resize
595
642
  private_constant :OPERATION_RESIZE
643
+
644
+ def wait_for_snapshot_complete
645
+ interval = INITIAL_POLL_INTERVAL
646
+ start_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
647
+ while state == DaytonaApiClient::SandboxState::SNAPSHOTTING
648
+ refresh
649
+
650
+ if [DaytonaApiClient::SandboxState::ERROR, DaytonaApiClient::SandboxState::BUILD_FAILED].include?(state)
651
+ raise Sdk::Error,
652
+ "Sandbox #{id} snapshot failed with state: #{state}, error reason: #{error_reason}"
653
+ end
654
+
655
+ break if state != DaytonaApiClient::SandboxState::SNAPSHOTTING
656
+
657
+ sleep(interval)
658
+ if ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start_time > 5
659
+ interval = [interval * BACKOFF_MULTIPLIER, MAX_POLL_INTERVAL].min
660
+ end
661
+ end
662
+ end
596
663
  end
597
664
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Daytona
4
4
  module Sdk
5
- VERSION = '0.164.0'
5
+ VERSION = '0.166.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daytona
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.164.0
4
+ version: 0.166.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daytona Platforms Inc.
@@ -85,28 +85,28 @@ dependencies:
85
85
  requirements:
86
86
  - - '='
87
87
  - !ruby/object:Gem::Version
88
- version: 0.164.0
88
+ version: 0.166.0
89
89
  type: :runtime
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 0.164.0
95
+ version: 0.166.0
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: daytona_toolbox_api_client
98
98
  requirement: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 0.164.0
102
+ version: 0.166.0
103
103
  type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 0.164.0
109
+ version: 0.166.0
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: dotenv
112
112
  requirement: !ruby/object:Gem::Requirement