Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cli/golem-cli/src/command_handler/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ impl InteractiveHandler {
)
}

pub fn confirm_interrupt_ephemeral_agent(&self) -> anyhow::Result<bool> {
self.confirm(
false,
"The target agent is ephemeral. Interrupting it will stop the current invocation and it cannot be resumed. Continue?",
None,
)
}

pub fn confirm_reset_allow_incompatible_component_update(
&self,
component_name: &ComponentName,
Expand Down
14 changes: 14 additions & 0 deletions cli/golem-cli/src/command_handler/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,20 @@ impl WorkerCommandHandler {
.component_by_agent_name_match(&agent_name_match)
.await?;

if component
.metadata
.agent_types()
.iter()
.find(|agent_type| agent_type.type_name == agent_name_match.agent_type_name)
.is_some_and(|agent_type| agent_type.mode == AgentMode::Ephemeral)
&& !self
.ctx
.interactive_handler()
.confirm_interrupt_ephemeral_agent()?
{
bail!(NonSuccessfulExit);
}

log_action(
"Interrupting",
format!("agent {}", format_agent_name_match(&agent_name_match)),
Expand Down
18 changes: 17 additions & 1 deletion cli/golem-cli/wit/deps/golem-1.x/golem-oplog.wit
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,19 @@ interface oplog {
resource-name: string
}

record ephemeral-sleep-too-long {
requested-nanos: u64,
max-nanos: u64
}

record ephemeral-fuel-exhausted {
overdraft-limit: u64
}

record ephemeral-cannot-suspend {
reason: string
}

/// Describes the error that occurred in the agent
variant worker-error {
unknown(string),
Expand All @@ -448,7 +461,10 @@ interface oplog {
exceeded-rpc-call-limit,
node-out-of-filesystem-storage,
agent-exceeded-filesystem-storage-limit,
agent-terminated-by-quota(agent-terminated-by-quota-error)
agent-terminated-by-quota(agent-terminated-by-quota-error),
ephemeral-sleep-too-long(ephemeral-sleep-too-long),
ephemeral-fuel-exhausted(ephemeral-fuel-exhausted),
ephemeral-cannot-suspend(ephemeral-cannot-suspend)
}

record raw-create-parameters {
Expand Down
16 changes: 16 additions & 0 deletions golem-api-grpc/proto/golem/worker/worker_error.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ message AgentError {
ExceededHttpCallLimit exceeded_http_call_limit = 13;
ExceededRpcCallLimit exceeded_rpc_call_limit = 14;
AgentTerminatedByQuota agent_terminated_by_quota = 15;
EphemeralSleepTooLong ephemeral_sleep_too_long = 16;
EphemeralFuelExhausted ephemeral_fuel_exhausted = 17;
EphemeralCannotSuspend ephemeral_cannot_suspend = 18;
}
}

Expand Down Expand Up @@ -68,3 +71,16 @@ message AgentTerminatedByQuota {
golem.common.EnvironmentId environment_id = 1;
string resource_name = 2;
}

message EphemeralSleepTooLong {
uint64 requested_nanos = 1;
uint64 max_nanos = 2;
}

message EphemeralFuelExhausted {
uint64 overdraft_limit = 1;
}

message EphemeralCannotSuspend {
string reason = 1;
}
34 changes: 33 additions & 1 deletion golem-common/src/model/oplog/protobuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ use crate::model::oplog::public_oplog_entry::{
SnapshotParams, StartSpanParams, SuccessfulUpdateParams, SuspendParams,
};
use crate::model::oplog::{
AgentTerminatedByQuotaError, DurableFunctionType, OplogEntry, PersistenceLevel,
AgentTerminatedByQuotaError, DurableFunctionType, EphemeralCannotSuspendError,
EphemeralFuelExhaustedError, EphemeralSleepTooLongError, OplogEntry, PersistenceLevel,
};
use crate::model::quota::ResourceName;
use crate::model::regions::OplogRegion;
Expand Down Expand Up @@ -129,6 +130,22 @@ impl TryFrom<golem_api_grpc::proto::golem::worker::AgentError> for AgentError {
resource_name: ResourceName(inner.resource_name),
}))
}
Error::EphemeralSleepTooLong(inner) => {
Ok(Self::EphemeralSleepTooLong(EphemeralSleepTooLongError {
requested_nanos: inner.requested_nanos,
max_nanos: inner.max_nanos,
}))
}
Error::EphemeralFuelExhausted(inner) => {
Ok(Self::EphemeralFuelExhausted(EphemeralFuelExhaustedError {
overdraft_limit: inner.overdraft_limit,
}))
}
Error::EphemeralCannotSuspend(inner) => {
Ok(Self::EphemeralCannotSuspend(EphemeralCannotSuspendError {
reason: inner.reason,
}))
}
}
}
}
Expand Down Expand Up @@ -184,6 +201,21 @@ impl From<AgentError> for golem_api_grpc::proto::golem::worker::AgentError {
resource_name: details.resource_name.0,
})
}
AgentError::EphemeralSleepTooLong(EphemeralSleepTooLongError {
requested_nanos,
max_nanos,
}) => Error::EphemeralSleepTooLong(grpc_worker::EphemeralSleepTooLong {
requested_nanos,
max_nanos,
}),
AgentError::EphemeralFuelExhausted(EphemeralFuelExhaustedError { overdraft_limit }) => {
Error::EphemeralFuelExhausted(grpc_worker::EphemeralFuelExhausted {
overdraft_limit,
})
}
AgentError::EphemeralCannotSuspend(EphemeralCannotSuspendError { reason }) => {
Error::EphemeralCannotSuspend(grpc_worker::EphemeralCannotSuspend { reason })
}
};
Self { error: Some(error) }
}
Expand Down
28 changes: 28 additions & 0 deletions golem-common/src/model/oplog/raw_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,25 @@ pub struct AgentTerminatedByQuotaError {
pub resource_name: ResourceName,
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, BinaryCodec, IntoValue, FromValue)]
#[wit(name = "ephemeral-sleep-too-long", owner = "golem:api@1.5.0/oplog")]
pub struct EphemeralSleepTooLongError {
pub requested_nanos: u64,
pub max_nanos: u64,
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, BinaryCodec, IntoValue, FromValue)]
#[wit(name = "ephemeral-fuel-exhausted", owner = "golem:api@1.5.0/oplog")]
pub struct EphemeralFuelExhaustedError {
pub overdraft_limit: u64,
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, BinaryCodec, IntoValue, FromValue)]
#[wit(name = "ephemeral-cannot-suspend", owner = "golem:api@1.5.0/oplog")]
pub struct EphemeralCannotSuspendError {
pub reason: String,
}

/// Describes the error that occurred in the worker
#[derive(Clone, Debug, PartialEq, Eq, Hash, BinaryCodec, IntoValue, FromValue)]
#[wit(name = "worker-error", owner = "golem:api@1.5.0/oplog")]
Expand All @@ -381,6 +400,12 @@ pub enum AgentError {
AgentExceededFilesystemStorageLimit,
// The agent was terminated by a quota with the terminae enforcement action (permanent)
AgentTerminatedByQuota(AgentTerminatedByQuotaError),
// Ephemeral agents cannot suspend and the requested sleep exceeded the configured maximum
EphemeralSleepTooLong(EphemeralSleepTooLongError),
// Ephemeral agent exhausted its per-invocation fuel overdraft allowance
EphemeralFuelExhausted(EphemeralFuelExhaustedError),
// Ephemeral agent reached a condition that would suspend a durable agent
EphemeralCannotSuspend(EphemeralCannotSuspendError),
}

impl AgentError {
Expand All @@ -401,6 +426,9 @@ impl AgentError {
Self::NodeOutOfFilesystemStorage => "Out of storage space",
Self::AgentExceededFilesystemStorageLimit => "Exceeded plan storage limit",
Self::AgentTerminatedByQuota(_) => "Terminated by quota",
Self::EphemeralSleepTooLong(_) => "Ephemeral sleep too long",
Self::EphemeralFuelExhausted(_) => "Ephemeral fuel exhausted",
Self::EphemeralCannotSuspend(_) => "Ephemeral agent cannot suspend",
}
}

Expand Down
18 changes: 17 additions & 1 deletion golem-common/wit/deps/golem-1.x/golem-oplog.wit
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,19 @@ interface oplog {
resource-name: string
}

record ephemeral-sleep-too-long {
requested-nanos: u64,
max-nanos: u64
}

record ephemeral-fuel-exhausted {
overdraft-limit: u64
}

record ephemeral-cannot-suspend {
reason: string
}

/// Describes the error that occurred in the agent
variant worker-error {
unknown(string),
Expand All @@ -448,7 +461,10 @@ interface oplog {
exceeded-rpc-call-limit,
node-out-of-filesystem-storage,
agent-exceeded-filesystem-storage-limit,
agent-terminated-by-quota(agent-terminated-by-quota-error)
agent-terminated-by-quota(agent-terminated-by-quota-error),
ephemeral-sleep-too-long(ephemeral-sleep-too-long),
ephemeral-fuel-exhausted(ephemeral-fuel-exhausted),
ephemeral-cannot-suspend(ephemeral-cannot-suspend)
}

record raw-create-parameters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ GOLEM__KEY_VALUE_STORAGE__CONFIG__RETRIES__MAX_DELAY="2s"
GOLEM__KEY_VALUE_STORAGE__CONFIG__RETRIES__MAX_JITTER_FACTOR=0.15
GOLEM__KEY_VALUE_STORAGE__CONFIG__RETRIES__MIN_DELAY="100ms"
GOLEM__KEY_VALUE_STORAGE__CONFIG__RETRIES__MULTIPLIER=2.0
GOLEM__LIMITS__EPHEMERAL_FUEL_OVERDRAFT_MULTIPLIER=100
GOLEM__LIMITS__EPOCH_INTERVAL="10ms"
GOLEM__LIMITS__EPOCH_TICKS=1
GOLEM__LIMITS__EVENT_BROADCAST_CAPACITY=1024
Expand Down Expand Up @@ -112,6 +113,7 @@ GOLEM__RETRY__MAX_JITTER_FACTOR=0.15
GOLEM__RETRY__MIN_DELAY="100ms"
GOLEM__RETRY__MULTIPLIER=3.0
GOLEM__SCHEDULER__REFRESH_INTERVAL="2s"
GOLEM__SUSPEND__EPHEMERAL_MAX_SLEEP="1m"
GOLEM__SUSPEND__SUSPEND_AFTER="10s"
GOLEM__TRACING__CONSOLE=false
GOLEM__TRACING__DTOR_FRIENDLY=false
Expand Down Expand Up @@ -196,6 +198,7 @@ GOLEM__KEY_VALUE_STORAGE__CONFIG__RETRIES__MAX_DELAY="2s"
GOLEM__KEY_VALUE_STORAGE__CONFIG__RETRIES__MAX_JITTER_FACTOR=0.15
GOLEM__KEY_VALUE_STORAGE__CONFIG__RETRIES__MIN_DELAY="100ms"
GOLEM__KEY_VALUE_STORAGE__CONFIG__RETRIES__MULTIPLIER=2.0
GOLEM__LIMITS__EPHEMERAL_FUEL_OVERDRAFT_MULTIPLIER=100
GOLEM__LIMITS__EPOCH_INTERVAL="10ms"
GOLEM__LIMITS__EPOCH_TICKS=1
GOLEM__LIMITS__EVENT_BROADCAST_CAPACITY=1024
Expand Down Expand Up @@ -270,6 +273,7 @@ GOLEM__RETRY__MAX_JITTER_FACTOR=0.15
GOLEM__RETRY__MIN_DELAY="100ms"
GOLEM__RETRY__MULTIPLIER=3.0
GOLEM__SCHEDULER__REFRESH_INTERVAL="2s"
GOLEM__SUSPEND__EPHEMERAL_MAX_SLEEP="1m"
GOLEM__SUSPEND__SUSPEND_AFTER="10s"
GOLEM__TRACING__CONSOLE=false
GOLEM__TRACING__DTOR_FRIENDLY=false
Expand Down
4 changes: 4 additions & 0 deletions golem-debugging-service/config/debug-worker-executor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ min_delay = "100ms"
multiplier = 2.0

[limits]
ephemeral_fuel_overdraft_multiplier = 100
epoch_interval = "10ms"
epoch_ticks = 1
event_broadcast_capacity = 1024
Expand Down Expand Up @@ -187,6 +188,7 @@ multiplier = 3.0
refresh_interval = "2s"

[suspend]
ephemeral_max_sleep = "1m"
suspend_after = "10s"

[tracing]
Expand Down Expand Up @@ -314,6 +316,7 @@ without_time = false
# multiplier = 2.0
#
# [limits]
# ephemeral_fuel_overdraft_multiplier = 100
# epoch_interval = "10ms"
# epoch_ticks = 1
# event_broadcast_capacity = 1024
Expand Down Expand Up @@ -430,6 +433,7 @@ without_time = false
# refresh_interval = "2s"
#
# [suspend]
# ephemeral_max_sleep = "1m"
# suspend_after = "10s"
#
# [tracing]
Expand Down
6 changes: 3 additions & 3 deletions golem-debugging-service/src/debug_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use golem_common::model::component::ComponentRevision;
use golem_common::model::invocation_context::{
self, AttributeValue, InvocationContextStack, SpanId,
};
use golem_common::model::oplog::TimestampedUpdateDescription;
use golem_common::model::oplog::{AgentError, TimestampedUpdateDescription};
use golem_common::model::{
AgentId, AgentInvocation, AgentInvocationOutput, AgentStatusRecord, IdempotencyKey,
OwnedAgentId, Timestamp,
Expand Down Expand Up @@ -98,8 +98,8 @@ impl DurableWorkerCtxView<DebugContext> for DebugContext {

#[async_trait]
impl FuelManagement for DebugContext {
fn ensure_fuel(&mut self, _current_level: u64) -> bool {
true
fn ensure_fuel(&mut self, _current_level: u64) -> Result<(), AgentError> {
Ok(())
}

fn return_fuel(&mut self, _current_level: u64) -> u64 {
Expand Down
18 changes: 17 additions & 1 deletion golem-wasm/wit/deps/golem-1.x/golem-oplog.wit
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,19 @@ interface oplog {
resource-name: string
}

record ephemeral-sleep-too-long {
requested-nanos: u64,
max-nanos: u64
}

record ephemeral-fuel-exhausted {
overdraft-limit: u64
}

record ephemeral-cannot-suspend {
reason: string
}

/// Describes the error that occurred in the agent
variant worker-error {
unknown(string),
Expand All @@ -448,7 +461,10 @@ interface oplog {
exceeded-rpc-call-limit,
node-out-of-filesystem-storage,
agent-exceeded-filesystem-storage-limit,
agent-terminated-by-quota(agent-terminated-by-quota-error)
agent-terminated-by-quota(agent-terminated-by-quota-error),
ephemeral-sleep-too-long(ephemeral-sleep-too-long),
ephemeral-fuel-exhausted(ephemeral-fuel-exhausted),
ephemeral-cannot-suspend(ephemeral-cannot-suspend)
}

record raw-create-parameters {
Expand Down
8 changes: 4 additions & 4 deletions golem-worker-executor-test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ use golem_common::model::invocation_context::{
AttributeValue, InvocationContextSpan, InvocationContextStack, SpanId,
};
use golem_common::model::oplog::{
OplogEntry, PayloadId, PersistenceLevel, RawOplogPayload, TimestampedUpdateDescription,
types::ObjectMetadata,
AgentError, OplogEntry, PayloadId, PersistenceLevel, RawOplogPayload,
TimestampedUpdateDescription, types::ObjectMetadata,
};
use golem_common::model::plan::PlanId;
use golem_common::model::worker::{AgentConfigEntryDto, AgentMetadataDto};
Expand Down Expand Up @@ -733,8 +733,8 @@ impl wasmtime_wasi::p2::bindings::cli::environment::Host for TestWorkerCtx {

#[async_trait]
impl FuelManagement for TestWorkerCtx {
fn ensure_fuel(&mut self, _current_level: u64) -> bool {
true
fn ensure_fuel(&mut self, _current_level: u64) -> Result<(), AgentError> {
Ok(())
}

fn return_fuel(&mut self, _current_level: u64) -> u64 {
Expand Down
Loading
Loading