From b4b4b688d355203bc2322fafa32e517885378083 Mon Sep 17 00:00:00 2001 From: Taahir Ahmed Date: Tue, 7 Jul 2026 15:03:48 -0700 Subject: [PATCH 1/7] Remove volume type enum --- .../internal/controlapi/workload_spec.go | 2 - .../internal/controlapi/workload_spec_test.go | 4 - cmd/atelet/main.go | 7 +- cmd/atelet/main_test.go | 6 +- cmd/atelet/oci.go | 10 +- cmd/atelet/oci_test.go | 4 +- cmd/atelet/volumes.go | 6 - cmd/atelet/volumes_test.go | 6 +- internal/proto/ateletpb/atelet.pb.go | 241 +++++++----------- internal/proto/ateletpb/atelet.proto | 12 +- 10 files changed, 107 insertions(+), 191 deletions(-) diff --git a/cmd/ateapi/internal/controlapi/workload_spec.go b/cmd/ateapi/internal/controlapi/workload_spec.go index 4289ff2ed..e94e9875d 100644 --- a/cmd/ateapi/internal/controlapi/workload_spec.go +++ b/cmd/ateapi/internal/controlapi/workload_spec.go @@ -33,7 +33,6 @@ func workloadSpecFromActorTemplate(actorTemplate *atev1alpha1.ActorTemplate, act if vol.VolumeSource.DurableDir != nil { workloadSpec.Volumes = append(workloadSpec.Volumes, &ateletpb.Volume{ Name: vol.Name, - Type: ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR, Source: &ateletpb.Volume_DurableDir{ DurableDir: &ateletpb.DurableDirVolume{}, }, @@ -104,7 +103,6 @@ func appendExternalVolumes(workloadSpec *ateletpb.WorkloadSpec, template *atev1a } workloadSpec.Volumes = append(workloadSpec.Volumes, &ateletpb.Volume{ Name: vol.Name, - Type: ateletpb.VolumeType_VOLUME_TYPE_EXTERNAL, Source: &ateletpb.Volume_External{ External: &ateletpb.ExternalVolumeSource{ StorageVolumeId: storageVolID, diff --git a/cmd/ateapi/internal/controlapi/workload_spec_test.go b/cmd/ateapi/internal/controlapi/workload_spec_test.go index 569945713..d7e36df67 100644 --- a/cmd/ateapi/internal/controlapi/workload_spec_test.go +++ b/cmd/ateapi/internal/controlapi/workload_spec_test.go @@ -55,7 +55,6 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) { Volumes: []*ateletpb.Volume{ { Name: "home", - Type: ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR, Source: &ateletpb.Volume_DurableDir{DurableDir: &ateletpb.DurableDirVolume{}}, }, }, @@ -95,7 +94,6 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) { Volumes: []*ateletpb.Volume{ { Name: "home", - Type: ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR, Source: &ateletpb.Volume_DurableDir{DurableDir: &ateletpb.DurableDirVolume{}}, }, }, @@ -127,7 +125,6 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) { Volumes: []*ateletpb.Volume{ { Name: "home", - Type: ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR, Source: &ateletpb.Volume_DurableDir{DurableDir: &ateletpb.DurableDirVolume{}}, }, }, @@ -308,7 +305,6 @@ func TestAppendExternalVolumes(t *testing.T) { Volumes: []*ateletpb.Volume{ { Name: "vol-1", - Type: ateletpb.VolumeType_VOLUME_TYPE_EXTERNAL, Source: &ateletpb.Volume_External{ External: &ateletpb.ExternalVolumeSource{ StorageVolumeId: "vol-gce-pd-123", diff --git a/cmd/atelet/main.go b/cmd/atelet/main.go index 0fcd67c02..e513ff161 100644 --- a/cmd/atelet/main.go +++ b/cmd/atelet/main.go @@ -1373,7 +1373,7 @@ func (s *AteomHerder) prepareOCIBundles( } // make directories for all durable-dir volumes for _, vol := range spec.GetVolumes() { - if vol.GetType() == ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR { + if vol.GetDurableDir() != nil { volPath := ateompath.DurableDirVolumeMountPoint(actorUID, vol.GetName()) if err := os.MkdirAll(volPath, 0o700); err != nil { return fmt.Errorf("while creating %q: %w", volPath, err) @@ -1392,7 +1392,7 @@ func (s *AteomHerder) prepareOCIBundles( // Declare durable-dir volumes to gVisor. We use the volume name as the // mount hint name to support multiple durable-dir volumes. for _, vol := range spec.GetVolumes() { - if vol.GetType() == ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR { + if vol.GetDurableDir() != nil { annotations[fmt.Sprintf("dev.gvisor.spec.mount.%s.type", vol.GetName())] = "bind" annotations[fmt.Sprintf("dev.gvisor.spec.mount.%s.share", vol.GetName())] = "container" annotations[fmt.Sprintf("dev.gvisor.spec.mount.%s.source", vol.GetName())] = ateompath.DurableDirVolumeMountPoint(actorUID, vol.GetName()) @@ -1470,7 +1470,8 @@ func (s *AteomHerder) dialAteom(ctx context.Context, targetAteomUid string) (ate func buildAteomWorkloadSpec(spec *ateletpb.WorkloadSpec) *ateompb.WorkloadSpec { ddVolumes := make(map[string]bool) for _, vol := range spec.GetVolumes() { - if vol.GetType() == ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR { + switch vol.GetSource().(type) { + case *ateletpb.Volume_DurableDir: ddVolumes[vol.GetName()] = true } } diff --git a/cmd/atelet/main_test.go b/cmd/atelet/main_test.go index 1bb492db4..700b26ddd 100644 --- a/cmd/atelet/main_test.go +++ b/cmd/atelet/main_test.go @@ -702,9 +702,9 @@ func TestBuildAteomWorkloadSpecForwardsReadyz(t *testing.T) { func TestBuildAteomWorkloadSpecForwardsDurableDirMounts(t *testing.T) { in := &ateletpb.WorkloadSpec{ Volumes: []*ateletpb.Volume{ - {Name: "data", Type: ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR}, - {Name: "cache", Type: ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR}, - {Name: "scratch", Type: ateletpb.VolumeType_VOLUME_TYPE_EXTERNAL}, + {Name: "data", Source: &ateletpb.Volume_DurableDir{DurableDir: &ateletpb.DurableDirVolume{}}}, + {Name: "cache", Source: &ateletpb.Volume_DurableDir{DurableDir: &ateletpb.DurableDirVolume{}}}, + {Name: "scratch", Source: &ateletpb.Volume_External{External: &ateletpb.ExternalVolumeSource{}}}, }, Containers: []*ateletpb.Container{ { diff --git a/cmd/atelet/oci.go b/cmd/atelet/oci.go index e1476610c..74fb8f93a 100644 --- a/cmd/atelet/oci.go +++ b/cmd/atelet/oci.go @@ -295,17 +295,17 @@ func buildActorOCISpec(actorUID string, args []string, env []string, annotations } // Prepare and mount all volumes. - volumeTypes := make(map[string]ateletpb.VolumeType) + volumesByName := make(map[string]*ateletpb.Volume) for _, vol := range volumes { - volumeTypes[vol.GetName()] = vol.GetType() + volumesByName[vol.GetName()] = vol } for _, vm := range volumeMounts { var srcPath string - switch volumeTypes[vm.GetName()] { - case ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR: + switch volumesByName[vm.GetName()].GetSource().(type) { + case *ateletpb.Volume_DurableDir: srcPath = ateompath.DurableDirVolumeMountPoint(actorUID, vm.GetName()) - case ateletpb.VolumeType_VOLUME_TYPE_EXTERNAL: + case *ateletpb.Volume_External: srcPath = ateompath.VolumeHostPath(actorUID, vm.GetName()) default: continue diff --git a/cmd/atelet/oci_test.go b/cmd/atelet/oci_test.go index 433c082c3..1f492092a 100644 --- a/cmd/atelet/oci_test.go +++ b/cmd/atelet/oci_test.go @@ -211,8 +211,8 @@ func TestBuildActorOCISpec_DurableDirVolumeMounts(t *testing.T) { {Name: "cache", MountPath: "/var/cache"}, } volumes := []*ateletpb.Volume{ - {Name: "data", Type: ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR}, - {Name: "cache", Type: ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR}, + {Name: "data", Source: &ateletpb.Volume_DurableDir{DurableDir: &ateletpb.DurableDirVolume{}}}, + {Name: "cache", Source: &ateletpb.Volume_DurableDir{DurableDir: &ateletpb.DurableDirVolume{}}}, } spec := buildActorOCISpec( actorUID, diff --git a/cmd/atelet/volumes.go b/cmd/atelet/volumes.go index 639bb6e75..492aadc10 100644 --- a/cmd/atelet/volumes.go +++ b/cmd/atelet/volumes.go @@ -31,9 +31,6 @@ import ( func (s *AteomHerder) mountExternalVolumes(ctx context.Context, actorUID string, volumes []*ateletpb.Volume) error { for _, vol := range volumes { - if vol.GetType() != ateletpb.VolumeType_VOLUME_TYPE_EXTERNAL { - continue - } ext := vol.GetExternal() if ext == nil { continue @@ -57,9 +54,6 @@ func (s *AteomHerder) mountExternalVolumes(ctx context.Context, actorUID string, func (s *AteomHerder) unmountExternalVolumes(ctx context.Context, actorUID string, volumes []*ateletpb.Volume) error { var errs []error for _, vol := range volumes { - if vol.GetType() != ateletpb.VolumeType_VOLUME_TYPE_EXTERNAL { - continue - } ext := vol.GetExternal() if ext == nil { continue diff --git a/cmd/atelet/volumes_test.go b/cmd/atelet/volumes_test.go index 6d009a53c..588d1f637 100644 --- a/cmd/atelet/volumes_test.go +++ b/cmd/atelet/volumes_test.go @@ -47,7 +47,6 @@ func TestUnmountExternalVolumes(t *testing.T) { extVol1 := &ateletpb.Volume{ Name: "vol-1", - Type: ateletpb.VolumeType_VOLUME_TYPE_EXTERNAL, Source: &ateletpb.Volume_External{ External: &ateletpb.ExternalVolumeSource{ StorageVolumeId: "mock-vol-1", @@ -57,7 +56,6 @@ func TestUnmountExternalVolumes(t *testing.T) { } extVol2 := &ateletpb.Volume{ Name: "vol-2", - Type: ateletpb.VolumeType_VOLUME_TYPE_EXTERNAL, Source: &ateletpb.Volume_External{ External: &ateletpb.ExternalVolumeSource{ StorageVolumeId: "mock-vol-2", @@ -67,7 +65,9 @@ func TestUnmountExternalVolumes(t *testing.T) { } durableVol := &ateletpb.Volume{ Name: "durable-1", - Type: ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR, + Source: &ateletpb.Volume_DurableDir{ + DurableDir: &ateletpb.DurableDirVolume{}, + }, } t.Run("success", func(t *testing.T) { diff --git a/internal/proto/ateletpb/atelet.pb.go b/internal/proto/ateletpb/atelet.pb.go index c6a5b5814..323a9dd43 100644 --- a/internal/proto/ateletpb/atelet.pb.go +++ b/internal/proto/ateletpb/atelet.pb.go @@ -35,55 +35,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type VolumeType int32 - -const ( - VolumeType_VOLUME_TYPE_UNSPECIFIED VolumeType = 0 - VolumeType_VOLUME_TYPE_DURABLE_DIR VolumeType = 1 - VolumeType_VOLUME_TYPE_EXTERNAL VolumeType = 2 -) - -// Enum value maps for VolumeType. -var ( - VolumeType_name = map[int32]string{ - 0: "VOLUME_TYPE_UNSPECIFIED", - 1: "VOLUME_TYPE_DURABLE_DIR", - 2: "VOLUME_TYPE_EXTERNAL", - } - VolumeType_value = map[string]int32{ - "VOLUME_TYPE_UNSPECIFIED": 0, - "VOLUME_TYPE_DURABLE_DIR": 1, - "VOLUME_TYPE_EXTERNAL": 2, - } -) - -func (x VolumeType) Enum() *VolumeType { - p := new(VolumeType) - *p = x - return p -} - -func (x VolumeType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (VolumeType) Descriptor() protoreflect.EnumDescriptor { - return file_atelet_proto_enumTypes[0].Descriptor() -} - -func (VolumeType) Type() protoreflect.EnumType { - return &file_atelet_proto_enumTypes[0] -} - -func (x VolumeType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use VolumeType.Descriptor instead. -func (VolumeType) EnumDescriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{0} -} - type CheckpointType int32 const ( @@ -120,11 +71,11 @@ func (x CheckpointType) String() string { } func (CheckpointType) Descriptor() protoreflect.EnumDescriptor { - return file_atelet_proto_enumTypes[1].Descriptor() + return file_atelet_proto_enumTypes[0].Descriptor() } func (CheckpointType) Type() protoreflect.EnumType { - return &file_atelet_proto_enumTypes[1] + return &file_atelet_proto_enumTypes[0] } func (x CheckpointType) Number() protoreflect.EnumNumber { @@ -133,7 +84,7 @@ func (x CheckpointType) Number() protoreflect.EnumNumber { // Deprecated: Use CheckpointType.Descriptor instead. func (CheckpointType) EnumDescriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{1} + return file_atelet_proto_rawDescGZIP(), []int{0} } type SnapshotScope int32 @@ -184,11 +135,11 @@ func (x SnapshotScope) String() string { } func (SnapshotScope) Descriptor() protoreflect.EnumDescriptor { - return file_atelet_proto_enumTypes[2].Descriptor() + return file_atelet_proto_enumTypes[1].Descriptor() } func (SnapshotScope) Type() protoreflect.EnumType { - return &file_atelet_proto_enumTypes[2] + return &file_atelet_proto_enumTypes[1] } func (x SnapshotScope) Number() protoreflect.EnumNumber { @@ -197,7 +148,7 @@ func (x SnapshotScope) Number() protoreflect.EnumNumber { // Deprecated: Use SnapshotScope.Descriptor instead. func (SnapshotScope) EnumDescriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{2} + return file_atelet_proto_rawDescGZIP(), []int{1} } type MintActorCertificateRequest struct { @@ -783,7 +734,6 @@ func (x *ExternalVolumeSource) GetVolumeContext() map[string]string { type Volume struct { state protoimpl.MessageState `protogen:"open.v1"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Type VolumeType `protobuf:"varint,2,opt,name=type,proto3,enum=atelet.VolumeType" json:"type,omitempty"` // Types that are valid to be assigned to Source: // // *Volume_DurableDir @@ -830,13 +780,6 @@ func (x *Volume) GetName() string { return "" } -func (x *Volume) GetType() VolumeType { - if x != nil { - return x.Type - } - return VolumeType_VOLUME_TYPE_UNSPECIFIED -} - func (x *Volume) GetSource() isVolume_Source { if x != nil { return x.Source @@ -867,11 +810,11 @@ type isVolume_Source interface { } type Volume_DurableDir struct { - DurableDir *DurableDirVolume `protobuf:"bytes,3,opt,name=durable_dir,json=durableDir,proto3,oneof"` + DurableDir *DurableDirVolume `protobuf:"bytes,2,opt,name=durable_dir,json=durableDir,proto3,oneof"` } type Volume_External struct { - External *ExternalVolumeSource `protobuf:"bytes,4,opt,name=external,proto3,oneof"` + External *ExternalVolumeSource `protobuf:"bytes,3,opt,name=external,proto3,oneof"` } func (*Volume_DurableDir) isVolume_Source() {} @@ -1931,13 +1874,12 @@ const file_atelet_proto_rawDesc = "" + "\x0evolume_context\x18\x03 \x03(\v2/.atelet.ExternalVolumeSource.VolumeContextEntryR\rvolumeContext\x1a@\n" + "\x12VolumeContextEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xc7\x01\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x9f\x01\n" + "\x06Volume\x12\x12\n" + - "\x04name\x18\x01 \x01(\tR\x04name\x12&\n" + - "\x04type\x18\x02 \x01(\x0e2\x12.atelet.VolumeTypeR\x04type\x12;\n" + - "\vdurable_dir\x18\x03 \x01(\v2\x18.atelet.DurableDirVolumeH\x00R\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12;\n" + + "\vdurable_dir\x18\x02 \x01(\v2\x18.atelet.DurableDirVolumeH\x00R\n" + "durableDir\x12:\n" + - "\bexternal\x18\x04 \x01(\v2\x1c.atelet.ExternalVolumeSourceH\x00R\bexternalB\b\n" + + "\bexternal\x18\x03 \x01(\v2\x1c.atelet.ExternalVolumeSourceH\x00R\bexternalB\b\n" + "\x06source\"@\n" + "\vVolumeMount\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x1d\n" + @@ -2010,12 +1952,7 @@ const file_atelet_proto_rawDesc = "" + "\x0eegress_gateway\x18\r \x01(\v2\x15.atelet.EgressGatewayH\x01R\regressGateway\x88\x01\x01B\b\n" + "\x06configB\x11\n" + "\x0f_egress_gateway\"\x11\n" + - "\x0fRestoreResponse*`\n" + - "\n" + - "VolumeType\x12\x1b\n" + - "\x17VOLUME_TYPE_UNSPECIFIED\x10\x00\x12\x1b\n" + - "\x17VOLUME_TYPE_DURABLE_DIR\x10\x01\x12\x18\n" + - "\x14VOLUME_TYPE_EXTERNAL\x10\x02*j\n" + + "\x0fRestoreResponse*j\n" + "\x0eCheckpointType\x12\x1f\n" + "\x1bCHECKPOINT_TYPE_UNSPECIFIED\x10\x00\x12\x19\n" + "\x15CHECKPOINT_TYPE_LOCAL\x10\x01\x12\x1c\n" + @@ -2046,86 +1983,84 @@ func file_atelet_proto_rawDescGZIP() []byte { return file_atelet_proto_rawDescData } -var file_atelet_proto_enumTypes = make([]protoimpl.EnumInfo, 3) +var file_atelet_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_atelet_proto_msgTypes = make([]protoimpl.MessageInfo, 28) var file_atelet_proto_goTypes = []any{ - (VolumeType)(0), // 0: atelet.VolumeType - (CheckpointType)(0), // 1: atelet.CheckpointType - (SnapshotScope)(0), // 2: atelet.SnapshotScope - (*MintActorCertificateRequest)(nil), // 3: atelet.MintActorCertificateRequest - (*MintActorCertificateResponse)(nil), // 4: atelet.MintActorCertificateResponse - (*RunRequest)(nil), // 5: atelet.RunRequest - (*EgressGateway)(nil), // 6: atelet.EgressGateway - (*AssetFile)(nil), // 7: atelet.AssetFile - (*ArchAssets)(nil), // 8: atelet.ArchAssets - (*SandboxAssets)(nil), // 9: atelet.SandboxAssets - (*WorkloadSpec)(nil), // 10: atelet.WorkloadSpec - (*DurableDirVolume)(nil), // 11: atelet.DurableDirVolume - (*ExternalVolumeSource)(nil), // 12: atelet.ExternalVolumeSource - (*Volume)(nil), // 13: atelet.Volume - (*VolumeMount)(nil), // 14: atelet.VolumeMount - (*Container)(nil), // 15: atelet.Container - (*EnvEntry)(nil), // 16: atelet.EnvEntry - (*Readyz)(nil), // 17: atelet.Readyz - (*HTTPGetAction)(nil), // 18: atelet.HTTPGetAction - (*RunResponse)(nil), // 19: atelet.RunResponse - (*LocalCheckpointConfiguration)(nil), // 20: atelet.LocalCheckpointConfiguration - (*ExternalCheckpointConfiguration)(nil), // 21: atelet.ExternalCheckpointConfiguration - (*CheckpointRequest)(nil), // 22: atelet.CheckpointRequest - (*CheckpointResponse)(nil), // 23: atelet.CheckpointResponse - (*UploadPausedCheckpointRequest)(nil), // 24: atelet.UploadPausedCheckpointRequest - (*UploadPausedCheckpointResponse)(nil), // 25: atelet.UploadPausedCheckpointResponse - (*RestoreRequest)(nil), // 26: atelet.RestoreRequest - (*RestoreResponse)(nil), // 27: atelet.RestoreResponse - nil, // 28: atelet.ArchAssets.FilesEntry - nil, // 29: atelet.SandboxAssets.AssetsEntry - nil, // 30: atelet.ExternalVolumeSource.VolumeContextEntry + (CheckpointType)(0), // 0: atelet.CheckpointType + (SnapshotScope)(0), // 1: atelet.SnapshotScope + (*MintActorCertificateRequest)(nil), // 2: atelet.MintActorCertificateRequest + (*MintActorCertificateResponse)(nil), // 3: atelet.MintActorCertificateResponse + (*RunRequest)(nil), // 4: atelet.RunRequest + (*EgressGateway)(nil), // 5: atelet.EgressGateway + (*AssetFile)(nil), // 6: atelet.AssetFile + (*ArchAssets)(nil), // 7: atelet.ArchAssets + (*SandboxAssets)(nil), // 8: atelet.SandboxAssets + (*WorkloadSpec)(nil), // 9: atelet.WorkloadSpec + (*DurableDirVolume)(nil), // 10: atelet.DurableDirVolume + (*ExternalVolumeSource)(nil), // 11: atelet.ExternalVolumeSource + (*Volume)(nil), // 12: atelet.Volume + (*VolumeMount)(nil), // 13: atelet.VolumeMount + (*Container)(nil), // 14: atelet.Container + (*EnvEntry)(nil), // 15: atelet.EnvEntry + (*Readyz)(nil), // 16: atelet.Readyz + (*HTTPGetAction)(nil), // 17: atelet.HTTPGetAction + (*RunResponse)(nil), // 18: atelet.RunResponse + (*LocalCheckpointConfiguration)(nil), // 19: atelet.LocalCheckpointConfiguration + (*ExternalCheckpointConfiguration)(nil), // 20: atelet.ExternalCheckpointConfiguration + (*CheckpointRequest)(nil), // 21: atelet.CheckpointRequest + (*CheckpointResponse)(nil), // 22: atelet.CheckpointResponse + (*UploadPausedCheckpointRequest)(nil), // 23: atelet.UploadPausedCheckpointRequest + (*UploadPausedCheckpointResponse)(nil), // 24: atelet.UploadPausedCheckpointResponse + (*RestoreRequest)(nil), // 25: atelet.RestoreRequest + (*RestoreResponse)(nil), // 26: atelet.RestoreResponse + nil, // 27: atelet.ArchAssets.FilesEntry + nil, // 28: atelet.SandboxAssets.AssetsEntry + nil, // 29: atelet.ExternalVolumeSource.VolumeContextEntry } var file_atelet_proto_depIdxs = []int32{ - 10, // 0: atelet.RunRequest.spec:type_name -> atelet.WorkloadSpec - 9, // 1: atelet.RunRequest.sandbox_assets:type_name -> atelet.SandboxAssets - 6, // 2: atelet.RunRequest.egress_gateway:type_name -> atelet.EgressGateway - 28, // 3: atelet.ArchAssets.files:type_name -> atelet.ArchAssets.FilesEntry - 29, // 4: atelet.SandboxAssets.assets:type_name -> atelet.SandboxAssets.AssetsEntry - 15, // 5: atelet.WorkloadSpec.containers:type_name -> atelet.Container - 13, // 6: atelet.WorkloadSpec.volumes:type_name -> atelet.Volume - 30, // 7: atelet.ExternalVolumeSource.volume_context:type_name -> atelet.ExternalVolumeSource.VolumeContextEntry - 0, // 8: atelet.Volume.type:type_name -> atelet.VolumeType - 11, // 9: atelet.Volume.durable_dir:type_name -> atelet.DurableDirVolume - 12, // 10: atelet.Volume.external:type_name -> atelet.ExternalVolumeSource - 16, // 11: atelet.Container.env:type_name -> atelet.EnvEntry - 17, // 12: atelet.Container.readyz:type_name -> atelet.Readyz - 14, // 13: atelet.Container.volume_mounts:type_name -> atelet.VolumeMount - 18, // 14: atelet.Readyz.http_get:type_name -> atelet.HTTPGetAction - 10, // 15: atelet.CheckpointRequest.spec:type_name -> atelet.WorkloadSpec - 1, // 16: atelet.CheckpointRequest.type:type_name -> atelet.CheckpointType - 20, // 17: atelet.CheckpointRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration - 21, // 18: atelet.CheckpointRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration - 2, // 19: atelet.CheckpointRequest.scope:type_name -> atelet.SnapshotScope - 2, // 20: atelet.UploadPausedCheckpointRequest.desired_scope:type_name -> atelet.SnapshotScope - 10, // 21: atelet.RestoreRequest.spec:type_name -> atelet.WorkloadSpec - 1, // 22: atelet.RestoreRequest.type:type_name -> atelet.CheckpointType - 20, // 23: atelet.RestoreRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration - 21, // 24: atelet.RestoreRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration - 2, // 25: atelet.RestoreRequest.scope:type_name -> atelet.SnapshotScope - 6, // 26: atelet.RestoreRequest.egress_gateway:type_name -> atelet.EgressGateway - 7, // 27: atelet.ArchAssets.FilesEntry.value:type_name -> atelet.AssetFile - 8, // 28: atelet.SandboxAssets.AssetsEntry.value:type_name -> atelet.ArchAssets - 3, // 29: atelet.CredentialBroker.MintActorCertificate:input_type -> atelet.MintActorCertificateRequest - 5, // 30: atelet.AteomHerder.Run:input_type -> atelet.RunRequest - 22, // 31: atelet.AteomHerder.Checkpoint:input_type -> atelet.CheckpointRequest - 26, // 32: atelet.AteomHerder.Restore:input_type -> atelet.RestoreRequest - 24, // 33: atelet.AteomHerder.UploadPausedCheckpoint:input_type -> atelet.UploadPausedCheckpointRequest - 4, // 34: atelet.CredentialBroker.MintActorCertificate:output_type -> atelet.MintActorCertificateResponse - 19, // 35: atelet.AteomHerder.Run:output_type -> atelet.RunResponse - 23, // 36: atelet.AteomHerder.Checkpoint:output_type -> atelet.CheckpointResponse - 27, // 37: atelet.AteomHerder.Restore:output_type -> atelet.RestoreResponse - 25, // 38: atelet.AteomHerder.UploadPausedCheckpoint:output_type -> atelet.UploadPausedCheckpointResponse - 34, // [34:39] is the sub-list for method output_type - 29, // [29:34] is the sub-list for method input_type - 29, // [29:29] is the sub-list for extension type_name - 29, // [29:29] is the sub-list for extension extendee - 0, // [0:29] is the sub-list for field type_name + 9, // 0: atelet.RunRequest.spec:type_name -> atelet.WorkloadSpec + 8, // 1: atelet.RunRequest.sandbox_assets:type_name -> atelet.SandboxAssets + 5, // 2: atelet.RunRequest.egress_gateway:type_name -> atelet.EgressGateway + 27, // 3: atelet.ArchAssets.files:type_name -> atelet.ArchAssets.FilesEntry + 28, // 4: atelet.SandboxAssets.assets:type_name -> atelet.SandboxAssets.AssetsEntry + 14, // 5: atelet.WorkloadSpec.containers:type_name -> atelet.Container + 12, // 6: atelet.WorkloadSpec.volumes:type_name -> atelet.Volume + 29, // 7: atelet.ExternalVolumeSource.volume_context:type_name -> atelet.ExternalVolumeSource.VolumeContextEntry + 10, // 8: atelet.Volume.durable_dir:type_name -> atelet.DurableDirVolume + 11, // 9: atelet.Volume.external:type_name -> atelet.ExternalVolumeSource + 15, // 10: atelet.Container.env:type_name -> atelet.EnvEntry + 16, // 11: atelet.Container.readyz:type_name -> atelet.Readyz + 13, // 12: atelet.Container.volume_mounts:type_name -> atelet.VolumeMount + 17, // 13: atelet.Readyz.http_get:type_name -> atelet.HTTPGetAction + 9, // 14: atelet.CheckpointRequest.spec:type_name -> atelet.WorkloadSpec + 0, // 15: atelet.CheckpointRequest.type:type_name -> atelet.CheckpointType + 19, // 16: atelet.CheckpointRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration + 20, // 17: atelet.CheckpointRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration + 1, // 18: atelet.CheckpointRequest.scope:type_name -> atelet.SnapshotScope + 1, // 19: atelet.UploadPausedCheckpointRequest.desired_scope:type_name -> atelet.SnapshotScope + 9, // 20: atelet.RestoreRequest.spec:type_name -> atelet.WorkloadSpec + 0, // 21: atelet.RestoreRequest.type:type_name -> atelet.CheckpointType + 19, // 22: atelet.RestoreRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration + 20, // 23: atelet.RestoreRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration + 1, // 24: atelet.RestoreRequest.scope:type_name -> atelet.SnapshotScope + 5, // 25: atelet.RestoreRequest.egress_gateway:type_name -> atelet.EgressGateway + 6, // 26: atelet.ArchAssets.FilesEntry.value:type_name -> atelet.AssetFile + 7, // 27: atelet.SandboxAssets.AssetsEntry.value:type_name -> atelet.ArchAssets + 2, // 28: atelet.CredentialBroker.MintActorCertificate:input_type -> atelet.MintActorCertificateRequest + 4, // 29: atelet.AteomHerder.Run:input_type -> atelet.RunRequest + 21, // 30: atelet.AteomHerder.Checkpoint:input_type -> atelet.CheckpointRequest + 25, // 31: atelet.AteomHerder.Restore:input_type -> atelet.RestoreRequest + 23, // 32: atelet.AteomHerder.UploadPausedCheckpoint:input_type -> atelet.UploadPausedCheckpointRequest + 3, // 33: atelet.CredentialBroker.MintActorCertificate:output_type -> atelet.MintActorCertificateResponse + 18, // 34: atelet.AteomHerder.Run:output_type -> atelet.RunResponse + 22, // 35: atelet.AteomHerder.Checkpoint:output_type -> atelet.CheckpointResponse + 26, // 36: atelet.AteomHerder.Restore:output_type -> atelet.RestoreResponse + 24, // 37: atelet.AteomHerder.UploadPausedCheckpoint:output_type -> atelet.UploadPausedCheckpointResponse + 33, // [33:38] is the sub-list for method output_type + 28, // [28:33] is the sub-list for method input_type + 28, // [28:28] is the sub-list for extension type_name + 28, // [28:28] is the sub-list for extension extendee + 0, // [0:28] is the sub-list for field type_name } func init() { file_atelet_proto_init() } @@ -2151,7 +2086,7 @@ func file_atelet_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_atelet_proto_rawDesc), len(file_atelet_proto_rawDesc)), - NumEnums: 3, + NumEnums: 2, NumMessages: 28, NumExtensions: 0, NumServices: 2, diff --git a/internal/proto/ateletpb/atelet.proto b/internal/proto/ateletpb/atelet.proto index 92263d230..5281d0495 100644 --- a/internal/proto/ateletpb/atelet.proto +++ b/internal/proto/ateletpb/atelet.proto @@ -126,12 +126,6 @@ message WorkloadSpec { reserved "pause_image"; // moved to SandboxAssets } -enum VolumeType { - VOLUME_TYPE_UNSPECIFIED = 0; - VOLUME_TYPE_DURABLE_DIR = 1; - VOLUME_TYPE_EXTERNAL = 2; -} - message DurableDirVolume { } @@ -144,11 +138,9 @@ message ExternalVolumeSource { message Volume { string name = 1; - VolumeType type = 2; - oneof source { - DurableDirVolume durable_dir = 3; - ExternalVolumeSource external = 4; + DurableDirVolume durable_dir = 2; + ExternalVolumeSource external = 3; } } From fc43b9d85fc4f00318f99de6d67b03e27f4d6167 Mon Sep 17 00:00:00 2001 From: Taahir Ahmed Date: Thu, 9 Jul 2026 14:50:22 -0700 Subject: [PATCH 2/7] System Information Volumes: Part 1 (Actor Identity) This commit defines a new volume type, SystemInfoVolume, that will serve a similar purpose as Projected volumes in Kubernetes. It will support writing information from multiple sources to automatically-updating files in the Actor's filesystem. For a first pass, I have converted the existing hardcoded Actor ID file to be one of the available information sources in a SystemInfoVolume. Further work will add Actor Identity JWTs and Actor Identity certificates. --- .../internal/controlapi/workload_spec.go | 33 +- .../third_party/atomicwriter/atomic_writer.go | 496 ++++++++ .../atomicwriter/atomic_writer_linux.go | 27 + .../atomicwriter/atomic_writer_test.go | 1104 +++++++++++++++++ .../atomicwriter/atomic_writer_unsupported.go | 32 + cmd/atelet/main.go | 69 +- cmd/atelet/oci.go | 55 +- cmd/atelet/oci_test.go | 46 +- docs/api-guide.md | 28 +- internal/ateompath/ateompath.go | 32 +- internal/proto/ateletpb/atelet.pb.go | 414 +++++-- internal/proto/ateletpb/atelet.proto | 20 + .../generated/ate.dev_actortemplates.yaml | 44 +- pkg/api/v1alpha1/actortemplate_types.go | 39 +- .../v1alpha1/actortemplate_validation_test.go | 6 +- pkg/api/v1alpha1/zz_generated.deepcopy.go | 62 + 16 files changed, 2283 insertions(+), 224 deletions(-) create mode 100644 cmd/atelet/internal/third_party/atomicwriter/atomic_writer.go create mode 100644 cmd/atelet/internal/third_party/atomicwriter/atomic_writer_linux.go create mode 100644 cmd/atelet/internal/third_party/atomicwriter/atomic_writer_test.go create mode 100644 cmd/atelet/internal/third_party/atomicwriter/atomic_writer_unsupported.go diff --git a/cmd/ateapi/internal/controlapi/workload_spec.go b/cmd/ateapi/internal/controlapi/workload_spec.go index e94e9875d..d75402bf2 100644 --- a/cmd/ateapi/internal/controlapi/workload_spec.go +++ b/cmd/ateapi/internal/controlapi/workload_spec.go @@ -27,16 +27,43 @@ import ( func workloadSpecFromActorTemplate(actorTemplate *atev1alpha1.ActorTemplate, actor *ateapipb.Actor) (*ateletpb.WorkloadSpec, error) { workloadSpec := &ateletpb.WorkloadSpec{} - // add volumes + // Convert volumes to atelet's representation. ActorTemplate validation has + // already ensured that only one source is set. for _, vol := range actorTemplate.Spec.Volumes { - // volume is durable-dir type - if vol.VolumeSource.DurableDir != nil { + switch { + case vol.VolumeSource.DurableDir != nil: workloadSpec.Volumes = append(workloadSpec.Volumes, &ateletpb.Volume{ Name: vol.Name, Source: &ateletpb.Volume_DurableDir{ DurableDir: &ateletpb.DurableDirVolume{}, }, }) + + case vol.VolumeSource.SystemInfo != nil: + ateletSystemInfo := &ateletpb.SystemInfoVolume{} + for _, dataSource := range vol.VolumeSource.SystemInfo.DataSources { + switch { + case dataSource.ActorIdentity != nil: + ateletSystemInfo.DataSources = append(ateletSystemInfo.DataSources, &ateletpb.SystemInfoDataSource{ + DataSource: &ateletpb.SystemInfoDataSource_ActorIdentity{ + ActorIdentity: &ateletpb.ActorIdentityDataSource{ + Path: dataSource.ActorIdentity.Path, + }, + }, + }) + default: + continue // Drop unrecognized data sources + } + } + workloadSpec.Volumes = append(workloadSpec.Volumes, &ateletpb.Volume{ + Name: vol.Name, + Source: &ateletpb.Volume_SystemInfo{ + SystemInfo: ateletSystemInfo, + }, + }) + + default: + continue // Drop unrecognized volumes. } } diff --git a/cmd/atelet/internal/third_party/atomicwriter/atomic_writer.go b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer.go new file mode 100644 index 000000000..d2f3a6e0b --- /dev/null +++ b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer.go @@ -0,0 +1,496 @@ +/* +Copyright 2016 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package atomicwriter + +import ( + "bytes" + "context" + "fmt" + "log/slog" + "os" + "path" + "path/filepath" + "runtime" + "strings" + "time" + + "k8s.io/apimachinery/pkg/util/sets" +) + +const ( + maxFileNameLength = 255 + maxPathLength = 4096 +) + +// AtomicWriter handles atomically projecting content for a set of files into +// a target directory. +// +// Note: +// +// 1. AtomicWriter reserves the set of pathnames starting with `..`. +// 2. AtomicWriter offers no concurrency guarantees and must be synchronized +// by the caller. +// +// The visible files in this volume are symlinks to files in the writer's data +// directory. Actual files are stored in a hidden timestamped directory which +// is symlinked to by the data directory. The timestamped directory and +// data directory symlink are created in the writer's target dir.  This scheme +// allows the files to be atomically updated by changing the target of the +// data directory symlink. +// +// Consumers of the target directory can monitor the ..data symlink using +// inotify or fanotify to receive events when the content in the volume is +// updated. +type AtomicWriter struct { + targetDir string +} + +// FileProjection contains file Data and access Mode +type FileProjection struct { + Data []byte + Mode int32 + FsUser *int64 +} + +// NewAtomicWriter creates a new AtomicWriter configured to write to the given +// target directory, or returns an error if the target directory does not exist. +func NewAtomicWriter(targetDir string) (*AtomicWriter, error) { + _, err := os.Stat(targetDir) + if os.IsNotExist(err) { + return nil, err + } + + return &AtomicWriter{targetDir: targetDir}, nil +} + +const ( + dataDirName = "..data" + newDataDirName = "..data_tmp" +) + +// Write does an atomic projection of the given payload into the writer's target +// directory. Input paths must not begin with '..'. +// setPerms is an optional pointer to a function that caller can provide to set the +// permissions of the newly created files before they are published. The function is +// passed subPath which is the name of the timestamped directory that was created +// under target directory. +// +// The Write algorithm is: +// +// 1. The payload is validated; if the payload is invalid, the function returns +// +// 2. The current timestamped directory is detected by reading the data directory +// symlink +// +// 3. The old version of the volume is walked to determine whether any +// portion of the payload was deleted and is still present on disk. +// +// 4. The data in the current timestamped directory is compared to the projected +// data to determine if an update to data directory is required. +// +// 5. A new timestamped dir is created if an update is required. +// +// 6. The payload is written to the new timestamped directory. +// +// 7. Permissions are set (if setPerms is not nil) on the new timestamped directory and files. +// +// 8. A symlink to the new timestamped directory ..data_tmp is created that will +// become the new data directory. +// +// 9. The new data directory symlink is renamed to the data directory; rename is atomic. +// +// 10. Symlinks and directory for new user-visible files are created (if needed). +// +// For example, consider the files: +// /podName +// /user/labels +// /k8s/annotations +// +// The user visible files are symbolic links into the internal data directory: +// /podName -> ..data/podName +// /usr -> ..data/usr +// /k8s -> ..data/k8s +// +// The data directory itself is a link to a timestamped directory with +// the real data: +// /..data -> ..2016_02_01_15_04_05.12345678/ +// NOTE(claudiub): We need to create these symlinks AFTER we've finished creating and +// linking everything else. On Windows, if a target does not exist, the created symlink +// will not work properly if the target ends up being a directory. +// +// 11. Old paths are removed from the user-visible portion of the target directory. +// +// 12. The previous timestamped directory is removed, if it exists. +func (w *AtomicWriter) Write(ctx context.Context, payload map[string]FileProjection, setPerms func(subPath string) error) error { + // (1) + cleanPayload, err := validatePayload(payload) + if err != nil { + return fmt.Errorf("while validating payload: %w", err) + } + + // (2) + dataDirPath := filepath.Join(w.targetDir, dataDirName) + oldTsDir, err := os.Readlink(dataDirPath) + if err != nil { + if !os.IsNotExist(err) { + return fmt.Errorf("while reading link for data directory: %w", err) + } + // although Readlink() returns "" on err, don't be fragile by relying on it (since it's not specified in docs) + // empty oldTsDir indicates that it didn't exist + oldTsDir = "" + } + oldTsPath := filepath.Join(w.targetDir, oldTsDir) + + var pathsToRemove sets.Set[string] + shouldWrite := true + // if there was no old version, there's nothing to remove + if len(oldTsDir) != 0 { + // (3) + pathsToRemove, err = w.pathsToRemove(ctx, cleanPayload, oldTsPath) + if err != nil { + return fmt.Errorf("while determining user-visible files to remove: %w", err) + } + + // (4) + if should, err := shouldWritePayload(cleanPayload, oldTsPath); err != nil { + return fmt.Errorf("while determining whether payload should be written to disk: %w", err) + } else if !should && len(pathsToRemove) == 0 { + slog.InfoContext(ctx, "write not required for data directory", slog.String("dir", oldTsDir)) + // data directory is already up to date, but we need to make sure that + // the user-visible symlinks are created. + // See https://github.com/kubernetes/kubernetes/issues/121472 for more details. + // Reset oldTsDir to empty string to avoid removing the data directory. + shouldWrite = false + oldTsDir = "" + } else { + slog.InfoContext(ctx, "write required for target directory", slog.String("dir", w.targetDir)) + } + } + + if shouldWrite { + // (5) + tsDir, err := w.newTimestampDir() + if err != nil { + return fmt.Errorf("while creating new ts data directory: %w", err) + } + tsDirName := filepath.Base(tsDir) + + // (6) + if err = w.writePayloadToDir(cleanPayload, tsDir); err != nil { + return fmt.Errorf("while writing payload to ts data directory %s: %w", tsDir, err) + } + + slog.InfoContext(ctx, "performed write of new data to ts data directory", slog.String("dir", tsDir)) + + // (7) + if setPerms != nil { + if err := setPerms(tsDirName); err != nil { + return fmt.Errorf("while applying ownership settings: %w", err) + } + } + + // (8) + newDataDirPath := filepath.Join(w.targetDir, newDataDirName) + if err = os.Symlink(tsDirName, newDataDirPath); err != nil { + if err := os.RemoveAll(tsDir); err != nil { + return fmt.Errorf("while removing new ts directory %s: %w", tsDir, err) + } + } + + // (9) + if runtime.GOOS == "windows" { + if err := os.Remove(dataDirPath); err != nil { + slog.ErrorContext(ctx, "Error removing data dir directory", slog.Any("err", err), slog.String("dir", dataDirPath)) + } + err = os.Symlink(tsDirName, dataDirPath) + if err := os.Remove(newDataDirPath); err != nil { + slog.ErrorContext(ctx, "Error removing new data dir directory", slog.Any("err", err), slog.String("dir", newDataDirPath)) + } + } else { + err = os.Rename(newDataDirPath, dataDirPath) + } + if err != nil { + if err := os.Remove(newDataDirPath); err != nil && err != os.ErrNotExist { + slog.ErrorContext(ctx, "Error removing new data dir directory", slog.Any("err", err), slog.String("dir", newDataDirPath)) + } + if err := os.RemoveAll(tsDir); err != nil { + slog.ErrorContext(ctx, "Error removing new ts directory", slog.Any("err", err), slog.String("dir", tsDir)) + } + return fmt.Errorf("while renaming symbolic link for data directory: %s: %w", newDataDirPath, err) + } + } + + // (10) + if err = w.createUserVisibleFiles(cleanPayload); err != nil { + return fmt.Errorf("while creating visible symlinks in %s: %w", w.targetDir, err) + } + + // (11) + if err = w.removeUserVisiblePaths(ctx, pathsToRemove); err != nil { + return fmt.Errorf("while removing old visible symlinks: %w", err) + } + + // (12) + if len(oldTsDir) > 0 { + if err = os.RemoveAll(oldTsPath); err != nil { + return fmt.Errorf("while removing old data directory %s: %w", oldTsDir, err) + } + } + + return nil +} + +// validatePayload returns an error if any path in the payload returns a copy of the payload with the paths cleaned. +func validatePayload(payload map[string]FileProjection) (map[string]FileProjection, error) { + cleanPayload := make(map[string]FileProjection) + for k, content := range payload { + if err := validatePath(k); err != nil { + return nil, err + } + + cleanPayload[filepath.Clean(k)] = content + } + + return cleanPayload, nil +} + +// validatePath validates a single path, returning an error if the path is +// invalid. paths may not: +// +// 1. be absolute +// 2. contain '..' as an element +// 3. start with '..' +// 4. contain filenames larger than 255 characters +// 5. be longer than 4096 characters +func validatePath(targetPath string) error { + // TODO: somehow unify this with the similar api validation, + // validateVolumeSourcePath; the error semantics are just different enough + // from this that it was time-prohibitive trying to find the right + // refactoring to re-use. + if targetPath == "" { + return fmt.Errorf("invalid path: must not be empty: %q", targetPath) + } + if path.IsAbs(targetPath) { + return fmt.Errorf("invalid path: must be relative path: %s", targetPath) + } + + if len(targetPath) > maxPathLength { + return fmt.Errorf("invalid path: must be less than or equal to %d characters", maxPathLength) + } + + items := strings.Split(targetPath, string(os.PathSeparator)) + for _, item := range items { + if item == ".." { + return fmt.Errorf("invalid path: must not contain '..': %s", targetPath) + } + if len(item) > maxFileNameLength { + return fmt.Errorf("invalid path: filenames must be less than or equal to %d characters", maxFileNameLength) + } + } + if strings.HasPrefix(items[0], "..") && len(items[0]) > 2 { + return fmt.Errorf("invalid path: must not start with '..': %s", targetPath) + } + + return nil +} + +// shouldWritePayload returns whether the payload should be written to disk. +func shouldWritePayload(payload map[string]FileProjection, oldTsDir string) (bool, error) { + for userVisiblePath, fileProjection := range payload { + shouldWrite, err := shouldWriteFile(filepath.Join(oldTsDir, userVisiblePath), fileProjection.Data) + if err != nil { + return false, err + } + + if shouldWrite { + return true, nil + } + } + + return false, nil +} + +// shouldWriteFile returns whether a new version of a file should be written to disk. +func shouldWriteFile(path string, content []byte) (bool, error) { + _, err := os.Lstat(path) + if os.IsNotExist(err) { + return true, nil + } + + contentOnFs, err := os.ReadFile(path) + if err != nil { + return false, err + } + + return !bytes.Equal(content, contentOnFs), nil +} + +// pathsToRemove walks the current version of the data directory and +// determines which paths should be removed (if any) after the payload is +// written to the target directory. +func (w *AtomicWriter) pathsToRemove(ctx context.Context, payload map[string]FileProjection, oldTSDir string) (sets.Set[string], error) { + paths := sets.New[string]() + visitor := func(path string, info os.FileInfo, err error) error { + relativePath := strings.TrimPrefix(path, oldTSDir) + relativePath = strings.TrimPrefix(relativePath, string(os.PathSeparator)) + if relativePath == "" { + return nil + } + + paths.Insert(relativePath) + return nil + } + + err := filepath.Walk(oldTSDir, visitor) + if os.IsNotExist(err) { + return nil, nil + } else if err != nil { + return nil, err + } + + slog.DebugContext(ctx, "current paths", slog.String("targetDir", w.targetDir), slog.Any("paths", sets.List(paths))) + + newPaths := sets.New[string]() + for file := range payload { + // add all subpaths for the payload to the set of new paths + // to avoid attempting to remove non-empty dirs + for subPath := file; subPath != ""; { + newPaths.Insert(subPath) + subPath, _ = filepath.Split(subPath) + subPath = strings.TrimSuffix(subPath, string(os.PathSeparator)) + } + } + slog.DebugContext(ctx, "new paths", slog.String("targetDir", w.targetDir), slog.Any("paths", sets.List(newPaths))) + + result := paths.Difference(newPaths) + slog.DebugContext(ctx, "paths to remove", slog.String("targetDir", w.targetDir), slog.Any("paths", result)) + + return result, nil +} + +// newTimestampDir creates a new timestamp directory +func (w *AtomicWriter) newTimestampDir() (string, error) { + tsDir, err := os.MkdirTemp(w.targetDir, time.Now().UTC().Format("..2006_01_02_15_04_05.")) + if err != nil { + return "", fmt.Errorf("while creating new temp directory: %w", err) + } + + // 0755 permissions are needed to allow 'group' and 'other' to recurse the + // directory tree. do a chmod here to ensure that permissions are set correctly + // regardless of the process' umask. + err = os.Chmod(tsDir, 0755) + if err != nil { + return "", fmt.Errorf("while setting mode on new temp directory: %w", err) + } + + return tsDir, nil +} + +// writePayloadToDir writes the given payload to the given directory. The +// directory must exist. +func (w *AtomicWriter) writePayloadToDir(payload map[string]FileProjection, dir string) error { + for userVisiblePath, fileProjection := range payload { + content := fileProjection.Data + mode := os.FileMode(fileProjection.Mode) + fullPath := filepath.Join(dir, userVisiblePath) + baseDir, _ := filepath.Split(fullPath) + + if err := os.MkdirAll(baseDir, os.ModePerm); err != nil { + return fmt.Errorf("while creating directory %s: %w", baseDir, err) + } + + if err := os.WriteFile(fullPath, content, mode); err != nil { + return fmt.Errorf("while writing file %s with mode %v: %w", fullPath, mode, err) + } + // Chmod is needed because os.WriteFile() ends up calling + // open(2) to create the file, so the final mode used is "mode & + // ~umask". But we want to make sure the specified mode is used + // in the file no matter what the umask is. + if err := os.Chmod(fullPath, mode); err != nil { + return fmt.Errorf("while changing file %s with mode %v: %w", fullPath, mode, err) + } + + if fileProjection.FsUser == nil { + continue + } + + if err := w.lchown(fullPath, int(*fileProjection.FsUser), -1); err != nil { + return fmt.Errorf("while changing file %s to owner %v: %w", fullPath, int(*fileProjection.FsUser), err) + } + } + + return nil +} + +// createUserVisibleFiles creates the relative symlinks for all the +// files configured in the payload. If the directory in a file path does not +// exist, it is created. +// +// Viz: +// For files: "bar", "foo/bar", "baz/bar", "foo/baz/blah" +// the following symlinks are created: +// bar -> ..data/bar +// foo -> ..data/foo +// baz -> ..data/baz +func (w *AtomicWriter) createUserVisibleFiles(payload map[string]FileProjection) error { + for userVisiblePath, fileProjection := range payload { + slashpos := strings.Index(userVisiblePath, string(os.PathSeparator)) + if slashpos == -1 { + slashpos = len(userVisiblePath) + } + linkname := userVisiblePath[:slashpos] + _, err := os.Readlink(filepath.Join(w.targetDir, linkname)) + if err != nil && os.IsNotExist(err) { + // The link into the data directory for this path doesn't exist; create it + visibleFile := filepath.Join(w.targetDir, linkname) + dataDirFile := filepath.Join(dataDirName, linkname) + + err = os.Symlink(dataDirFile, visibleFile) + if err != nil { + return err + } + + if fileProjection.FsUser == nil { + continue + } + + if err := w.lchown(visibleFile, int(*fileProjection.FsUser), -1); err != nil { + return fmt.Errorf("while changing file %s to owner %v: %w", visibleFile, int(*fileProjection.FsUser), err) + } + } + } + return nil +} + +// removeUserVisiblePaths removes the set of paths from the user-visible +// portion of the writer's target directory. +func (w *AtomicWriter) removeUserVisiblePaths(ctx context.Context, paths sets.Set[string]) error { + ps := string(os.PathSeparator) + var lasterr error + for p := range paths { + // only remove symlinks from the volume root directory (i.e. items that don't contain '/') + if strings.Contains(p, ps) { + continue + } + if err := os.Remove(filepath.Join(w.targetDir, p)); err != nil { + slog.ErrorContext(ctx, "Error pruning old user-visible path", slog.String("path", p), slog.Any("err", err)) + lasterr = err + } + } + + return lasterr +} diff --git a/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_linux.go b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_linux.go new file mode 100644 index 000000000..1d5f7d34e --- /dev/null +++ b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_linux.go @@ -0,0 +1,27 @@ +//go:build linux + +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package atomicwriter + +import "os" + +// lchown changes the numeric uid and gid of the named file. +// If the file is a symbolic link, it changes the uid and gid of the link itself. +func (w *AtomicWriter) lchown(name string, uid, gid int) error { + return os.Lchown(name, uid, gid) +} diff --git a/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_test.go b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_test.go new file mode 100644 index 000000000..09d9e5232 --- /dev/null +++ b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_test.go @@ -0,0 +1,1104 @@ +//go:build linux + +/* +Copyright 2016 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package atomicwriter + +import ( + "encoding/base64" + "fmt" + "os" + "path/filepath" + "reflect" + "strings" + "testing" + + "k8s.io/apimachinery/pkg/util/sets" +) + +// mkTmpdir creates a temporary directory based upon the prefix passed in. +// If successful, it returns the temporary directory path. The directory can be +// deleted with a call to "os.RemoveAll(...)". +// In case of error, it'll return an empty string and the error. +func mkTmpdir(prefix string) (string, error) { + tmpDir, err := os.MkdirTemp(os.TempDir(), prefix) + if err != nil { + return "", err + } + return tmpDir, nil +} + +func TestNewAtomicWriter(t *testing.T) { + targetDir, err := mkTmpdir("atomic-write") + if err != nil { + t.Fatalf("unexpected error creating tmp dir: %v", err) + } + defer os.RemoveAll(targetDir) + + _, err = NewAtomicWriter(targetDir) + if err != nil { + t.Fatalf("unexpected error creating writer for existing target dir: %v", err) + } + + nonExistentDir, err := mkTmpdir("atomic-write") + if err != nil { + t.Fatalf("unexpected error creating tmp dir: %v", err) + } + err = os.Remove(nonExistentDir) + if err != nil { + t.Fatalf("unexpected error ensuring dir %v does not exist: %v", nonExistentDir, err) + } + + _, err = NewAtomicWriter(nonExistentDir) + if err == nil { + t.Fatalf("unexpected success creating writer for nonexistent target dir: %v", err) + } +} + +func TestValidatePath(t *testing.T) { + maxPath := strings.Repeat("a", maxPathLength+1) + maxFile := strings.Repeat("a", maxFileNameLength+1) + + cases := []struct { + name string + path string + valid bool + }{ + { + name: "valid 1", + path: "i/am/well/behaved.txt", + valid: true, + }, + { + name: "valid 2", + path: "keepyourheaddownandfollowtherules.txt", + valid: true, + }, + { + name: "max path length", + path: maxPath, + valid: false, + }, + { + name: "max file length", + path: maxFile, + valid: false, + }, + { + name: "absolute failure", + path: "/dev/null", + valid: false, + }, + { + name: "reserved path", + path: "..sneaky.txt", + valid: false, + }, + { + name: "contains doubledot 1", + path: "hello/there/../../../../../../etc/passwd", + valid: false, + }, + { + name: "contains doubledot 2", + path: "hello/../etc/somethingbad", + valid: false, + }, + { + name: "empty", + path: "", + valid: false, + }, + } + + for _, tc := range cases { + err := validatePath(tc.path) + if tc.valid && err != nil { + t.Errorf("%v: unexpected failure: %v", tc.name, err) + continue + } + + if !tc.valid && err == nil { + t.Errorf("%v: unexpected success", tc.name) + } + } +} + +func TestPathsToRemove(t *testing.T) { + cases := []struct { + name string + payload1 map[string]FileProjection + payload2 map[string]FileProjection + expected sets.Set[string] + }{ + { + name: "simple", + payload1: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + "bar.txt": {Mode: 0644, Data: []byte("bar")}, + }, + payload2: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + }, + expected: sets.New[string]("bar.txt"), + }, + { + name: "simple 2", + payload1: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + "zip/bar.txt": {Mode: 0644, Data: []byte("zip/b}ar")}, + }, + payload2: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + }, + expected: sets.New[string]("zip/bar.txt", "zip"), + }, + { + name: "subdirs 1", + payload1: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + "zip/zap/bar.txt": {Mode: 0644, Data: []byte("zip/bar")}, + }, + payload2: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + }, + expected: sets.New[string]("zip/zap/bar.txt", "zip", "zip/zap"), + }, + { + name: "subdirs 2", + payload1: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + "zip/1/2/3/4/bar.txt": {Mode: 0644, Data: []byte("zip/b}ar")}, + }, + payload2: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + }, + expected: sets.New[string]("zip/1/2/3/4/bar.txt", "zip", "zip/1", "zip/1/2", "zip/1/2/3", "zip/1/2/3/4"), + }, + { + name: "subdirs 3", + payload1: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + "zip/1/2/3/4/bar.txt": {Mode: 0644, Data: []byte("zip/b}ar")}, + "zap/a/b/c/bar.txt": {Mode: 0644, Data: []byte("zap/bar")}, + }, + payload2: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + }, + expected: sets.New[string]("zip/1/2/3/4/bar.txt", "zip", "zip/1", "zip/1/2", "zip/1/2/3", "zip/1/2/3/4", "zap", "zap/a", "zap/a/b", "zap/a/b/c", "zap/a/b/c/bar.txt"), + }, + { + name: "subdirs 4", + payload1: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + "zap/1/2/3/4/bar.txt": {Mode: 0644, Data: []byte("zip/bar")}, + "zap/1/2/c/bar.txt": {Mode: 0644, Data: []byte("zap/bar")}, + "zap/1/2/magic.txt": {Mode: 0644, Data: []byte("indigo")}, + }, + payload2: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + "zap/1/2/magic.txt": {Mode: 0644, Data: []byte("indigo")}, + }, + expected: sets.New[string]("zap/1/2/3/4/bar.txt", "zap/1/2/3", "zap/1/2/3/4", "zap/1/2/3/4/bar.txt", "zap/1/2/c", "zap/1/2/c/bar.txt"), + }, + { + name: "subdirs 5", + payload1: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + "zap/1/2/3/4/bar.txt": {Mode: 0644, Data: []byte("zip/bar")}, + "zap/1/2/c/bar.txt": {Mode: 0644, Data: []byte("zap/bar")}, + }, + payload2: map[string]FileProjection{ + "foo.txt": {Mode: 0644, Data: []byte("foo")}, + "zap/1/2/magic.txt": {Mode: 0644, Data: []byte("indigo")}, + }, + expected: sets.New[string]("zap/1/2/3/4/bar.txt", "zap/1/2/3", "zap/1/2/3/4", "zap/1/2/3/4/bar.txt", "zap/1/2/c", "zap/1/2/c/bar.txt"), + }, + } + + for _, tc := range cases { + targetDir, err := mkTmpdir("atomic-write") + if err != nil { + t.Errorf("%v: unexpected error creating tmp dir: %v", tc.name, err) + continue + } + defer os.RemoveAll(targetDir) + + writer := &AtomicWriter{targetDir: targetDir} + err = writer.Write(t.Context(), tc.payload1, nil) + if err != nil { + t.Errorf("%v: unexpected error writing: %v", tc.name, err) + continue + } + + dataDirPath := filepath.Join(targetDir, dataDirName) + oldTsDir, err := os.Readlink(dataDirPath) + if err != nil && os.IsNotExist(err) { + t.Errorf("Data symlink does not exist: %v", dataDirPath) + continue + } else if err != nil { + t.Errorf("Unable to read symlink %v: %v", dataDirPath, err) + continue + } + + actual, err := writer.pathsToRemove(t.Context(), tc.payload2, filepath.Join(targetDir, oldTsDir)) + if err != nil { + t.Errorf("%v: unexpected error determining paths to remove: %v", tc.name, err) + continue + } + + if e, a := tc.expected, actual; !e.Equal(a) { + t.Errorf("%v: unexpected paths to remove:\nexpected: %v\n got: %v", tc.name, e, a) + } + } +} + +func TestWriteOnce(t *testing.T) { + // $1 if you can tell me what this binary is + encodedMysteryBinary := `f0VMRgIBAQAAAAAAAAAAAAIAPgABAAAAeABAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAOAAB +AAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAfQAAAAAAAAB9AAAAAAAAAAAA +IAAAAAAAsDyZDwU=` + + mysteryBinaryBytes := make([]byte, base64.StdEncoding.DecodedLen(len(encodedMysteryBinary))) + numBytes, err := base64.StdEncoding.Decode(mysteryBinaryBytes, []byte(encodedMysteryBinary)) + if err != nil { + t.Fatalf("Unexpected error decoding binary payload: %v", err) + } + + if numBytes != 125 { + t.Fatalf("Unexpected decoded binary size: expected 125, got %v", numBytes) + } + + cases := []struct { + name string + payload map[string]FileProjection + success bool + }{ + { + name: "invalid payload 1", + payload: map[string]FileProjection{ + "foo": {Mode: 0644, Data: []byte("foo")}, + "..bar": {Mode: 0644, Data: []byte("bar")}, + "binary.bin": {Mode: 0644, Data: mysteryBinaryBytes}, + }, + success: false, + }, + { + name: "invalid payload 2", + payload: map[string]FileProjection{ + "foo/../bar": {Mode: 0644, Data: []byte("foo")}, + }, + success: false, + }, + { + name: "basic 1", + payload: map[string]FileProjection{ + "foo": {Mode: 0644, Data: []byte("foo")}, + "bar": {Mode: 0644, Data: []byte("bar")}, + }, + success: true, + }, + { + name: "basic 2", + payload: map[string]FileProjection{ + "binary.bin": {Mode: 0644, Data: mysteryBinaryBytes}, + ".binary.bin": {Mode: 0644, Data: mysteryBinaryBytes}, + }, + success: true, + }, + { + name: "basic mode 1", + payload: map[string]FileProjection{ + "foo": {Mode: 0777, Data: []byte("foo")}, + "bar": {Mode: 0400, Data: []byte("bar")}, + }, + success: true, + }, + { + name: "dotfiles", + payload: map[string]FileProjection{ + "foo": {Mode: 0644, Data: []byte("foo")}, + "bar": {Mode: 0644, Data: []byte("bar")}, + ".dotfile": {Mode: 0644, Data: []byte("dotfile")}, + ".dotfile.file": {Mode: 0644, Data: []byte("dotfile.file")}, + }, + success: true, + }, + { + name: "dotfiles mode", + payload: map[string]FileProjection{ + "foo": {Mode: 0407, Data: []byte("foo")}, + "bar": {Mode: 0440, Data: []byte("bar")}, + ".dotfile": {Mode: 0777, Data: []byte("dotfile")}, + ".dotfile.file": {Mode: 0666, Data: []byte("dotfile.file")}, + }, + success: true, + }, + { + name: "subdirectories 1", + payload: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt")}, + }, + success: true, + }, + { + name: "subdirectories mode 1", + payload: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0400, Data: []byte("foo/bar")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt")}, + }, + success: true, + }, + { + name: "subdirectories 2", + payload: map[string]FileProjection{ + "foo//bar.txt": {Mode: 0644, Data: []byte("foo//bar")}, + "bar///bar/zab.txt": {Mode: 0644, Data: []byte("bar/../bar/zab.txt")}, + }, + success: true, + }, + { + name: "subdirectories 3", + payload: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt")}, + "foo/blaz/bar.txt": {Mode: 0644, Data: []byte("foo/blaz/bar")}, + "bar/zib/zab.txt": {Mode: 0644, Data: []byte("bar/zib/zab.txt")}, + }, + success: true, + }, + { + name: "kitchen sink", + payload: map[string]FileProjection{ + "foo.log": {Mode: 0644, Data: []byte("foo")}, + "bar.zap": {Mode: 0644, Data: []byte("bar")}, + ".dotfile": {Mode: 0644, Data: []byte("dotfile")}, + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt")}, + "foo/blaz/bar.txt": {Mode: 0644, Data: []byte("foo/blaz/bar")}, + "bar/zib/zab.txt": {Mode: 0400, Data: []byte("bar/zib/zab.txt")}, + "1/2/3/4/5/6/7/8/9/10/.dotfile.lib": {Mode: 0777, Data: []byte("1-2-3-dotfile")}, + }, + success: true, + }, + } + + for _, tc := range cases { + targetDir, err := mkTmpdir("atomic-write") + if err != nil { + t.Errorf("%v: unexpected error creating tmp dir: %v", tc.name, err) + continue + } + defer os.RemoveAll(targetDir) + + writer := &AtomicWriter{targetDir: targetDir} + err = writer.Write(t.Context(), tc.payload, nil) + if err != nil && tc.success { + t.Errorf("%v: unexpected error writing payload: %v", tc.name, err) + continue + } else if err == nil && !tc.success { + t.Errorf("%v: unexpected success", tc.name) + continue + } else if err != nil { + continue + } + + checkVolumeContents(targetDir, tc.name, tc.payload, t) + } +} + +func TestUpdate(t *testing.T) { + cases := []struct { + name string + first map[string]FileProjection + next map[string]FileProjection + shouldWrite bool + }{ + { + name: "update", + first: map[string]FileProjection{ + "foo": {Mode: 0644, Data: []byte("foo")}, + "bar": {Mode: 0644, Data: []byte("bar")}, + }, + next: map[string]FileProjection{ + "foo": {Mode: 0644, Data: []byte("foo2")}, + "bar": {Mode: 0640, Data: []byte("bar2")}, + }, + shouldWrite: true, + }, + { + name: "no update", + first: map[string]FileProjection{ + "foo": {Mode: 0644, Data: []byte("foo")}, + "bar": {Mode: 0644, Data: []byte("bar")}, + }, + next: map[string]FileProjection{ + "foo": {Mode: 0644, Data: []byte("foo")}, + "bar": {Mode: 0644, Data: []byte("bar")}, + }, + shouldWrite: false, + }, + { + name: "no update 2", + first: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar")}, + }, + next: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar")}, + }, + shouldWrite: false, + }, + { + name: "add 1", + first: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar")}, + }, + next: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar")}, + "blu/zip.txt": {Mode: 0644, Data: []byte("zip")}, + }, + shouldWrite: true, + }, + { + name: "add 2", + first: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar")}, + }, + next: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar")}, + "blu/two/2/3/4/5/zip.txt": {Mode: 0644, Data: []byte("zip")}, + }, + shouldWrite: true, + }, + { + name: "add 3", + first: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar")}, + }, + next: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar")}, + "bar/2/3/4/5/zip.txt": {Mode: 0644, Data: []byte("zip")}, + }, + shouldWrite: true, + }, + { + name: "delete 1", + first: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar")}, + }, + next: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + }, + shouldWrite: true, + }, + { + name: "delete 2", + first: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/1/2/3/zab.txt": {Mode: 0644, Data: []byte("bar")}, + }, + next: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + }, + shouldWrite: true, + }, + { + name: "delete 3", + first: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/1/2/sip.txt": {Mode: 0644, Data: []byte("sip")}, + "bar/1/2/3/zab.txt": {Mode: 0644, Data: []byte("bar")}, + }, + next: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/1/2/sip.txt": {Mode: 0644, Data: []byte("sip")}, + }, + shouldWrite: true, + }, + { + name: "delete 4", + first: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/1/2/sip.txt": {Mode: 0644, Data: []byte("sip")}, + "bar/1/2/3/4/5/6zab.txt": {Mode: 0644, Data: []byte("bar")}, + }, + next: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/1/2/sip.txt": {Mode: 0644, Data: []byte("sip")}, + }, + shouldWrite: true, + }, + { + name: "delete all", + first: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/1/2/sip.txt": {Mode: 0644, Data: []byte("sip")}, + "bar/1/2/3/4/5/6zab.txt": {Mode: 0644, Data: []byte("bar")}, + }, + next: map[string]FileProjection{}, + shouldWrite: true, + }, + { + name: "add and delete 1", + first: map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + }, + next: map[string]FileProjection{ + "bar/baz.txt": {Mode: 0644, Data: []byte("baz")}, + }, + shouldWrite: true, + }, + } + + for _, tc := range cases { + targetDir, err := mkTmpdir("atomic-write") + if err != nil { + t.Errorf("%v: unexpected error creating tmp dir: %v", tc.name, err) + continue + } + defer os.RemoveAll(targetDir) + + writer := &AtomicWriter{targetDir: targetDir} + + err = writer.Write(t.Context(), tc.first, nil) + if err != nil { + t.Errorf("%v: unexpected error writing: %v", tc.name, err) + continue + } + + checkVolumeContents(targetDir, tc.name, tc.first, t) + if !tc.shouldWrite { + continue + } + + err = writer.Write(t.Context(), tc.next, nil) + if err != nil { + if tc.shouldWrite { + t.Errorf("%v: unexpected error writing: %v", tc.name, err) + continue + } + } else if !tc.shouldWrite { + t.Errorf("%v: unexpected success", tc.name) + continue + } + + checkVolumeContents(targetDir, tc.name, tc.next, t) + } +} + +func TestMultipleUpdates(t *testing.T) { + cases := []struct { + name string + payloads []map[string]FileProjection + }{ + { + name: "update 1", + payloads: []map[string]FileProjection{ + { + "foo": {Mode: 0644, Data: []byte("foo")}, + "bar": {Mode: 0644, Data: []byte("bar")}, + }, + { + "foo": {Mode: 0400, Data: []byte("foo2")}, + "bar": {Mode: 0400, Data: []byte("bar2")}, + }, + { + "foo": {Mode: 0600, Data: []byte("foo3")}, + "bar": {Mode: 0600, Data: []byte("bar3")}, + }, + }, + }, + { + name: "update 2", + payloads: []map[string]FileProjection{ + { + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt")}, + }, + { + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar2")}, + "bar/zab.txt": {Mode: 0400, Data: []byte("bar/zab.txt2")}, + }, + }, + }, + { + name: "clear sentinel", + payloads: []map[string]FileProjection{ + { + "foo": {Mode: 0644, Data: []byte("foo")}, + "bar": {Mode: 0644, Data: []byte("bar")}, + }, + { + "foo": {Mode: 0644, Data: []byte("foo2")}, + "bar": {Mode: 0644, Data: []byte("bar2")}, + }, + { + "foo": {Mode: 0644, Data: []byte("foo3")}, + "bar": {Mode: 0644, Data: []byte("bar3")}, + }, + { + "foo": {Mode: 0644, Data: []byte("foo4")}, + "bar": {Mode: 0644, Data: []byte("bar4")}, + }, + }, + }, + { + name: "subdirectories 2", + payloads: []map[string]FileProjection{ + { + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt")}, + "foo/blaz/bar.txt": {Mode: 0644, Data: []byte("foo/blaz/bar")}, + "bar/zib/zab.txt": {Mode: 0644, Data: []byte("bar/zib/zab.txt")}, + }, + { + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar2")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt2")}, + "foo/blaz/bar.txt": {Mode: 0644, Data: []byte("foo/blaz/bar2")}, + "bar/zib/zab.txt": {Mode: 0644, Data: []byte("bar/zib/zab.txt2")}, + }, + }, + }, + { + name: "add 1", + payloads: []map[string]FileProjection{ + { + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar")}, + "bar//zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt")}, + "foo/blaz/bar.txt": {Mode: 0644, Data: []byte("foo/blaz/bar")}, + "bar/zib////zib/zab.txt": {Mode: 0644, Data: []byte("bar/zib/zab.txt")}, + }, + { + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar2")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt2")}, + "foo/blaz/bar.txt": {Mode: 0644, Data: []byte("foo/blaz/bar2")}, + "bar/zib/zab.txt": {Mode: 0644, Data: []byte("bar/zib/zab.txt2")}, + "add/new/keys.txt": {Mode: 0644, Data: []byte("addNewKeys")}, + }, + }, + }, + { + name: "add 2", + payloads: []map[string]FileProjection{ + { + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar2")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt2")}, + "foo/blaz/bar.txt": {Mode: 0644, Data: []byte("foo/blaz/bar2")}, + "bar/zib/zab.txt": {Mode: 0644, Data: []byte("bar/zib/zab.txt2")}, + "add/new/keys.txt": {Mode: 0644, Data: []byte("addNewKeys")}, + }, + { + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar2")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt2")}, + "foo/blaz/bar.txt": {Mode: 0644, Data: []byte("foo/blaz/bar2")}, + "bar/zib/zab.txt": {Mode: 0644, Data: []byte("bar/zib/zab.txt2")}, + "add/new/keys.txt": {Mode: 0644, Data: []byte("addNewKeys")}, + "add/new/keys2.txt": {Mode: 0644, Data: []byte("addNewKeys2")}, + "add/new/keys3.txt": {Mode: 0644, Data: []byte("addNewKeys3")}, + }, + }, + }, + { + name: "remove 1", + payloads: []map[string]FileProjection{ + { + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar")}, + "bar//zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt")}, + "foo/blaz/bar.txt": {Mode: 0644, Data: []byte("foo/blaz/bar")}, + "zip/zap/zup/fop.txt": {Mode: 0644, Data: []byte("zip/zap/zup/fop.txt")}, + }, + { + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar2")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar/zab.txt2")}, + }, + { + "foo/bar.txt": {Mode: 0644, Data: []byte("foo/bar")}, + }, + }, + }, + } + + for _, tc := range cases { + targetDir, err := mkTmpdir("atomic-write") + if err != nil { + t.Errorf("%v: unexpected error creating tmp dir: %v", tc.name, err) + continue + } + defer os.RemoveAll(targetDir) + + writer := &AtomicWriter{targetDir: targetDir} + + for _, payload := range tc.payloads { + writer.Write(t.Context(), payload, nil) + + checkVolumeContents(targetDir, tc.name, payload, t) + } + } +} + +func checkVolumeContents(targetDir, tcName string, payload map[string]FileProjection, t *testing.T) { + dataDirPath := filepath.Join(targetDir, dataDirName) + // use filepath.Walk to reconstruct the payload, then deep equal + observedPayload := make(map[string]FileProjection) + visitor := func(path string, info os.FileInfo, _ error) error { + if info.IsDir() { + return nil + } + + relativePath := strings.TrimPrefix(path, dataDirPath) + relativePath = strings.TrimPrefix(relativePath, "/") + if strings.HasPrefix(relativePath, "..") { + return nil + } + + content, err := os.ReadFile(path) + if err != nil { + return err + } + fileInfo, err := os.Stat(path) + if err != nil { + return err + } + mode := int32(fileInfo.Mode()) + + observedPayload[relativePath] = FileProjection{Data: content, Mode: mode} + + return nil + } + + d, err := os.ReadDir(targetDir) + if err != nil { + t.Errorf("Unable to read dir %v: %v", targetDir, err) + return + } + for _, info := range d { + if strings.HasPrefix(info.Name(), "..") { + continue + } + if info.Type()&os.ModeSymlink != 0 { + p := filepath.Join(targetDir, info.Name()) + actual, err := os.Readlink(p) + if err != nil { + t.Errorf("Unable to read symlink %v: %v", p, err) + continue + } + if err := filepath.Walk(filepath.Join(targetDir, actual), visitor); err != nil { + t.Errorf("%v: unexpected error walking directory: %v", tcName, err) + } + } + } + + cleanPathPayload := make(map[string]FileProjection, len(payload)) + for k, v := range payload { + cleanPathPayload[filepath.Clean(k)] = v + } + + if !reflect.DeepEqual(cleanPathPayload, observedPayload) { + t.Errorf("%v: payload and observed payload do not match.", tcName) + } +} + +func TestValidatePayload(t *testing.T) { + maxPath := strings.Repeat("a", maxPathLength+1) + + cases := []struct { + name string + payload map[string]FileProjection + expected sets.Set[string] + valid bool + }{ + { + name: "valid payload", + payload: map[string]FileProjection{ + "foo": {}, + "bar": {}, + }, + valid: true, + expected: sets.New[string]("foo", "bar"), + }, + { + name: "payload with path length > 4096 is invalid", + payload: map[string]FileProjection{ + maxPath: {}, + }, + valid: false, + }, + { + name: "payload with absolute path is invalid", + payload: map[string]FileProjection{ + "/dev/null": {}, + }, + valid: false, + }, + { + name: "payload with reserved path is invalid", + payload: map[string]FileProjection{ + "..sneaky.txt": {}, + }, + valid: false, + }, + { + name: "payload with doubledot path is invalid", + payload: map[string]FileProjection{ + "foo/../etc/password": {}, + }, + valid: false, + }, + { + name: "payload with empty path is invalid", + payload: map[string]FileProjection{ + "": {}, + }, + valid: false, + }, + { + name: "payload with unclean path should be cleaned", + payload: map[string]FileProjection{ + "foo////bar": {}, + }, + valid: true, + expected: sets.New[string]("foo/bar"), + }, + } + getPayloadPaths := func(payload map[string]FileProjection) sets.Set[string] { + paths := sets.New[string]() + for path := range payload { + paths.Insert(path) + } + return paths + } + + for _, tc := range cases { + real, err := validatePayload(tc.payload) + if !tc.valid && err == nil { + t.Errorf("%v: unexpected success", tc.name) + } + + if tc.valid { + if err != nil { + t.Errorf("%v: unexpected failure: %v", tc.name, err) + continue + } + + realPaths := getPayloadPaths(real) + if !realPaths.Equal(tc.expected) { + t.Errorf("%v: unexpected payload paths: %v is not equal to %v", tc.name, realPaths, tc.expected) + } + } + + } +} + +func TestCreateUserVisibleFiles(t *testing.T) { + cases := []struct { + name string + payload map[string]FileProjection + expected map[string]string + }{ + { + name: "simple path", + payload: map[string]FileProjection{ + "foo": {}, + "bar": {}, + }, + expected: map[string]string{ + "foo": "..data/foo", + "bar": "..data/bar", + }, + }, + { + name: "simple nested path", + payload: map[string]FileProjection{ + "foo/bar": {}, + "foo/bar/txt": {}, + "bar/txt": {}, + }, + expected: map[string]string{ + "foo": "..data/foo", + "bar": "..data/bar", + }, + }, + { + name: "unclean nested path", + payload: map[string]FileProjection{ + "./bar": {}, + "foo///bar": {}, + }, + expected: map[string]string{ + "bar": "..data/bar", + "foo": "..data/foo", + }, + }, + } + + for _, tc := range cases { + targetDir, err := mkTmpdir("atomic-write") + if err != nil { + t.Errorf("%v: unexpected error creating tmp dir: %v", tc.name, err) + continue + } + defer os.RemoveAll(targetDir) + + dataDirPath := filepath.Join(targetDir, dataDirName) + err = os.MkdirAll(dataDirPath, 0755) + if err != nil { + t.Fatalf("%v: unexpected error creating data path: %v", tc.name, err) + } + + writer := &AtomicWriter{targetDir: targetDir} + payload, err := validatePayload(tc.payload) + if err != nil { + t.Fatalf("%v: unexpected error validating payload: %v", tc.name, err) + } + err = writer.createUserVisibleFiles(payload) + if err != nil { + t.Fatalf("%v: unexpected error creating visible files: %v", tc.name, err) + } + + for subpath, expectedDest := range tc.expected { + visiblePath := filepath.Join(targetDir, subpath) + destination, err := os.Readlink(visiblePath) + if err != nil && os.IsNotExist(err) { + t.Fatalf("%v: visible symlink does not exist: %v", tc.name, visiblePath) + } else if err != nil { + t.Fatalf("%v: unable to read symlink %v: %v", tc.name, dataDirPath, err) + } + + if expectedDest != destination { + t.Fatalf("%v: symlink destination %q not same with expected data dir %q", tc.name, destination, expectedDest) + } + } + } +} + +func TestSetPerms(t *testing.T) { + targetDir, err := mkTmpdir("atomic-write") + if err != nil { + t.Fatalf("unexpected error creating tmp dir: %v", err) + } + defer os.RemoveAll(targetDir) + + // Test that setPerms() is called once and with valid timestamp directory. + payload1 := map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar")}, + } + + var setPermsCalled int + writer := &AtomicWriter{targetDir: targetDir} + err = writer.Write(t.Context(), payload1, func(subPath string) error { + fileInfo, err := os.Stat(filepath.Join(targetDir, subPath)) + if err != nil { + t.Fatalf("unexpected error getting file info: %v", err) + } + // Ensure that given timestamp directory really exists. + if !fileInfo.IsDir() { + t.Fatalf("subPath is not a directory: %v", subPath) + } + setPermsCalled++ + return nil + }) + if err != nil { + t.Fatalf("unexpected error writing: %v", err) + } + if setPermsCalled != 1 { + t.Fatalf("unexpected number of calls to setPerms: %v", setPermsCalled) + } + + // Test that errors from setPerms() are propagated. + payload2 := map[string]FileProjection{ + "foo/bar.txt": {Mode: 0644, Data: []byte("foo2")}, + "bar/zab.txt": {Mode: 0644, Data: []byte("bar2")}, + } + + err = writer.Write(t.Context(), payload2, func(_ string) error { + return fmt.Errorf("error in setPerms") + }) + if err == nil { + t.Fatalf("expected error while writing but got nil") + } + if !strings.Contains(err.Error(), "error in setPerms") { + t.Fatalf("unexpected error while writing: %v", err) + } +} + +func TestWriteAgainAfterUnexpectedExit(t *testing.T) { + testCases := []struct { + name string + payload map[string]FileProjection + simulateFn func(targetDir string, payload map[string]FileProjection) error + }{ + { + name: "process killed before creating user visible files", + payload: map[string]FileProjection{ + "foo": {Mode: 0644, Data: []byte("foo")}, + "bar": {Mode: 0644, Data: []byte("bar")}, + }, + simulateFn: func(targetDir string, payload map[string]FileProjection) error { + for filename := range payload { + path := filepath.Join(targetDir, filename) + if err := os.RemoveAll(path); err != nil { + return err + } + } + return nil + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + targetDir, err := mkTmpdir("atomic-write") + if err != nil { + t.Fatalf("unexpected error creating tmp dir: %v", err) + } + defer func() { + err := os.RemoveAll(targetDir) + if err != nil { + t.Errorf("%v: unexpected error removing tmp dir: %v", tc.name, err) + } + }() + + writer := &AtomicWriter{targetDir: targetDir} + err = writer.Write(t.Context(), tc.payload, nil) + if err != nil { + t.Fatalf("unexpected error writing payload: %v", err) + } + + err = tc.simulateFn(targetDir, tc.payload) + if err != nil { + t.Fatalf("failed to simulate the unexpected exit: %v", err) + } + + err = writer.Write(t.Context(), tc.payload, nil) + if err != nil { + t.Fatalf("unexpected error writing payload again: %v", err) + } + checkVolumeContents(targetDir, tc.name, tc.payload, t) + }) + } +} diff --git a/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_unsupported.go b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_unsupported.go new file mode 100644 index 000000000..2de802794 --- /dev/null +++ b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_unsupported.go @@ -0,0 +1,32 @@ +//go:build !linux + +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package atomicwriter + +import ( + "log/slog" + "runtime" +) + +// lchown changes the numeric uid and gid of the named file. +// If the file is a symbolic link, it changes the uid and gid of the link itself. +// This is a no-op on unsupported platforms. +func (w *AtomicWriter) lchown(name string, uid, _ /* gid */ int) error { + slog.Warn("skipping change of Linux owner; unsupported on this platform", slog.Int("uid", uid), slog.String("name", name), slog.String("goos", runtime.GOOS)) + return nil +} diff --git a/cmd/atelet/main.go b/cmd/atelet/main.go index e513ff161..859dcc3bc 100644 --- a/cmd/atelet/main.go +++ b/cmd/atelet/main.go @@ -36,6 +36,7 @@ import ( "cloud.google.com/go/storage" "github.com/agent-substrate/substrate/cmd/atelet/internal/ategcs" + "github.com/agent-substrate/substrate/cmd/atelet/internal/third_party/atomicwriter" "github.com/agent-substrate/substrate/internal/ateapiauth" "github.com/agent-substrate/substrate/internal/ateattr" "github.com/agent-substrate/substrate/internal/ateerrors" @@ -1361,23 +1362,43 @@ func (s *AteomHerder) prepareOCIBundles( pauseImage string, targetAteomUid string, ) error { - // Populate the per-actor identity directory that gets bind-mounted into - // the application containers. Regenerated on every resume, so it carries - // the correct per-actor name even when restoring from the golden snapshot. - identityDir := ateompath.ActorIdentityDirPath(actorUID) - if err := os.MkdirAll(identityDir, 0o755); err != nil { - return fmt.Errorf("while creating actor identity dir: %w", err) - } - if err := writeFileAtomic(filepath.Join(identityDir, ActorIDFileName), []byte(actorName), 0o644); err != nil { - return fmt.Errorf("while writing actor identity file: %w", err) - } - // make directories for all durable-dir volumes + // Prepare host folders for volume types that need them. for _, vol := range spec.GetVolumes() { - if vol.GetDurableDir() != nil { + switch volSrc := vol.GetSource().(type) { + case *ateletpb.Volume_DurableDir: volPath := ateompath.DurableDirVolumeMountPoint(actorUID, vol.GetName()) if err := os.MkdirAll(volPath, 0o700); err != nil { return fmt.Errorf("while creating %q: %w", volPath, err) } + + case *ateletpb.Volume_SystemInfo: + // Populated on every Run/Restore, so the contents carry the + // correct per-actor values even when restoring from the golden + // snapshot. + volRootHostPath := ateompath.SystemInfoVolumeRoot(actorUID, vol.GetName()) + if err := os.MkdirAll(volRootHostPath, 0o755); err != nil { + return fmt.Errorf("while creating %q: %w", volRootHostPath, err) + } + + aw, err := atomicwriter.NewAtomicWriter(volRootHostPath) + if err != nil { + return fmt.Errorf("while creating atomicwriter: %w", err) + } + + contents := map[string]atomicwriter.FileProjection{} + for _, dataSourceAny := range volSrc.SystemInfo.GetDataSources() { + switch dataSource := dataSourceAny.GetDataSource().(type) { + case *ateletpb.SystemInfoDataSource_ActorIdentity: + contents[dataSource.ActorIdentity.GetPath()] = atomicwriter.FileProjection{ + Data: []byte(actorName), + Mode: 0o644, + } + } + } + + if err := aw.Write(ctx, contents, nil); err != nil { + return fmt.Errorf("while writing contents of SystemInfoVolume: %w", err) + } } } @@ -1410,8 +1431,7 @@ func (s *AteomHerder) prepareOCIBundles( nil, annotations, ateompath.AteomNetNSPath(targetAteomUid), - "", // pause is sandbox infra; it gets no actor identity mount. - nil, + nil, // pause is sandbox infra; it mounts no volumes. nil, ); err != nil { return wrapFileSystemErr("while creating pause OCI bundle", err) @@ -1442,7 +1462,6 @@ func (s *AteomHerder) prepareOCIBundles( "io.kubernetes.cri.container-name": ctr.GetName(), }, ateompath.AteomNetNSPath(targetAteomUid), - identityDir, spec.GetVolumes(), ctr.GetVolumeMounts(), ); err != nil { @@ -1820,16 +1839,6 @@ func resetActorDirs(actorUID string) error { return wrapFileSystemErr("while creating restore-state dir: %w", err) } - // World-readable (0o755): bind-mounted into the actor, whose workload - // reads it through the gofer. - identityDir := ateompath.ActorIdentityDirPath(actorUID) - if err := os.RemoveAll(identityDir); err != nil { - return wrapFileSystemErr("while deleting actor identity dir: %w", err) - } - if err := os.MkdirAll(identityDir, 0o755); err != nil { - return wrapFileSystemErr("while creating actor identity dir: %w", err) - } - durableDirVolumesMountDir := ateompath.DurableDirVolumeMountsDir(actorUID) if err := os.RemoveAll(durableDirVolumesMountDir); err != nil { return wrapFileSystemErr("while deleting durable-dir volumes mount dir: %w", err) @@ -1838,6 +1847,16 @@ func resetActorDirs(actorUID string) error { return wrapFileSystemErr("while creating durable-dir volumes mount dir: %w", err) } + // World-readable (0o755): bind-mounted read-only into the actor, whose + // workload reads it through the gofer. + systemInfoVolumeRootsDir := ateompath.SystemInfoVolumeRootsDir(actorUID) + if err := os.RemoveAll(systemInfoVolumeRootsDir); err != nil { + return wrapFileSystemErr("while deleting system-info volume roots dir: %w", err) + } + if err := os.MkdirAll(systemInfoVolumeRootsDir, 0o755); err != nil { + return wrapFileSystemErr("while creating system-info volume roots dir: %w", err) + } + // Do not call RemoveAll on volume directories in case the unmount failed. // We do not want to delete mount content. volumesDir := ateompath.VolumesDir(actorUID) diff --git a/cmd/atelet/oci.go b/cmd/atelet/oci.go index 74fb8f93a..94a4274ea 100644 --- a/cmd/atelet/oci.go +++ b/cmd/atelet/oci.go @@ -25,32 +25,14 @@ import ( "github.com/agent-substrate/substrate/internal/ateerrors" "github.com/agent-substrate/substrate/internal/ateompath" "github.com/agent-substrate/substrate/internal/imagecache" + "github.com/agent-substrate/substrate/internal/proto/ateletpb" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/opencontainers/runtime-spec/specs-go" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" - - "github.com/agent-substrate/substrate/internal/proto/ateletpb" -) - -const ( - // IdentityMountPath is the in-actor directory at which atelet bind-mounts - // the actor's identity data. Workloads read the files inside it (at - // request time, not cached at startup) to learn about themselves. It is - // delivered as a per-actor bind mount rather than environment variables - // because env lives in the checkpointed process memory and would be - // frozen at the golden snapshot's values after a restore; a bind mount is - // re-attached per-actor on every resume. A directory (rather than a - // single-file mount) so further identity data can be added without - // changing the mount shape. - IdentityMountPath = "/run/ate" - - // ActorIDFileName is the file inside IdentityMountPath holding the - // actor's own ID, raw with no trailing newline. - ActorIDFileName = "actor-id" ) -func prepareOCIDirectory(ctx context.Context, imageCache *imagecache.Store, actorUID, containerName, ref string, command, args []string, env []string, annotations map[string]string, netns string, identityDir string, volumes []*ateletpb.Volume, volumeMounts []*ateletpb.VolumeMount) error { +func prepareOCIDirectory(ctx context.Context, imageCache *imagecache.Store, actorUID, containerName, ref string, command, args []string, env []string, annotations map[string]string, netns string, volumes []*ateletpb.Volume, volumeMounts []*ateletpb.VolumeMount) error { tracer := otel.Tracer("prepareOCIDirectory") ctx, span := tracer.Start(ctx, "prepareOCIDirectory") @@ -90,14 +72,10 @@ func prepareOCIDirectory(ctx context.Context, imageCache *imagecache.Store, acto } resolvedEnv := resolveActorEnv(&img.Config, env) - // The identity bind target must exist in the rootfs for the mount to - // attach; ateom creates it through the mounted overlay (it lands in the - // actor's upper) so the workload can read its own name at - // IdentityMountPath/ActorIDFileName. + // Every bind target must exist in the rootfs for the mount to attach; + // ateom creates them through the mounted overlay (they land in the + // actor's upper). var extraDirs []string - if identityDir != "" { - extraDirs = append(extraDirs, IdentityMountPath) - } for _, vm := range volumeMounts { extraDirs = append(extraDirs, vm.GetMountPath()) } @@ -109,7 +87,7 @@ func prepareOCIDirectory(ctx context.Context, imageCache *imagecache.Store, acto return fmt.Errorf("while writing overlay spec: %w", err) } - ociSpec := buildActorOCISpec(actorUID, resolvedArgs, resolvedEnv, annotations, netns, identityDir, volumes, volumeMounts) + ociSpec := buildActorOCISpec(actorUID, resolvedArgs, resolvedEnv, annotations, netns, volumes, volumeMounts) ociSpecBytes, err := json.MarshalIndent(ociSpec, "", " ") if err != nil { return fmt.Errorf("while marshaling OCI spec: %w", err) @@ -183,10 +161,7 @@ func resolveProcessArgs(imageCfg *v1.Config, command, args []string) ([]string, // buildActorOCISpec assembles the OCI runtime spec for an actor container from // already-resolved args and env (see resolveProcessArgs and resolveActorEnv). -// When identityDir is non-empty it adds a read-only bind mount of that host -// directory at IdentityMountPath so the actor can read its own ID (see -// IdentityMountPath for why this is a bind mount rather than env vars). -func buildActorOCISpec(actorUID string, args []string, env []string, annotations map[string]string, netns string, identityDir string, volumes []*ateletpb.Volume, volumeMounts []*ateletpb.VolumeMount) *specs.Spec { +func buildActorOCISpec(actorUID string, args []string, env []string, annotations map[string]string, netns string, volumes []*ateletpb.Volume, volumeMounts []*ateletpb.VolumeMount) *specs.Spec { mounts := []specs.Mount{ { Destination: "/proc", @@ -216,14 +191,6 @@ func buildActorOCISpec(actorUID string, args []string, env []string, annotations Options: []string{"ro"}, }, } - if identityDir != "" { - mounts = append(mounts, specs.Mount{ - Destination: IdentityMountPath, - Type: "bind", - Source: identityDir, - Options: []string{"ro"}, - }) - } spec := &specs.Spec{ Process: &specs.Process{ @@ -302,11 +269,17 @@ func buildActorOCISpec(actorUID string, args []string, env []string, annotations for _, vm := range volumeMounts { var srcPath string + options := []string{"bind", "rw"} switch volumesByName[vm.GetName()].GetSource().(type) { case *ateletpb.Volume_DurableDir: srcPath = ateompath.DurableDirVolumeMountPoint(actorUID, vm.GetName()) case *ateletpb.Volume_External: srcPath = ateompath.VolumeHostPath(actorUID, vm.GetName()) + case *ateletpb.Volume_SystemInfo: + // System-info contents are generated by atelet; the workload only + // reads them. + srcPath = ateompath.SystemInfoVolumeRoot(actorUID, vm.GetName()) + options = []string{"bind", "ro"} default: continue } @@ -314,7 +287,7 @@ func buildActorOCISpec(actorUID string, args []string, env []string, annotations Destination: vm.GetMountPath(), Type: "bind", Source: srcPath, - Options: []string{"bind", "rw"}, + Options: options, }) } diff --git a/cmd/atelet/oci_test.go b/cmd/atelet/oci_test.go index 1f492092a..64d7aedc5 100644 --- a/cmd/atelet/oci_test.go +++ b/cmd/atelet/oci_test.go @@ -25,36 +25,47 @@ import ( v1 "github.com/google/go-containerregistry/pkg/v1" ) -// With an identity dir, a read-only bind mount appears at IdentityMountPath. -func TestBuildActorOCISpec_IdentityMount(t *testing.T) { +// Each system-info volume mount becomes a read-only bind mount whose source +// is the per-actor on-host SystemInfoVolumeRoot for that volume name. It is +// delivered as a bind mount rather than environment variables because env +// lives in the checkpointed process memory and would be frozen at the golden +// snapshot's values after a restore; a bind mount is re-attached per-actor on +// every resume. +func TestBuildActorOCISpec_SystemInfoVolumeMounts(t *testing.T) { + const actorUID = "actor_uid" + volumeMounts := []*ateletpb.VolumeMount{ + {Name: "sysinfo", MountPath: "/run/ate"}, + } + volumes := []*ateletpb.Volume{ + {Name: "sysinfo", Source: &ateletpb.Volume_SystemInfo{SystemInfo: &ateletpb.SystemInfoVolume{}}}, + } spec := buildActorOCISpec( - "actor_uid", + actorUID, []string{"/app"}, []string{"FOO=bar"}, map[string]string{"k": "v"}, "/run/netns/x", - "/host/actors/actor_uid/identity", - nil, - nil, + volumes, + volumeMounts, ) found := false for _, m := range spec.Mounts { - if m.Destination != IdentityMountPath { + if m.Destination != "/run/ate" { continue } found = true - if m.Source != "/host/actors/actor_uid/identity" { - t.Errorf("identity mount source = %q, want the per-actor identity dir", m.Source) + if want := ateompath.SystemInfoVolumeRoot(actorUID, "sysinfo"); m.Source != want { + t.Errorf("system-info mount source = %q, want %q", m.Source, want) } if m.Type != "bind" { - t.Errorf("identity mount type = %q, want bind", m.Type) + t.Errorf("system-info mount type = %q, want bind", m.Type) } if !slices.Contains(m.Options, "ro") { - t.Errorf("identity mount must be read-only, options=%v", m.Options) + t.Errorf("system-info mount must be read-only, options=%v", m.Options) } } if !found { - t.Fatalf("identity mount %q missing; mounts=%v", IdentityMountPath, spec.Mounts) + t.Fatalf("system-info mount %q missing; mounts=%v", "/run/ate", spec.Mounts) } } @@ -192,16 +203,6 @@ func TestResolveProcessArgs(t *testing.T) { } } -// Without an identity dir (the pause container), no identity mount appears. -func TestBuildActorOCISpec_NoIdentityMountForPause(t *testing.T) { - bare := buildActorOCISpec("actor_uid", []string{"/pause"}, nil, nil, "/run/netns/x", "", nil, nil) - for _, m := range bare.Mounts { - if m.Destination == IdentityMountPath { - t.Errorf("identity mount must be absent when identityDir is empty") - } - } -} - // Each durable-dir volume mount becomes a bind mount whose source is the // per-actor on-host DurableDirVolumeMountPoint for that volume name. func TestBuildActorOCISpec_DurableDirVolumeMounts(t *testing.T) { @@ -218,7 +219,6 @@ func TestBuildActorOCISpec_DurableDirVolumeMounts(t *testing.T) { actorUID, []string{"/app"}, nil, nil, "/run/netns/x", - "", volumes, durableDirs, ) diff --git a/docs/api-guide.md b/docs/api-guide.md index e0d8f5f9f..2ee9839cf 100644 --- a/docs/api-guide.md +++ b/docs/api-guide.md @@ -157,10 +157,32 @@ Substrate uses a **Uniform DNS Mesh**: every actor created from a template is au **Format:** `..actors.resources.substrate.ate.dev` -### Actor Identity -Substrate bind-mounts a read-only, per-actor identity directory at **`/run/ate`** into each of the actor's containers. An actor can learn its own name without parsing the `Host` header by reading the file **`/run/ate/actor-id`** inside it, which contains the raw actor name with no trailing newline. Further identity and configuration data may appear in this directory over time. +### SystemInfo Volumes -Read it fresh rather than caching it at process start. It is delivered as a per-actor bind mount, not an environment variable, precisely so it carries the correct name after a resume from the golden snapshot — an env var (or a file baked into the image) would be frozen at the *golden* actor's name, since it lives in the checkpointed process memory, and would therefore be identical for every actor of the template. +To deliver identity information, including credentials, to a running actor, you can use a SystemInfo volume. Define it in `spec.volumes`, and mount it into each container that needs it. + +Available information sources: + +#### ActorIdentity +The ActorIdentity data source places a file that contains the actor's name (raw, with no trailing newline) at a configurable relative path in the volume. + +```yaml +spec: + volumes: + - name: system-info + systemInfo: + dataSources: + - actorIdentity: + path: actor-id + containers: + - name: main + # ... + volumeMounts: + - name: system-info + mountPath: /run/ate # the actor reads /run/ate/actor-id +``` + +Read it fresh rather than caching it at process start. It is delivered as a file on a read-only per-actor bind mount, not an environment variable, precisely so it carries the correct name after a resume from the golden snapshot — an env var (or a file baked into the image) would be frozen at the *golden* actor's name, since it lives in the checkpointed process memory, and would therefore be identical for every actor of the template. ### Container Fields diff --git a/internal/ateompath/ateompath.go b/internal/ateompath/ateompath.go index 5c47c2d49..45e0560c7 100644 --- a/internal/ateompath/ateompath.go +++ b/internal/ateompath/ateompath.go @@ -91,18 +91,6 @@ func ActorPath(actorUID string) string { ) } -// ActorIdentityDirPath is the host directory atelet populates with the -// actor's identity data (currently the single file "actor-id") and -// bind-mounts read-only into the actor. It is per-actor and regenerated on -// every resume, so (unlike the checkpointed process environment) it reflects -// the correct ID after a restore from the golden snapshot. -func ActorIdentityDirPath(actorUID string) string { - return filepath.Join( - ActorPath(actorUID), - "identity", - ) -} - // ActorSandboxAssetsFile is the per-actor file where atelet records the sandbox // binaries (class + content-addressed asset set, for this node's architecture) // the actor is currently running. It is written at Run/Restore and read at @@ -189,6 +177,26 @@ func DurableDirVolumeMountPoint(actorUID, volumeName string) string { ) } +// SystemInfoVolumeRootsDir is the directory containing the per-volume root +// directories of system-info volumes. It is deliberately separate from +// DurableDirVolumeMountsDir: system-info contents are regenerated by atelet +// on every Run/Restore and must never be captured into durable snapshots. +func SystemInfoVolumeRootsDir(actorUID string) string { + return filepath.Join( + ActorPath(actorUID), + "system-info", + ) +} + +// SystemInfoVolumeRoot returns the host path of the root directory for a +// specific system-info volume. +func SystemInfoVolumeRoot(actorUID, volumeName string) string { + return filepath.Join( + SystemInfoVolumeRootsDir(actorUID), + volumeName, + ) +} + // RestoreStateDir is the local directory to use to restore an actor from a // checkpoint downloaded from GCS. // diff --git a/internal/proto/ateletpb/atelet.pb.go b/internal/proto/ateletpb/atelet.pb.go index 323a9dd43..9f4e24901 100644 --- a/internal/proto/ateletpb/atelet.pb.go +++ b/internal/proto/ateletpb/atelet.pb.go @@ -731,6 +731,165 @@ func (x *ExternalVolumeSource) GetVolumeContext() map[string]string { return nil } +// ActorIdentityDataSource writes the actor's name to a file at the given +// path, relative to the root of the enclosing system-info volume. +type ActorIdentityDataSource struct { + state protoimpl.MessageState `protogen:"open.v1"` + Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ActorIdentityDataSource) Reset() { + *x = ActorIdentityDataSource{} + mi := &file_atelet_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ActorIdentityDataSource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ActorIdentityDataSource) ProtoMessage() {} + +func (x *ActorIdentityDataSource) ProtoReflect() protoreflect.Message { + mi := &file_atelet_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ActorIdentityDataSource.ProtoReflect.Descriptor instead. +func (*ActorIdentityDataSource) Descriptor() ([]byte, []int) { + return file_atelet_proto_rawDescGZIP(), []int{10} +} + +func (x *ActorIdentityDataSource) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +type SystemInfoDataSource struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to DataSource: + // + // *SystemInfoDataSource_ActorIdentity + DataSource isSystemInfoDataSource_DataSource `protobuf_oneof:"data_source"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SystemInfoDataSource) Reset() { + *x = SystemInfoDataSource{} + mi := &file_atelet_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SystemInfoDataSource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SystemInfoDataSource) ProtoMessage() {} + +func (x *SystemInfoDataSource) ProtoReflect() protoreflect.Message { + mi := &file_atelet_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SystemInfoDataSource.ProtoReflect.Descriptor instead. +func (*SystemInfoDataSource) Descriptor() ([]byte, []int) { + return file_atelet_proto_rawDescGZIP(), []int{11} +} + +func (x *SystemInfoDataSource) GetDataSource() isSystemInfoDataSource_DataSource { + if x != nil { + return x.DataSource + } + return nil +} + +func (x *SystemInfoDataSource) GetActorIdentity() *ActorIdentityDataSource { + if x != nil { + if x, ok := x.DataSource.(*SystemInfoDataSource_ActorIdentity); ok { + return x.ActorIdentity + } + } + return nil +} + +type isSystemInfoDataSource_DataSource interface { + isSystemInfoDataSource_DataSource() +} + +type SystemInfoDataSource_ActorIdentity struct { + ActorIdentity *ActorIdentityDataSource `protobuf:"bytes,1,opt,name=actor_identity,json=actorIdentity,proto3,oneof"` +} + +func (*SystemInfoDataSource_ActorIdentity) isSystemInfoDataSource_DataSource() {} + +// SystemInfoVolume is a read-only volume whose files are generated by atelet +// on every Run/Restore, so they carry per-actor values even after a restore +// from the golden snapshot. +type SystemInfoVolume struct { + state protoimpl.MessageState `protogen:"open.v1"` + DataSources []*SystemInfoDataSource `protobuf:"bytes,1,rep,name=data_sources,json=dataSources,proto3" json:"data_sources,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SystemInfoVolume) Reset() { + *x = SystemInfoVolume{} + mi := &file_atelet_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SystemInfoVolume) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SystemInfoVolume) ProtoMessage() {} + +func (x *SystemInfoVolume) ProtoReflect() protoreflect.Message { + mi := &file_atelet_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SystemInfoVolume.ProtoReflect.Descriptor instead. +func (*SystemInfoVolume) Descriptor() ([]byte, []int) { + return file_atelet_proto_rawDescGZIP(), []int{12} +} + +func (x *SystemInfoVolume) GetDataSources() []*SystemInfoDataSource { + if x != nil { + return x.DataSources + } + return nil +} + type Volume struct { state protoimpl.MessageState `protogen:"open.v1"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` @@ -738,6 +897,7 @@ type Volume struct { // // *Volume_DurableDir // *Volume_External + // *Volume_SystemInfo Source isVolume_Source `protobuf_oneof:"source"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -745,7 +905,7 @@ type Volume struct { func (x *Volume) Reset() { *x = Volume{} - mi := &file_atelet_proto_msgTypes[10] + mi := &file_atelet_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -757,7 +917,7 @@ func (x *Volume) String() string { func (*Volume) ProtoMessage() {} func (x *Volume) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[10] + mi := &file_atelet_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -770,7 +930,7 @@ func (x *Volume) ProtoReflect() protoreflect.Message { // Deprecated: Use Volume.ProtoReflect.Descriptor instead. func (*Volume) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{10} + return file_atelet_proto_rawDescGZIP(), []int{13} } func (x *Volume) GetName() string { @@ -805,6 +965,15 @@ func (x *Volume) GetExternal() *ExternalVolumeSource { return nil } +func (x *Volume) GetSystemInfo() *SystemInfoVolume { + if x != nil { + if x, ok := x.Source.(*Volume_SystemInfo); ok { + return x.SystemInfo + } + } + return nil +} + type isVolume_Source interface { isVolume_Source() } @@ -817,10 +986,16 @@ type Volume_External struct { External *ExternalVolumeSource `protobuf:"bytes,3,opt,name=external,proto3,oneof"` } +type Volume_SystemInfo struct { + SystemInfo *SystemInfoVolume `protobuf:"bytes,4,opt,name=system_info,json=systemInfo,proto3,oneof"` +} + func (*Volume_DurableDir) isVolume_Source() {} func (*Volume_External) isVolume_Source() {} +func (*Volume_SystemInfo) isVolume_Source() {} + type VolumeMount struct { state protoimpl.MessageState `protogen:"open.v1"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` @@ -831,7 +1006,7 @@ type VolumeMount struct { func (x *VolumeMount) Reset() { *x = VolumeMount{} - mi := &file_atelet_proto_msgTypes[11] + mi := &file_atelet_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -843,7 +1018,7 @@ func (x *VolumeMount) String() string { func (*VolumeMount) ProtoMessage() {} func (x *VolumeMount) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[11] + mi := &file_atelet_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -856,7 +1031,7 @@ func (x *VolumeMount) ProtoReflect() protoreflect.Message { // Deprecated: Use VolumeMount.ProtoReflect.Descriptor instead. func (*VolumeMount) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{11} + return file_atelet_proto_rawDescGZIP(), []int{14} } func (x *VolumeMount) GetName() string { @@ -888,7 +1063,7 @@ type Container struct { func (x *Container) Reset() { *x = Container{} - mi := &file_atelet_proto_msgTypes[12] + mi := &file_atelet_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -900,7 +1075,7 @@ func (x *Container) String() string { func (*Container) ProtoMessage() {} func (x *Container) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[12] + mi := &file_atelet_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -913,7 +1088,7 @@ func (x *Container) ProtoReflect() protoreflect.Message { // Deprecated: Use Container.ProtoReflect.Descriptor instead. func (*Container) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{12} + return file_atelet_proto_rawDescGZIP(), []int{15} } func (x *Container) GetName() string { @@ -975,7 +1150,7 @@ type EnvEntry struct { func (x *EnvEntry) Reset() { *x = EnvEntry{} - mi := &file_atelet_proto_msgTypes[13] + mi := &file_atelet_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -987,7 +1162,7 @@ func (x *EnvEntry) String() string { func (*EnvEntry) ProtoMessage() {} func (x *EnvEntry) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[13] + mi := &file_atelet_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1000,7 +1175,7 @@ func (x *EnvEntry) ProtoReflect() protoreflect.Message { // Deprecated: Use EnvEntry.ProtoReflect.Descriptor instead. func (*EnvEntry) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{13} + return file_atelet_proto_rawDescGZIP(), []int{16} } func (x *EnvEntry) GetName() string { @@ -1031,7 +1206,7 @@ type Readyz struct { func (x *Readyz) Reset() { *x = Readyz{} - mi := &file_atelet_proto_msgTypes[14] + mi := &file_atelet_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1043,7 +1218,7 @@ func (x *Readyz) String() string { func (*Readyz) ProtoMessage() {} func (x *Readyz) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[14] + mi := &file_atelet_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1056,7 +1231,7 @@ func (x *Readyz) ProtoReflect() protoreflect.Message { // Deprecated: Use Readyz.ProtoReflect.Descriptor instead. func (*Readyz) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{14} + return file_atelet_proto_rawDescGZIP(), []int{17} } func (x *Readyz) GetHttpGet() *HTTPGetAction { @@ -1086,7 +1261,7 @@ type HTTPGetAction struct { func (x *HTTPGetAction) Reset() { *x = HTTPGetAction{} - mi := &file_atelet_proto_msgTypes[15] + mi := &file_atelet_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1098,7 +1273,7 @@ func (x *HTTPGetAction) String() string { func (*HTTPGetAction) ProtoMessage() {} func (x *HTTPGetAction) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[15] + mi := &file_atelet_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1111,7 +1286,7 @@ func (x *HTTPGetAction) ProtoReflect() protoreflect.Message { // Deprecated: Use HTTPGetAction.ProtoReflect.Descriptor instead. func (*HTTPGetAction) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{15} + return file_atelet_proto_rawDescGZIP(), []int{18} } func (x *HTTPGetAction) GetPath() string { @@ -1136,7 +1311,7 @@ type RunResponse struct { func (x *RunResponse) Reset() { *x = RunResponse{} - mi := &file_atelet_proto_msgTypes[16] + mi := &file_atelet_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1148,7 +1323,7 @@ func (x *RunResponse) String() string { func (*RunResponse) ProtoMessage() {} func (x *RunResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[16] + mi := &file_atelet_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1161,7 +1336,7 @@ func (x *RunResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RunResponse.ProtoReflect.Descriptor instead. func (*RunResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{16} + return file_atelet_proto_rawDescGZIP(), []int{19} } type LocalCheckpointConfiguration struct { @@ -1177,7 +1352,7 @@ type LocalCheckpointConfiguration struct { func (x *LocalCheckpointConfiguration) Reset() { *x = LocalCheckpointConfiguration{} - mi := &file_atelet_proto_msgTypes[17] + mi := &file_atelet_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1189,7 +1364,7 @@ func (x *LocalCheckpointConfiguration) String() string { func (*LocalCheckpointConfiguration) ProtoMessage() {} func (x *LocalCheckpointConfiguration) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[17] + mi := &file_atelet_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1202,7 +1377,7 @@ func (x *LocalCheckpointConfiguration) ProtoReflect() protoreflect.Message { // Deprecated: Use LocalCheckpointConfiguration.ProtoReflect.Descriptor instead. func (*LocalCheckpointConfiguration) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{17} + return file_atelet_proto_rawDescGZIP(), []int{20} } func (x *LocalCheckpointConfiguration) GetSnapshotName() string { @@ -1223,7 +1398,7 @@ type ExternalCheckpointConfiguration struct { func (x *ExternalCheckpointConfiguration) Reset() { *x = ExternalCheckpointConfiguration{} - mi := &file_atelet_proto_msgTypes[18] + mi := &file_atelet_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1235,7 +1410,7 @@ func (x *ExternalCheckpointConfiguration) String() string { func (*ExternalCheckpointConfiguration) ProtoMessage() {} func (x *ExternalCheckpointConfiguration) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[18] + mi := &file_atelet_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1248,7 +1423,7 @@ func (x *ExternalCheckpointConfiguration) ProtoReflect() protoreflect.Message { // Deprecated: Use ExternalCheckpointConfiguration.ProtoReflect.Descriptor instead. func (*ExternalCheckpointConfiguration) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{18} + return file_atelet_proto_rawDescGZIP(), []int{21} } func (x *ExternalCheckpointConfiguration) GetSnapshotUri() string { @@ -1286,7 +1461,7 @@ type CheckpointRequest struct { func (x *CheckpointRequest) Reset() { *x = CheckpointRequest{} - mi := &file_atelet_proto_msgTypes[19] + mi := &file_atelet_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1298,7 +1473,7 @@ func (x *CheckpointRequest) String() string { func (*CheckpointRequest) ProtoMessage() {} func (x *CheckpointRequest) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[19] + mi := &file_atelet_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1311,7 +1486,7 @@ func (x *CheckpointRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CheckpointRequest.ProtoReflect.Descriptor instead. func (*CheckpointRequest) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{19} + return file_atelet_proto_rawDescGZIP(), []int{22} } func (x *CheckpointRequest) GetTargetAteomUid() string { @@ -1426,7 +1601,7 @@ type CheckpointResponse struct { func (x *CheckpointResponse) Reset() { *x = CheckpointResponse{} - mi := &file_atelet_proto_msgTypes[20] + mi := &file_atelet_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1438,7 +1613,7 @@ func (x *CheckpointResponse) String() string { func (*CheckpointResponse) ProtoMessage() {} func (x *CheckpointResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[20] + mi := &file_atelet_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1451,7 +1626,7 @@ func (x *CheckpointResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CheckpointResponse.ProtoReflect.Descriptor instead. func (*CheckpointResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{20} + return file_atelet_proto_rawDescGZIP(), []int{23} } type UploadPausedCheckpointRequest struct { @@ -1479,7 +1654,7 @@ type UploadPausedCheckpointRequest struct { func (x *UploadPausedCheckpointRequest) Reset() { *x = UploadPausedCheckpointRequest{} - mi := &file_atelet_proto_msgTypes[21] + mi := &file_atelet_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1491,7 +1666,7 @@ func (x *UploadPausedCheckpointRequest) String() string { func (*UploadPausedCheckpointRequest) ProtoMessage() {} func (x *UploadPausedCheckpointRequest) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[21] + mi := &file_atelet_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1504,7 +1679,7 @@ func (x *UploadPausedCheckpointRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UploadPausedCheckpointRequest.ProtoReflect.Descriptor instead. func (*UploadPausedCheckpointRequest) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{21} + return file_atelet_proto_rawDescGZIP(), []int{24} } func (x *UploadPausedCheckpointRequest) GetAtespace() string { @@ -1571,7 +1746,7 @@ type UploadPausedCheckpointResponse struct { func (x *UploadPausedCheckpointResponse) Reset() { *x = UploadPausedCheckpointResponse{} - mi := &file_atelet_proto_msgTypes[22] + mi := &file_atelet_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1583,7 +1758,7 @@ func (x *UploadPausedCheckpointResponse) String() string { func (*UploadPausedCheckpointResponse) ProtoMessage() {} func (x *UploadPausedCheckpointResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[22] + mi := &file_atelet_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1596,7 +1771,7 @@ func (x *UploadPausedCheckpointResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UploadPausedCheckpointResponse.ProtoReflect.Descriptor instead. func (*UploadPausedCheckpointResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{22} + return file_atelet_proto_rawDescGZIP(), []int{25} } type RestoreRequest struct { @@ -1636,7 +1811,7 @@ type RestoreRequest struct { func (x *RestoreRequest) Reset() { *x = RestoreRequest{} - mi := &file_atelet_proto_msgTypes[23] + mi := &file_atelet_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1648,7 +1823,7 @@ func (x *RestoreRequest) String() string { func (*RestoreRequest) ProtoMessage() {} func (x *RestoreRequest) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[23] + mi := &file_atelet_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1661,7 +1836,7 @@ func (x *RestoreRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RestoreRequest.ProtoReflect.Descriptor instead. func (*RestoreRequest) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{23} + return file_atelet_proto_rawDescGZIP(), []int{26} } func (x *RestoreRequest) GetTargetAteomUid() string { @@ -1790,7 +1965,7 @@ type RestoreResponse struct { func (x *RestoreResponse) Reset() { *x = RestoreResponse{} - mi := &file_atelet_proto_msgTypes[24] + mi := &file_atelet_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1802,7 +1977,7 @@ func (x *RestoreResponse) String() string { func (*RestoreResponse) ProtoMessage() {} func (x *RestoreResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[24] + mi := &file_atelet_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1815,7 +1990,7 @@ func (x *RestoreResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RestoreResponse.ProtoReflect.Descriptor instead. func (*RestoreResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{24} + return file_atelet_proto_rawDescGZIP(), []int{27} } var File_atelet_proto protoreflect.FileDescriptor @@ -1874,12 +2049,21 @@ const file_atelet_proto_rawDesc = "" + "\x0evolume_context\x18\x03 \x03(\v2/.atelet.ExternalVolumeSource.VolumeContextEntryR\rvolumeContext\x1a@\n" + "\x12VolumeContextEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x9f\x01\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"-\n" + + "\x17ActorIdentityDataSource\x12\x12\n" + + "\x04path\x18\x01 \x01(\tR\x04path\"o\n" + + "\x14SystemInfoDataSource\x12H\n" + + "\x0eactor_identity\x18\x01 \x01(\v2\x1f.atelet.ActorIdentityDataSourceH\x00R\ractorIdentityB\r\n" + + "\vdata_source\"S\n" + + "\x10SystemInfoVolume\x12?\n" + + "\fdata_sources\x18\x01 \x03(\v2\x1c.atelet.SystemInfoDataSourceR\vdataSources\"\xdc\x01\n" + "\x06Volume\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12;\n" + "\vdurable_dir\x18\x02 \x01(\v2\x18.atelet.DurableDirVolumeH\x00R\n" + "durableDir\x12:\n" + - "\bexternal\x18\x03 \x01(\v2\x1c.atelet.ExternalVolumeSourceH\x00R\bexternalB\b\n" + + "\bexternal\x18\x03 \x01(\v2\x1c.atelet.ExternalVolumeSourceH\x00R\bexternal\x12;\n" + + "\vsystem_info\x18\x04 \x01(\v2\x18.atelet.SystemInfoVolumeH\x00R\n" + + "systemInfoB\b\n" + "\x06source\"@\n" + "\vVolumeMount\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x1d\n" + @@ -1984,7 +2168,7 @@ func file_atelet_proto_rawDescGZIP() []byte { } var file_atelet_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_atelet_proto_msgTypes = make([]protoimpl.MessageInfo, 28) +var file_atelet_proto_msgTypes = make([]protoimpl.MessageInfo, 31) var file_atelet_proto_goTypes = []any{ (CheckpointType)(0), // 0: atelet.CheckpointType (SnapshotScope)(0), // 1: atelet.SnapshotScope @@ -1998,69 +2182,75 @@ var file_atelet_proto_goTypes = []any{ (*WorkloadSpec)(nil), // 9: atelet.WorkloadSpec (*DurableDirVolume)(nil), // 10: atelet.DurableDirVolume (*ExternalVolumeSource)(nil), // 11: atelet.ExternalVolumeSource - (*Volume)(nil), // 12: atelet.Volume - (*VolumeMount)(nil), // 13: atelet.VolumeMount - (*Container)(nil), // 14: atelet.Container - (*EnvEntry)(nil), // 15: atelet.EnvEntry - (*Readyz)(nil), // 16: atelet.Readyz - (*HTTPGetAction)(nil), // 17: atelet.HTTPGetAction - (*RunResponse)(nil), // 18: atelet.RunResponse - (*LocalCheckpointConfiguration)(nil), // 19: atelet.LocalCheckpointConfiguration - (*ExternalCheckpointConfiguration)(nil), // 20: atelet.ExternalCheckpointConfiguration - (*CheckpointRequest)(nil), // 21: atelet.CheckpointRequest - (*CheckpointResponse)(nil), // 22: atelet.CheckpointResponse - (*UploadPausedCheckpointRequest)(nil), // 23: atelet.UploadPausedCheckpointRequest - (*UploadPausedCheckpointResponse)(nil), // 24: atelet.UploadPausedCheckpointResponse - (*RestoreRequest)(nil), // 25: atelet.RestoreRequest - (*RestoreResponse)(nil), // 26: atelet.RestoreResponse - nil, // 27: atelet.ArchAssets.FilesEntry - nil, // 28: atelet.SandboxAssets.AssetsEntry - nil, // 29: atelet.ExternalVolumeSource.VolumeContextEntry + (*ActorIdentityDataSource)(nil), // 12: atelet.ActorIdentityDataSource + (*SystemInfoDataSource)(nil), // 13: atelet.SystemInfoDataSource + (*SystemInfoVolume)(nil), // 14: atelet.SystemInfoVolume + (*Volume)(nil), // 15: atelet.Volume + (*VolumeMount)(nil), // 16: atelet.VolumeMount + (*Container)(nil), // 17: atelet.Container + (*EnvEntry)(nil), // 18: atelet.EnvEntry + (*Readyz)(nil), // 19: atelet.Readyz + (*HTTPGetAction)(nil), // 20: atelet.HTTPGetAction + (*RunResponse)(nil), // 21: atelet.RunResponse + (*LocalCheckpointConfiguration)(nil), // 22: atelet.LocalCheckpointConfiguration + (*ExternalCheckpointConfiguration)(nil), // 23: atelet.ExternalCheckpointConfiguration + (*CheckpointRequest)(nil), // 24: atelet.CheckpointRequest + (*CheckpointResponse)(nil), // 25: atelet.CheckpointResponse + (*UploadPausedCheckpointRequest)(nil), // 26: atelet.UploadPausedCheckpointRequest + (*UploadPausedCheckpointResponse)(nil), // 27: atelet.UploadPausedCheckpointResponse + (*RestoreRequest)(nil), // 28: atelet.RestoreRequest + (*RestoreResponse)(nil), // 29: atelet.RestoreResponse + nil, // 30: atelet.ArchAssets.FilesEntry + nil, // 31: atelet.SandboxAssets.AssetsEntry + nil, // 32: atelet.ExternalVolumeSource.VolumeContextEntry } var file_atelet_proto_depIdxs = []int32{ 9, // 0: atelet.RunRequest.spec:type_name -> atelet.WorkloadSpec 8, // 1: atelet.RunRequest.sandbox_assets:type_name -> atelet.SandboxAssets 5, // 2: atelet.RunRequest.egress_gateway:type_name -> atelet.EgressGateway - 27, // 3: atelet.ArchAssets.files:type_name -> atelet.ArchAssets.FilesEntry - 28, // 4: atelet.SandboxAssets.assets:type_name -> atelet.SandboxAssets.AssetsEntry - 14, // 5: atelet.WorkloadSpec.containers:type_name -> atelet.Container - 12, // 6: atelet.WorkloadSpec.volumes:type_name -> atelet.Volume - 29, // 7: atelet.ExternalVolumeSource.volume_context:type_name -> atelet.ExternalVolumeSource.VolumeContextEntry - 10, // 8: atelet.Volume.durable_dir:type_name -> atelet.DurableDirVolume - 11, // 9: atelet.Volume.external:type_name -> atelet.ExternalVolumeSource - 15, // 10: atelet.Container.env:type_name -> atelet.EnvEntry - 16, // 11: atelet.Container.readyz:type_name -> atelet.Readyz - 13, // 12: atelet.Container.volume_mounts:type_name -> atelet.VolumeMount - 17, // 13: atelet.Readyz.http_get:type_name -> atelet.HTTPGetAction - 9, // 14: atelet.CheckpointRequest.spec:type_name -> atelet.WorkloadSpec - 0, // 15: atelet.CheckpointRequest.type:type_name -> atelet.CheckpointType - 19, // 16: atelet.CheckpointRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration - 20, // 17: atelet.CheckpointRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration - 1, // 18: atelet.CheckpointRequest.scope:type_name -> atelet.SnapshotScope - 1, // 19: atelet.UploadPausedCheckpointRequest.desired_scope:type_name -> atelet.SnapshotScope - 9, // 20: atelet.RestoreRequest.spec:type_name -> atelet.WorkloadSpec - 0, // 21: atelet.RestoreRequest.type:type_name -> atelet.CheckpointType - 19, // 22: atelet.RestoreRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration - 20, // 23: atelet.RestoreRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration - 1, // 24: atelet.RestoreRequest.scope:type_name -> atelet.SnapshotScope - 5, // 25: atelet.RestoreRequest.egress_gateway:type_name -> atelet.EgressGateway - 6, // 26: atelet.ArchAssets.FilesEntry.value:type_name -> atelet.AssetFile - 7, // 27: atelet.SandboxAssets.AssetsEntry.value:type_name -> atelet.ArchAssets - 2, // 28: atelet.CredentialBroker.MintActorCertificate:input_type -> atelet.MintActorCertificateRequest - 4, // 29: atelet.AteomHerder.Run:input_type -> atelet.RunRequest - 21, // 30: atelet.AteomHerder.Checkpoint:input_type -> atelet.CheckpointRequest - 25, // 31: atelet.AteomHerder.Restore:input_type -> atelet.RestoreRequest - 23, // 32: atelet.AteomHerder.UploadPausedCheckpoint:input_type -> atelet.UploadPausedCheckpointRequest - 3, // 33: atelet.CredentialBroker.MintActorCertificate:output_type -> atelet.MintActorCertificateResponse - 18, // 34: atelet.AteomHerder.Run:output_type -> atelet.RunResponse - 22, // 35: atelet.AteomHerder.Checkpoint:output_type -> atelet.CheckpointResponse - 26, // 36: atelet.AteomHerder.Restore:output_type -> atelet.RestoreResponse - 24, // 37: atelet.AteomHerder.UploadPausedCheckpoint:output_type -> atelet.UploadPausedCheckpointResponse - 33, // [33:38] is the sub-list for method output_type - 28, // [28:33] is the sub-list for method input_type - 28, // [28:28] is the sub-list for extension type_name - 28, // [28:28] is the sub-list for extension extendee - 0, // [0:28] is the sub-list for field type_name + 30, // 3: atelet.ArchAssets.files:type_name -> atelet.ArchAssets.FilesEntry + 31, // 4: atelet.SandboxAssets.assets:type_name -> atelet.SandboxAssets.AssetsEntry + 17, // 5: atelet.WorkloadSpec.containers:type_name -> atelet.Container + 15, // 6: atelet.WorkloadSpec.volumes:type_name -> atelet.Volume + 32, // 7: atelet.ExternalVolumeSource.volume_context:type_name -> atelet.ExternalVolumeSource.VolumeContextEntry + 12, // 8: atelet.SystemInfoDataSource.actor_identity:type_name -> atelet.ActorIdentityDataSource + 13, // 9: atelet.SystemInfoVolume.data_sources:type_name -> atelet.SystemInfoDataSource + 10, // 10: atelet.Volume.durable_dir:type_name -> atelet.DurableDirVolume + 11, // 11: atelet.Volume.external:type_name -> atelet.ExternalVolumeSource + 14, // 12: atelet.Volume.system_info:type_name -> atelet.SystemInfoVolume + 18, // 13: atelet.Container.env:type_name -> atelet.EnvEntry + 19, // 14: atelet.Container.readyz:type_name -> atelet.Readyz + 16, // 15: atelet.Container.volume_mounts:type_name -> atelet.VolumeMount + 20, // 16: atelet.Readyz.http_get:type_name -> atelet.HTTPGetAction + 9, // 17: atelet.CheckpointRequest.spec:type_name -> atelet.WorkloadSpec + 0, // 18: atelet.CheckpointRequest.type:type_name -> atelet.CheckpointType + 22, // 19: atelet.CheckpointRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration + 23, // 20: atelet.CheckpointRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration + 1, // 21: atelet.CheckpointRequest.scope:type_name -> atelet.SnapshotScope + 1, // 22: atelet.UploadPausedCheckpointRequest.desired_scope:type_name -> atelet.SnapshotScope + 9, // 23: atelet.RestoreRequest.spec:type_name -> atelet.WorkloadSpec + 0, // 24: atelet.RestoreRequest.type:type_name -> atelet.CheckpointType + 22, // 25: atelet.RestoreRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration + 23, // 26: atelet.RestoreRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration + 1, // 27: atelet.RestoreRequest.scope:type_name -> atelet.SnapshotScope + 5, // 28: atelet.RestoreRequest.egress_gateway:type_name -> atelet.EgressGateway + 6, // 29: atelet.ArchAssets.FilesEntry.value:type_name -> atelet.AssetFile + 7, // 30: atelet.SandboxAssets.AssetsEntry.value:type_name -> atelet.ArchAssets + 2, // 31: atelet.CredentialBroker.MintActorCertificate:input_type -> atelet.MintActorCertificateRequest + 4, // 32: atelet.AteomHerder.Run:input_type -> atelet.RunRequest + 24, // 33: atelet.AteomHerder.Checkpoint:input_type -> atelet.CheckpointRequest + 28, // 34: atelet.AteomHerder.Restore:input_type -> atelet.RestoreRequest + 26, // 35: atelet.AteomHerder.UploadPausedCheckpoint:input_type -> atelet.UploadPausedCheckpointRequest + 3, // 36: atelet.CredentialBroker.MintActorCertificate:output_type -> atelet.MintActorCertificateResponse + 21, // 37: atelet.AteomHerder.Run:output_type -> atelet.RunResponse + 25, // 38: atelet.AteomHerder.Checkpoint:output_type -> atelet.CheckpointResponse + 29, // 39: atelet.AteomHerder.Restore:output_type -> atelet.RestoreResponse + 27, // 40: atelet.AteomHerder.UploadPausedCheckpoint:output_type -> atelet.UploadPausedCheckpointResponse + 36, // [36:41] is the sub-list for method output_type + 31, // [31:36] is the sub-list for method input_type + 31, // [31:31] is the sub-list for extension type_name + 31, // [31:31] is the sub-list for extension extendee + 0, // [0:31] is the sub-list for field type_name } func init() { file_atelet_proto_init() } @@ -2069,15 +2259,19 @@ func file_atelet_proto_init() { return } file_atelet_proto_msgTypes[2].OneofWrappers = []any{} - file_atelet_proto_msgTypes[10].OneofWrappers = []any{ + file_atelet_proto_msgTypes[11].OneofWrappers = []any{ + (*SystemInfoDataSource_ActorIdentity)(nil), + } + file_atelet_proto_msgTypes[13].OneofWrappers = []any{ (*Volume_DurableDir)(nil), (*Volume_External)(nil), + (*Volume_SystemInfo)(nil), } - file_atelet_proto_msgTypes[19].OneofWrappers = []any{ + file_atelet_proto_msgTypes[22].OneofWrappers = []any{ (*CheckpointRequest_LocalConfig)(nil), (*CheckpointRequest_ExternalConfig)(nil), } - file_atelet_proto_msgTypes[23].OneofWrappers = []any{ + file_atelet_proto_msgTypes[26].OneofWrappers = []any{ (*RestoreRequest_LocalConfig)(nil), (*RestoreRequest_ExternalConfig)(nil), } @@ -2087,7 +2281,7 @@ func file_atelet_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_atelet_proto_rawDesc), len(file_atelet_proto_rawDesc)), NumEnums: 2, - NumMessages: 28, + NumMessages: 31, NumExtensions: 0, NumServices: 2, }, diff --git a/internal/proto/ateletpb/atelet.proto b/internal/proto/ateletpb/atelet.proto index 5281d0495..83d00a659 100644 --- a/internal/proto/ateletpb/atelet.proto +++ b/internal/proto/ateletpb/atelet.proto @@ -135,12 +135,32 @@ message ExternalVolumeSource { map volume_context = 3; } +// ActorIdentityDataSource writes the actor's name to a file at the given +// path, relative to the root of the enclosing system-info volume. +message ActorIdentityDataSource { + string path = 1; +} + +message SystemInfoDataSource { + oneof data_source { + ActorIdentityDataSource actor_identity = 1; + } +} + +// SystemInfoVolume is a read-only volume whose files are generated by atelet +// on every Run/Restore, so they carry per-actor values even after a restore +// from the golden snapshot. +message SystemInfoVolume { + repeated SystemInfoDataSource data_sources = 1; +} + message Volume { string name = 1; oneof source { DurableDirVolume durable_dir = 2; ExternalVolumeSource external = 3; + SystemInfoVolume system_info = 4; } } diff --git a/manifests/ate-install/generated/ate.dev_actortemplates.yaml b/manifests/ate-install/generated/ate.dev_actortemplates.yaml index 5d20a2973..d740601d1 100644 --- a/manifests/ate-install/generated/ate.dev_actortemplates.yaml +++ b/manifests/ate-install/generated/ate.dev_actortemplates.yaml @@ -344,13 +344,51 @@ spec: x-kubernetes-validations: - message: Name must be a valid DNS label rule: '!format.dns1123Label().validate(self).hasValue()' + systemInfo: + description: systemInfo configures a system information volume. + properties: + dataSources: + description: |- + DataSources is the list of data sources to place within the SystemInfo + volume. + items: + description: |- + SystemInfoDataSource is a container allowing you to pick a particular + SystemInfo data source. + + Exactly one member must be set. + properties: + actorIdentity: + description: |- + ActorIdentityDataSource is a SystemInfo volume data source that writes the + actor's ID to a file. + properties: + path: + description: |- + Relative path from the root of the SystemInfo volume that the actor + identity file should be written. + maxLength: 1024 + minLength: 1 + type: string + required: + - path + type: object + type: object + x-kubernetes-validations: + - message: exactly one of the fields in [actorIdentity] + must be set + rule: '[has(self.actorIdentity)].filter(x,x==true).size() + == 1' + maxItems: 32 + type: array + type: object required: - name type: object x-kubernetes-validations: - - message: exactly one of the fields in [durableDir externalVolumeTemplate] - must be set - rule: '[has(self.durableDir),has(self.externalVolumeTemplate)].filter(x,x==true).size() + - message: exactly one of the fields in [durableDir externalVolumeTemplate + systemInfo] must be set + rule: '[has(self.durableDir),has(self.externalVolumeTemplate),has(self.systemInfo)].filter(x,x==true).size() == 1' maxItems: 32 type: array diff --git a/pkg/api/v1alpha1/actortemplate_types.go b/pkg/api/v1alpha1/actortemplate_types.go index bda1346d1..8fc6210b6 100644 --- a/pkg/api/v1alpha1/actortemplate_types.go +++ b/pkg/api/v1alpha1/actortemplate_types.go @@ -45,12 +45,44 @@ type ExternalVolumeTemplate struct { StorageClassName string `json:"storageClassName"` } +// ActorIdentityDataSource is a SystemInfo volume data source that writes the +// actor's ID to a file. +type ActorIdentityDataSource struct { + // Relative path from the root of the SystemInfo volume that the actor + // identity file should be written. + // + // +required + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=1024 + Path string `json:"path"` +} + +// SystemInfoDataSource is a container allowing you to pick a particular +// SystemInfo data source. +// +// Exactly one member must be set. +// +// +kubebuilder:validation:ExactlyOneOf={actorIdentity} +type SystemInfoDataSource struct { + ActorIdentity *ActorIdentityDataSource `json:"actorIdentity,omitempty"` +} + +// Represents a system information volume, which provides files containing the +// actor ID, an actor identity JWT, and an actor identity certificate. +type SystemInfoVolumeSource struct { + // DataSources is the list of data sources to place within the SystemInfo + // volume. + // + // +kubebuilder:validation:MaxItems=32 + DataSources []SystemInfoDataSource `json:"dataSources,omitempty"` +} + // Represents the source of a volume to mount. // Exactly one of its members must be specified. // // When adding a new source type, list it in the ExactlyOneOf marker below. // -// +kubebuilder:validation:ExactlyOneOf={durableDir,externalVolumeTemplate} +// +kubebuilder:validation:ExactlyOneOf={durableDir,externalVolumeTemplate,systemInfo} type VolumeSource struct { // durableDir represents a durable directory on rootfs that persists across // resumes and participates in snapshots. @@ -62,6 +94,11 @@ type VolumeSource struct { // when the actor is deleted. // +optional ExternalVolumeTemplate *ExternalVolumeTemplate `json:"externalVolumeTemplate,omitempty"` + + // systemInfo configures a system information volume. + // + // +optional + SystemInfo *SystemInfoVolumeSource `json:"systemInfo,omitempty"` } type Volume struct { diff --git a/pkg/api/v1alpha1/actortemplate_validation_test.go b/pkg/api/v1alpha1/actortemplate_validation_test.go index 33b54da29..ff79b2f82 100644 --- a/pkg/api/v1alpha1/actortemplate_validation_test.go +++ b/pkg/api/v1alpha1/actortemplate_validation_test.go @@ -677,7 +677,7 @@ func TestActorTemplateValidation(t *testing.T) { } }, wantErr: true, - errMsg: "exactly one of the fields in [durableDir externalVolumeTemplate] must be set", + errMsg: "exactly one of the fields in [durableDir externalVolumeTemplate systemInfo] must be set", }, { name: "Volumes: VolumeSource with no source set is invalid", mutate: func(at *ActorTemplate) { @@ -686,7 +686,7 @@ func TestActorTemplateValidation(t *testing.T) { } }, wantErr: true, - errMsg: "exactly one of the fields in [durableDir externalVolumeTemplate] must be set", + errMsg: "exactly one of the fields in [durableDir externalVolumeTemplate systemInfo] must be set", }, { name: "Volumes: VolumeSource with no source set is invalid (mixed with a valid DurableDir volume)", mutate: func(at *ActorTemplate) { @@ -700,7 +700,7 @@ func TestActorTemplateValidation(t *testing.T) { } }, wantErr: true, - errMsg: "exactly one of the fields in [durableDir externalVolumeTemplate] must be set", + errMsg: "exactly one of the fields in [durableDir externalVolumeTemplate systemInfo] must be set", }, { name: "Volumes: DurableDir MountPath with nested absolute path is valid", mutate: func(at *ActorTemplate) { diff --git a/pkg/api/v1alpha1/zz_generated.deepcopy.go b/pkg/api/v1alpha1/zz_generated.deepcopy.go index fb0b8841a..1652e2597 100644 --- a/pkg/api/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/api/v1alpha1/zz_generated.deepcopy.go @@ -24,6 +24,21 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ActorIdentityDataSource) DeepCopyInto(out *ActorIdentityDataSource) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActorIdentityDataSource. +func (in *ActorIdentityDataSource) DeepCopy() *ActorIdentityDataSource { + if in == nil { + return nil + } + out := new(ActorIdentityDataSource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ActorTemplate) DeepCopyInto(out *ActorTemplate) { *out = *in @@ -472,6 +487,48 @@ func (in *SnapshotsConfig) DeepCopy() *SnapshotsConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SystemInfoDataSource) DeepCopyInto(out *SystemInfoDataSource) { + *out = *in + if in.ActorIdentity != nil { + in, out := &in.ActorIdentity, &out.ActorIdentity + *out = new(ActorIdentityDataSource) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SystemInfoDataSource. +func (in *SystemInfoDataSource) DeepCopy() *SystemInfoDataSource { + if in == nil { + return nil + } + out := new(SystemInfoDataSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SystemInfoVolumeSource) DeepCopyInto(out *SystemInfoVolumeSource) { + *out = *in + if in.DataSources != nil { + in, out := &in.DataSources, &out.DataSources + *out = make([]SystemInfoDataSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SystemInfoVolumeSource. +func (in *SystemInfoVolumeSource) DeepCopy() *SystemInfoVolumeSource { + if in == nil { + return nil + } + out := new(SystemInfoVolumeSource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Volume) DeepCopyInto(out *Volume) { *out = *in @@ -516,6 +573,11 @@ func (in *VolumeSource) DeepCopyInto(out *VolumeSource) { *out = new(ExternalVolumeTemplate) (*in).DeepCopyInto(*out) } + if in.SystemInfo != nil { + in, out := &in.SystemInfo, &out.SystemInfo + *out = new(SystemInfoVolumeSource) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSource. From 3609e52ea724e096df753cde39a072e46029bc9c Mon Sep 17 00:00:00 2001 From: Max Thompson Date: Fri, 7 Aug 2026 10:27:29 -0700 Subject: [PATCH 3/7] System Information Volumes: Part 1 finishing touches Complete the initial actorIdentity data source support: - e2e: declare a systemInfo volume in the identity probe's ActorTemplate, mounted at /run/ate, replacing the removed automatic identity mount so the restore-identity regression gate exercises the new API. - Validate actorIdentity paths at admission: must be a clean relative Unix path (no absolute paths, '..', '.', '//', ':', or control characters), and paths must be unique within a volume. Previously bad paths were only rejected by the atomic writer at Run/Restore time. - Unit tests for the ateapi systemInfo conversion and for atelet's system-info volume population (extracted into writeSystemInfoVolume). - Update the stale micro-VM known-gap comment to reference systemInfo volumes instead of the removed /run/ate identity mount. --- .../internal/controlapi/workload_spec_test.go | 60 ++++++++ cmd/atelet/main.go | 59 ++++---- cmd/atelet/main_test.go | 46 +++++++ cmd/ateom-microvm/spec.go | 13 +- internal/e2e/fixtures/probe/main.go | 4 +- internal/e2e/fixtures/probe/probe.yaml.tmpl | 9 ++ .../generated/ate.dev_actortemplates.yaml | 18 ++- pkg/api/v1alpha1/actortemplate_types.go | 8 +- .../v1alpha1/actortemplate_validation_test.go | 128 ++++++++++++++++++ 9 files changed, 308 insertions(+), 37 deletions(-) diff --git a/cmd/ateapi/internal/controlapi/workload_spec_test.go b/cmd/ateapi/internal/controlapi/workload_spec_test.go index d7e36df67..70ddee254 100644 --- a/cmd/ateapi/internal/controlapi/workload_spec_test.go +++ b/cmd/ateapi/internal/controlapi/workload_spec_test.go @@ -70,6 +70,66 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) { }, }, }, + { + name: "converts SystemInfo volume with ActorIdentity data sources", + template: &atev1alpha1.ActorTemplate{ + ObjectMeta: metav1.ObjectMeta{Name: "tmpl1", Namespace: "agent-ns"}, + Spec: atev1alpha1.ActorTemplateSpec{ + PauseImage: "pause", + Volumes: []atev1alpha1.Volume{ + { + Name: "system-info", + VolumeSource: atev1alpha1.VolumeSource{ + SystemInfo: &atev1alpha1.SystemInfoVolumeSource{ + DataSources: []atev1alpha1.SystemInfoDataSource{ + {ActorIdentity: &atev1alpha1.ActorIdentityDataSource{Path: "actor-id"}}, + {ActorIdentity: &atev1alpha1.ActorIdentityDataSource{Path: "identity/name"}}, + }, + }, + }, + }, + }, + Containers: []atev1alpha1.Container{ + { + Name: "main", + Image: "main", + VolumeMounts: []atev1alpha1.VolumeMount{ + {Name: "system-info", MountPath: "/run/ate"}, + }, + }, + }, + }, + }, + want: &ateletpb.WorkloadSpec{ + PauseImage: "pause", + Volumes: []*ateletpb.Volume{ + { + Name: "system-info", + Source: &ateletpb.Volume_SystemInfo{ + SystemInfo: &ateletpb.SystemInfoVolume{ + DataSources: []*ateletpb.SystemInfoDataSource{ + {DataSource: &ateletpb.SystemInfoDataSource_ActorIdentity{ + ActorIdentity: &ateletpb.ActorIdentityDataSource{Path: "actor-id"}, + }}, + {DataSource: &ateletpb.SystemInfoDataSource_ActorIdentity{ + ActorIdentity: &ateletpb.ActorIdentityDataSource{Path: "identity/name"}, + }}, + }, + }, + }, + }, + }, + Containers: []*ateletpb.Container{ + { + Name: "main", + Image: "main", + VolumeMounts: []*ateletpb.VolumeMount{ + {Name: "system-info", MountPath: "/run/ate"}, + }, + }, + }, + }, + }, { name: "skips non-DurableDir volumes", template: &atev1alpha1.ActorTemplate{ diff --git a/cmd/atelet/main.go b/cmd/atelet/main.go index 859dcc3bc..0001d097b 100644 --- a/cmd/atelet/main.go +++ b/cmd/atelet/main.go @@ -1372,32 +1372,9 @@ func (s *AteomHerder) prepareOCIBundles( } case *ateletpb.Volume_SystemInfo: - // Populated on every Run/Restore, so the contents carry the - // correct per-actor values even when restoring from the golden - // snapshot. volRootHostPath := ateompath.SystemInfoVolumeRoot(actorUID, vol.GetName()) - if err := os.MkdirAll(volRootHostPath, 0o755); err != nil { - return fmt.Errorf("while creating %q: %w", volRootHostPath, err) - } - - aw, err := atomicwriter.NewAtomicWriter(volRootHostPath) - if err != nil { - return fmt.Errorf("while creating atomicwriter: %w", err) - } - - contents := map[string]atomicwriter.FileProjection{} - for _, dataSourceAny := range volSrc.SystemInfo.GetDataSources() { - switch dataSource := dataSourceAny.GetDataSource().(type) { - case *ateletpb.SystemInfoDataSource_ActorIdentity: - contents[dataSource.ActorIdentity.GetPath()] = atomicwriter.FileProjection{ - Data: []byte(actorName), - Mode: 0o644, - } - } - } - - if err := aw.Write(ctx, contents, nil); err != nil { - return fmt.Errorf("while writing contents of SystemInfoVolume: %w", err) + if err := writeSystemInfoVolume(ctx, volRootHostPath, actorName, volSrc.SystemInfo); err != nil { + return fmt.Errorf("while populating system-info volume %q: %w", vol.GetName(), err) } } } @@ -1474,6 +1451,38 @@ func (s *AteomHerder) prepareOCIBundles( return g.Wait() } +// writeSystemInfoVolume populates the root directory of a system-info volume +// with one file per data source. It runs on every Run/Restore, before the +// sandbox starts, so the files carry the resumed actor's own values no matter +// what checkpointed state the actor boots from. Files are written with the +// atomic writer so a concurrent reader can never observe a partial write. +func writeSystemInfoVolume(ctx context.Context, rootPath, actorName string, si *ateletpb.SystemInfoVolume) error { + if err := os.MkdirAll(rootPath, 0o755); err != nil { + return fmt.Errorf("while creating %q: %w", rootPath, err) + } + + aw, err := atomicwriter.NewAtomicWriter(rootPath) + if err != nil { + return fmt.Errorf("while creating atomicwriter: %w", err) + } + + contents := map[string]atomicwriter.FileProjection{} + for _, dataSourceAny := range si.GetDataSources() { + switch dataSource := dataSourceAny.GetDataSource().(type) { + case *ateletpb.SystemInfoDataSource_ActorIdentity: + contents[dataSource.ActorIdentity.GetPath()] = atomicwriter.FileProjection{ + Data: []byte(actorName), + Mode: 0o644, + } + } + } + + if err := aw.Write(ctx, contents, nil); err != nil { + return fmt.Errorf("while writing contents of SystemInfoVolume: %w", err) + } + return nil +} + // dialAteom opens (or reuses) the gRPC connection to the target ateom // pod and returns an ateom client. func (s *AteomHerder) dialAteom(ctx context.Context, targetAteomUid string) (ateompb.AteomClient, error) { diff --git a/cmd/atelet/main_test.go b/cmd/atelet/main_test.go index 700b26ddd..74d532a70 100644 --- a/cmd/atelet/main_test.go +++ b/cmd/atelet/main_test.go @@ -119,6 +119,52 @@ func TestSnapshotManifestRequiresPauseImage(t *testing.T) { } } +func TestWriteSystemInfoVolume(t *testing.T) { + ctx := context.Background() + root := filepath.Join(t.TempDir(), "system-info", "vol1") + si := &ateletpb.SystemInfoVolume{ + DataSources: []*ateletpb.SystemInfoDataSource{ + {DataSource: &ateletpb.SystemInfoDataSource_ActorIdentity{ + ActorIdentity: &ateletpb.ActorIdentityDataSource{Path: "actor-id"}, + }}, + {DataSource: &ateletpb.SystemInfoDataSource_ActorIdentity{ + ActorIdentity: &ateletpb.ActorIdentityDataSource{Path: "identity/name"}, + }}, + }, + } + + if err := writeSystemInfoVolume(ctx, root, "golden-actor", si); err != nil { + t.Fatalf("writeSystemInfoVolume: %v", err) + } + + // Overwrite with a different actor name, as happens when a snapshot taken + // from one actor seeds another on resume: files must carry the new value. + if err := writeSystemInfoVolume(ctx, root, "probe-alpha", si); err != nil { + t.Fatalf("writeSystemInfoVolume (rewrite): %v", err) + } + + for _, path := range []string{"actor-id", "identity/name"} { + t.Run(path, func(t *testing.T) { + target := filepath.Join(root, path) + got, err := os.ReadFile(target) + if err != nil { + t.Fatalf("reading %q: %v", target, err) + } + // Raw actor name, no trailing newline. + if string(got) != "probe-alpha" { + t.Errorf("content = %q, want %q", got, "probe-alpha") + } + info, err := os.Stat(target) + if err != nil { + t.Fatalf("stat %q: %v", target, err) + } + if perm := info.Mode().Perm(); perm != 0o644 { + t.Errorf("perm = %o, want 644", perm) + } + }) + } +} + func TestWriteFileAtomic(t *testing.T) { dir := t.TempDir() target := filepath.Join(dir, "actor-id") diff --git a/cmd/ateom-microvm/spec.go b/cmd/ateom-microvm/spec.go index 7962bc5aa..1bb015751 100644 --- a/cmd/ateom-microvm/spec.go +++ b/cmd/ateom-microvm/spec.go @@ -88,12 +88,13 @@ func ensureKataCompatibleSpec(bundle, id, netnsPath string) (*specs.Spec, error) // the exact set `ctr run --runtime io.containerd.kata.v2` emits, which kata's // agent accepts. (Static shaper; pod DNS integration is future work.) // - // KNOWN GAP vs the gVisor runtime: this also drops atelet's read-only actor - // identity bind mount (/run/ate/actor-id). The micro-VM guest can't see host - // paths (the rootfs is an overlay of a virtio-fs base + a guest-RAM upper, not a - // host bind), so atelet's host-path identity mount has nothing to bind to. - // Exposing the identity needs a per-actor volume plumbed into the guest; not yet - // implemented. No micro-VM workload depends on it today. + // KNOWN GAP vs the gVisor runtime: this also drops atelet's read-only + // systemInfo volume bind mounts (e.g. the actorIdentity data-source file). + // The micro-VM guest can't see host paths (the rootfs is an overlay of a + // virtio-fs base + a guest-RAM upper, not a host bind), so atelet's + // host-path volume roots have nothing to bind to. Exposing them needs a + // per-actor volume plumbed into the guest; not yet implemented. No + // micro-VM workload depends on it today. spec.Mounts = defaultKataMounts() out, err := json.MarshalIndent(&spec, "", " ") diff --git a/internal/e2e/fixtures/probe/main.go b/internal/e2e/fixtures/probe/main.go index 6927a1d04..89fe88ed5 100644 --- a/internal/e2e/fixtures/probe/main.go +++ b/internal/e2e/fixtures/probe/main.go @@ -27,8 +27,8 @@ import ( "os" ) -// identityFile is the actor-id file inside the identity directory atelet -// bind-mounts at IdentityMountPath. +// identityFile is the actorIdentity data-source file of the systemInfo +// volume that probe.yaml.tmpl mounts at /run/ate. const identityFile = "/run/ate/actor-id" // whoami reports the actor's identity as observed at request time from the diff --git a/internal/e2e/fixtures/probe/probe.yaml.tmpl b/internal/e2e/fixtures/probe/probe.yaml.tmpl index 85ea73fd7..890fa9777 100644 --- a/internal/e2e/fixtures/probe/probe.yaml.tmpl +++ b/internal/e2e/fixtures/probe/probe.yaml.tmpl @@ -38,10 +38,19 @@ metadata: name: probe namespace: ate-e2e-probe spec: + volumes: + - name: system-info + systemInfo: + dataSources: + - actorIdentity: + path: actor-id containers: - name: probe image: ko://github.com/agent-substrate/substrate/internal/e2e/fixtures/probe command: ["/ko-app/probe"] + volumeMounts: + - name: system-info + mountPath: /run/ate # the probe reads /run/ate/actor-id # The probe binary binds :80 immediately, so this gates actor start on a # readiness signal rather than a guess, and carries a non-default # timeoutSeconds so e2e covers the value crossing ateapi -> atelet -> ateom diff --git a/manifests/ate-install/generated/ate.dev_actortemplates.yaml b/manifests/ate-install/generated/ate.dev_actortemplates.yaml index d740601d1..f3e338ff3 100644 --- a/manifests/ate-install/generated/ate.dev_actortemplates.yaml +++ b/manifests/ate-install/generated/ate.dev_actortemplates.yaml @@ -366,10 +366,20 @@ spec: path: description: |- Relative path from the root of the SystemInfo volume that the actor - identity file should be written. - maxLength: 1024 + identity file should be written. Must be a clean relative Unix path: + must not start or end with '/', and contain no ':', '..', '.', '//', + or control characters. + maxLength: 255 minLength: 1 type: string + x-kubernetes-validations: + - message: 'path must be a clean relative Unix + path: must not start or end with ''/'', and + contain no '':'', ''..'', ''.'', ''//'', or + control characters' + rule: '!self.startsWith(''/'') && !self.endsWith(''/'') + && !self.contains(''//'') && !self.contains('':'') + && !self.matches(''[\x00-\x1f\x7f]'') && !self.matches(''(^|/)[.][.]?(/|$)'')' required: - path type: object @@ -381,6 +391,10 @@ spec: == 1' maxItems: 32 type: array + x-kubernetes-validations: + - message: dataSources must not contain duplicate paths + rule: self.all(x, !has(x.actorIdentity) || self.exists_one(y, + has(y.actorIdentity) && y.actorIdentity.path == x.actorIdentity.path)) type: object required: - name diff --git a/pkg/api/v1alpha1/actortemplate_types.go b/pkg/api/v1alpha1/actortemplate_types.go index 8fc6210b6..daa065607 100644 --- a/pkg/api/v1alpha1/actortemplate_types.go +++ b/pkg/api/v1alpha1/actortemplate_types.go @@ -49,11 +49,14 @@ type ExternalVolumeTemplate struct { // actor's ID to a file. type ActorIdentityDataSource struct { // Relative path from the root of the SystemInfo volume that the actor - // identity file should be written. + // identity file should be written. Must be a clean relative Unix path: + // must not start or end with '/', and contain no ':', '..', '.', '//', + // or control characters. // // +required // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:MaxLength=1024 + // +kubebuilder:validation:MaxLength=255 + // +kubebuilder:validation:XValidation:rule="!self.startsWith('/') && !self.endsWith('/') && !self.contains('//') && !self.contains(':') && !self.matches('[\\x00-\\x1f\\x7f]') && !self.matches('(^|/)[.][.]?(/|$)')",message="path must be a clean relative Unix path: must not start or end with '/', and contain no ':', '..', '.', '//', or control characters" Path string `json:"path"` } @@ -74,6 +77,7 @@ type SystemInfoVolumeSource struct { // volume. // // +kubebuilder:validation:MaxItems=32 + // +kubebuilder:validation:XValidation:rule="self.all(x, !has(x.actorIdentity) || self.exists_one(y, has(y.actorIdentity) && y.actorIdentity.path == x.actorIdentity.path))",message="dataSources must not contain duplicate paths" DataSources []SystemInfoDataSource `json:"dataSources,omitempty"` } diff --git a/pkg/api/v1alpha1/actortemplate_validation_test.go b/pkg/api/v1alpha1/actortemplate_validation_test.go index ff79b2f82..1c3baacd9 100644 --- a/pkg/api/v1alpha1/actortemplate_validation_test.go +++ b/pkg/api/v1alpha1/actortemplate_validation_test.go @@ -701,6 +701,134 @@ func TestActorTemplateValidation(t *testing.T) { }, wantErr: true, errMsg: "exactly one of the fields in [durableDir externalVolumeTemplate systemInfo] must be set", + }, { + name: "Volumes: SystemInfo volume with an ActorIdentity data source is valid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ActorIdentity: &ActorIdentityDataSource{Path: "actor-id"}}, + }, + }, + }, + }, + } + at.Spec.Containers[0].VolumeMounts = []VolumeMount{ + {Name: "system-info", MountPath: "/run/ate"}, + } + }, + wantErr: false, + }, { + name: "Volumes: SystemInfo data source with nested relative path is valid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ActorIdentity: &ActorIdentityDataSource{Path: "identity/actor-id"}}, + }, + }, + }, + }, + } + at.Spec.Containers[0].VolumeMounts = []VolumeMount{ + {Name: "system-info", MountPath: "/run/ate"}, + } + }, + wantErr: false, + }, { + name: "Volumes: SystemInfo data source with no member set is invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{{}}, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "exactly one of the fields in [actorIdentity] must be set", + }, { + name: "Volumes: SystemInfo data source with empty path is invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ActorIdentity: &ActorIdentityDataSource{Path: ""}}, + }, + }, + }, + }, + } + }, + wantErr: true, + }, { + name: "Volumes: SystemInfo data source with absolute path is invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ActorIdentity: &ActorIdentityDataSource{Path: "/etc/actor-id"}}, + }, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "path must be a clean relative Unix path", + }, { + name: "Volumes: SystemInfo data source with path traversal is invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ActorIdentity: &ActorIdentityDataSource{Path: "../escape"}}, + }, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "path must be a clean relative Unix path", + }, { + name: "Volumes: SystemInfo data sources with duplicate paths are invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ActorIdentity: &ActorIdentityDataSource{Path: "actor-id"}}, + {ActorIdentity: &ActorIdentityDataSource{Path: "actor-id"}}, + }, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "dataSources must not contain duplicate paths", }, { name: "Volumes: DurableDir MountPath with nested absolute path is valid", mutate: func(at *ActorTemplate) { From d1c5052b6753bfa73b25b492f8515d622cbd387f Mon Sep 17 00:00:00 2001 From: Max Thompson Date: Mon, 10 Aug 2026 16:20:34 -0700 Subject: [PATCH 4/7] Restructure SystemInfo data sources around actorMetadata Per the API discussion on #802: substrate has no "actor ID" concept -- resource identity is (atespace, name) plus a server-generated UID. Replace the actorIdentity data source with an actorMetadata source that projects each identity field to its own file, downwardAPI-style: systemInfo: dataSources: - actorMetadata: items: - field: name # enum: name | atespace | uid path: actor-name - CRD: ActorMetadataDataSource with a field enum and per-item path; admission validation for unknown fields, duplicate fields, duplicate paths, and non-clean/absolute paths; at most one actorMetadata entry per volume keeps paths unique volume-wide. - atelet proto: ActorMetadataDataSource/ActorMetadataItem with a field enum; ateapi converts CRD items to wire items. - atelet: writeSystemInfoVolume projects name/atespace/uid from the Run/Restore request; unknown fields (newer ateapi) are skipped rather than written empty. - e2e: the identity probe projects and serves all three fields; the suite now also asserts atespace matches and the projected UID equals the control plane's authoritative UID per actor, distinct across actors seeded from the same snapshot. - docs: api-guide section rewritten for actorMetadata. This also frees the "identity" naming for the planned credential data sources (actorIdentityToken, actorIdentityCertificate), which relate to the existing ateapi.ActorIdentity service. --- .../internal/controlapi/workload_spec.go | 31 +- .../internal/controlapi/workload_spec_test.go | 26 +- cmd/atelet/main.go | 42 +- cmd/atelet/main_test.go | 35 +- cmd/ateom-microvm/spec.go | 2 +- docs/api-guide.md | 22 +- internal/e2e/fixtures/probe/main.go | 27 +- internal/e2e/fixtures/probe/probe.yaml.tmpl | 10 +- internal/e2e/suites/identity/identity_test.go | 26 +- internal/proto/ateletpb/atelet.pb.go | 461 +++++++++++------- internal/proto/ateletpb/atelet.proto | 29 +- .../generated/ate.dev_actortemplates.yaml | 87 +++- pkg/api/v1alpha1/actortemplate_types.go | 67 ++- .../v1alpha1/actortemplate_validation_test.go | 128 ++++- pkg/api/v1alpha1/zz_generated.deepcopy.go | 36 +- 15 files changed, 724 insertions(+), 305 deletions(-) diff --git a/cmd/ateapi/internal/controlapi/workload_spec.go b/cmd/ateapi/internal/controlapi/workload_spec.go index d75402bf2..b2420c368 100644 --- a/cmd/ateapi/internal/controlapi/workload_spec.go +++ b/cmd/ateapi/internal/controlapi/workload_spec.go @@ -43,12 +43,17 @@ func workloadSpecFromActorTemplate(actorTemplate *atev1alpha1.ActorTemplate, act ateletSystemInfo := &ateletpb.SystemInfoVolume{} for _, dataSource := range vol.VolumeSource.SystemInfo.DataSources { switch { - case dataSource.ActorIdentity != nil: + case dataSource.ActorMetadata != nil: + actorMetadata := &ateletpb.ActorMetadataDataSource{} + for _, item := range dataSource.ActorMetadata.Items { + actorMetadata.Items = append(actorMetadata.Items, &ateletpb.ActorMetadataItem{ + Field: toAteletActorMetadataField(item.Field), + Path: item.Path, + }) + } ateletSystemInfo.DataSources = append(ateletSystemInfo.DataSources, &ateletpb.SystemInfoDataSource{ - DataSource: &ateletpb.SystemInfoDataSource_ActorIdentity{ - ActorIdentity: &ateletpb.ActorIdentityDataSource{ - Path: dataSource.ActorIdentity.Path, - }, + DataSource: &ateletpb.SystemInfoDataSource_ActorMetadata{ + ActorMetadata: actorMetadata, }, }) default: @@ -157,6 +162,22 @@ func isVolumeMounted(volumeName string, template *atev1alpha1.ActorTemplate) boo // toAteletReadyz projects the CRD readyz field onto the ateletpb wire type. // Returns nil when the source is nil so containers without a probe stay // unchanged on the wire. +// toAteletActorMetadataField projects the CRD field selector onto the atelet +// wire enum. Unknown values map to UNSPECIFIED, which atelet skips; CRD enum +// validation makes that unreachable for stored templates. +func toAteletActorMetadataField(in atev1alpha1.ActorMetadataField) ateletpb.ActorMetadataField { + switch in { + case atev1alpha1.ActorMetadataFieldName: + return ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_NAME + case atev1alpha1.ActorMetadataFieldAtespace: + return ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_ATESPACE + case atev1alpha1.ActorMetadataFieldUID: + return ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_UID + default: + return ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_UNSPECIFIED + } +} + func toAteletReadyz(in *atev1alpha1.ContainerReadyz) *ateletpb.Readyz { if in == nil { return nil diff --git a/cmd/ateapi/internal/controlapi/workload_spec_test.go b/cmd/ateapi/internal/controlapi/workload_spec_test.go index 70ddee254..3e1b4a276 100644 --- a/cmd/ateapi/internal/controlapi/workload_spec_test.go +++ b/cmd/ateapi/internal/controlapi/workload_spec_test.go @@ -71,19 +71,23 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) { }, }, { - name: "converts SystemInfo volume with ActorIdentity data sources", + name: "converts SystemInfo volume with actorMetadata items", template: &atev1alpha1.ActorTemplate{ ObjectMeta: metav1.ObjectMeta{Name: "tmpl1", Namespace: "agent-ns"}, Spec: atev1alpha1.ActorTemplateSpec{ - PauseImage: "pause", Volumes: []atev1alpha1.Volume{ { Name: "system-info", VolumeSource: atev1alpha1.VolumeSource{ SystemInfo: &atev1alpha1.SystemInfoVolumeSource{ DataSources: []atev1alpha1.SystemInfoDataSource{ - {ActorIdentity: &atev1alpha1.ActorIdentityDataSource{Path: "actor-id"}}, - {ActorIdentity: &atev1alpha1.ActorIdentityDataSource{Path: "identity/name"}}, + {ActorMetadata: &atev1alpha1.ActorMetadataDataSource{ + Items: []atev1alpha1.ActorMetadataItem{ + {Field: atev1alpha1.ActorMetadataFieldName, Path: "actor-name"}, + {Field: atev1alpha1.ActorMetadataFieldAtespace, Path: "atespace"}, + {Field: atev1alpha1.ActorMetadataFieldUID, Path: "identity/actor-uid"}, + }, + }}, }, }, }, @@ -101,18 +105,20 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) { }, }, want: &ateletpb.WorkloadSpec{ - PauseImage: "pause", Volumes: []*ateletpb.Volume{ { Name: "system-info", Source: &ateletpb.Volume_SystemInfo{ SystemInfo: &ateletpb.SystemInfoVolume{ DataSources: []*ateletpb.SystemInfoDataSource{ - {DataSource: &ateletpb.SystemInfoDataSource_ActorIdentity{ - ActorIdentity: &ateletpb.ActorIdentityDataSource{Path: "actor-id"}, - }}, - {DataSource: &ateletpb.SystemInfoDataSource_ActorIdentity{ - ActorIdentity: &ateletpb.ActorIdentityDataSource{Path: "identity/name"}, + {DataSource: &ateletpb.SystemInfoDataSource_ActorMetadata{ + ActorMetadata: &ateletpb.ActorMetadataDataSource{ + Items: []*ateletpb.ActorMetadataItem{ + {Field: ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_NAME, Path: "actor-name"}, + {Field: ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_ATESPACE, Path: "atespace"}, + {Field: ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_UID, Path: "identity/actor-uid"}, + }, + }, }}, }, }, diff --git a/cmd/atelet/main.go b/cmd/atelet/main.go index 0001d097b..7f9465176 100644 --- a/cmd/atelet/main.go +++ b/cmd/atelet/main.go @@ -432,7 +432,7 @@ func (s *AteomHerder) Run(ctx context.Context, req *ateletpb.RunRequest) (resp * return nil, fmt.Errorf("while recording sandbox assets: %w", err) } - if err := s.prepareOCIBundles(ctx, actorUID, actorRef.Name, + if err := s.prepareOCIBundles(ctx, actorUID, actorRef, req.GetSpec(), sandboxRec.PauseImage, req.GetTargetAteomUid(), ); err != nil { return nil, ateerrors.CrashIfReason(ctx, err, ateerrors.ReasonInvalidContainerConfig) @@ -1054,7 +1054,7 @@ func (s *AteomHerder) Restore(ctx context.Context, req *ateletpb.RestoreRequest) return ateerrors.CrashIfReason(ctx, err, ateerrors.ReasonFailedGetExternalObject, ateerrors.ReasonInvalidObjectURL, ateerrors.ReasonTerminalFileSystemError, ateerrors.ReasonInvalidSandboxAsset) } t := time.Now() - err = s.prepareOCIBundles(gctx, actorUID, actorRef.Name, req.GetSpec(), runtimeRec.PauseImage, req.GetTargetAteomUid()) + err = s.prepareOCIBundles(gctx, actorUID, actorRef, req.GetSpec(), runtimeRec.PauseImage, req.GetTargetAteomUid()) dBundles = time.Since(t) if err != nil { prepFailedPhase = ateattr.SnapshotPhaseOCIUnpack @@ -1357,7 +1357,7 @@ func (s *AteomHerder) downloadExternalCheckpoint(ctx context.Context, snapshotUR func (s *AteomHerder) prepareOCIBundles( ctx context.Context, actorUID string, - actorName string, + actorRef resources.ActorRef, spec *ateletpb.WorkloadSpec, pauseImage string, targetAteomUid string, @@ -1373,7 +1373,7 @@ func (s *AteomHerder) prepareOCIBundles( case *ateletpb.Volume_SystemInfo: volRootHostPath := ateompath.SystemInfoVolumeRoot(actorUID, vol.GetName()) - if err := writeSystemInfoVolume(ctx, volRootHostPath, actorName, volSrc.SystemInfo); err != nil { + if err := writeSystemInfoVolume(ctx, volRootHostPath, actorRef, actorUID, volSrc.SystemInfo); err != nil { return fmt.Errorf("while populating system-info volume %q: %w", vol.GetName(), err) } } @@ -1452,11 +1452,12 @@ func (s *AteomHerder) prepareOCIBundles( } // writeSystemInfoVolume populates the root directory of a system-info volume -// with one file per data source. It runs on every Run/Restore, before the -// sandbox starts, so the files carry the resumed actor's own values no matter -// what checkpointed state the actor boots from. Files are written with the -// atomic writer so a concurrent reader can never observe a partial write. -func writeSystemInfoVolume(ctx context.Context, rootPath, actorName string, si *ateletpb.SystemInfoVolume) error { +// with one file per projected item. It runs on every Run/Restore, before the +// sandbox starts, so the files carry the values of the actor actually being +// started, no matter what checkpointed state it boots from. Files are written +// with the atomic writer so a concurrent reader can never observe a partial +// write. +func writeSystemInfoVolume(ctx context.Context, rootPath string, actorRef resources.ActorRef, actorUID string, si *ateletpb.SystemInfoVolume) error { if err := os.MkdirAll(rootPath, 0o755); err != nil { return fmt.Errorf("while creating %q: %w", rootPath, err) } @@ -1469,10 +1470,25 @@ func writeSystemInfoVolume(ctx context.Context, rootPath, actorName string, si * contents := map[string]atomicwriter.FileProjection{} for _, dataSourceAny := range si.GetDataSources() { switch dataSource := dataSourceAny.GetDataSource().(type) { - case *ateletpb.SystemInfoDataSource_ActorIdentity: - contents[dataSource.ActorIdentity.GetPath()] = atomicwriter.FileProjection{ - Data: []byte(actorName), - Mode: 0o644, + case *ateletpb.SystemInfoDataSource_ActorMetadata: + for _, item := range dataSource.ActorMetadata.GetItems() { + var value string + switch item.GetField() { + case ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_NAME: + value = actorRef.Name + case ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_ATESPACE: + value = actorRef.Atespace + case ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_UID: + value = actorUID + default: + // Unknown fields come only from a newer ateapi; skip the + // item rather than write an empty file under its path. + continue + } + contents[item.GetPath()] = atomicwriter.FileProjection{ + Data: []byte(value), + Mode: 0o644, + } } } } diff --git a/cmd/atelet/main_test.go b/cmd/atelet/main_test.go index 74d532a70..1ff751e70 100644 --- a/cmd/atelet/main_test.go +++ b/cmd/atelet/main_test.go @@ -124,35 +124,44 @@ func TestWriteSystemInfoVolume(t *testing.T) { root := filepath.Join(t.TempDir(), "system-info", "vol1") si := &ateletpb.SystemInfoVolume{ DataSources: []*ateletpb.SystemInfoDataSource{ - {DataSource: &ateletpb.SystemInfoDataSource_ActorIdentity{ - ActorIdentity: &ateletpb.ActorIdentityDataSource{Path: "actor-id"}, - }}, - {DataSource: &ateletpb.SystemInfoDataSource_ActorIdentity{ - ActorIdentity: &ateletpb.ActorIdentityDataSource{Path: "identity/name"}, + {DataSource: &ateletpb.SystemInfoDataSource_ActorMetadata{ + ActorMetadata: &ateletpb.ActorMetadataDataSource{ + Items: []*ateletpb.ActorMetadataItem{ + {Field: ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_NAME, Path: "actor-name"}, + {Field: ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_ATESPACE, Path: "atespace"}, + {Field: ateletpb.ActorMetadataField_ACTOR_METADATA_FIELD_UID, Path: "identity/actor-uid"}, + }, + }, }}, }, } - if err := writeSystemInfoVolume(ctx, root, "golden-actor", si); err != nil { + golden := resources.ActorRef{Atespace: "ate-e2e-probe", Name: "golden-actor"} + if err := writeSystemInfoVolume(ctx, root, golden, "uid-golden", si); err != nil { t.Fatalf("writeSystemInfoVolume: %v", err) } - // Overwrite with a different actor name, as happens when a snapshot taken - // from one actor seeds another on resume: files must carry the new value. - if err := writeSystemInfoVolume(ctx, root, "probe-alpha", si); err != nil { + // Overwrite with a different actor, as happens when a snapshot taken from + // one actor seeds another on resume: files must carry the new values. + alpha := resources.ActorRef{Atespace: "ate-e2e-probe", Name: "probe-alpha"} + if err := writeSystemInfoVolume(ctx, root, alpha, "uid-alpha", si); err != nil { t.Fatalf("writeSystemInfoVolume (rewrite): %v", err) } - for _, path := range []string{"actor-id", "identity/name"} { + // Values are written raw, no trailing newline. + for path, want := range map[string]string{ + "actor-name": "probe-alpha", + "atespace": "ate-e2e-probe", + "identity/actor-uid": "uid-alpha", + } { t.Run(path, func(t *testing.T) { target := filepath.Join(root, path) got, err := os.ReadFile(target) if err != nil { t.Fatalf("reading %q: %v", target, err) } - // Raw actor name, no trailing newline. - if string(got) != "probe-alpha" { - t.Errorf("content = %q, want %q", got, "probe-alpha") + if string(got) != want { + t.Errorf("content = %q, want %q", got, want) } info, err := os.Stat(target) if err != nil { diff --git a/cmd/ateom-microvm/spec.go b/cmd/ateom-microvm/spec.go index 1bb015751..52565704c 100644 --- a/cmd/ateom-microvm/spec.go +++ b/cmd/ateom-microvm/spec.go @@ -89,7 +89,7 @@ func ensureKataCompatibleSpec(bundle, id, netnsPath string) (*specs.Spec, error) // agent accepts. (Static shaper; pod DNS integration is future work.) // // KNOWN GAP vs the gVisor runtime: this also drops atelet's read-only - // systemInfo volume bind mounts (e.g. the actorIdentity data-source file). + // systemInfo volume bind mounts (e.g. the actorMetadata data-source files). // The micro-VM guest can't see host paths (the rootfs is an overlay of a // virtio-fs base + a guest-RAM upper, not a host bind), so atelet's // host-path volume roots have nothing to bind to. Exposing them needs a diff --git a/docs/api-guide.md b/docs/api-guide.md index 2ee9839cf..0ad4555d0 100644 --- a/docs/api-guide.md +++ b/docs/api-guide.md @@ -144,7 +144,7 @@ The `ActorTemplate` defines the code, environment, and state-management policies | `sandboxClass` | `string` | Optional. The sandbox runtime family this template's actors require: `gvisor` (default) or `microvm`. Only `WorkerPool`s whose `sandboxClass` matches are eligible. | | `workerSelector` | `*LabelSelector` | Optional. Gates which `WorkerPool`s actors from this template may use, by matching against each pool's labels. If unset, all pools are eligible (subject to the actor's own `worker_selector`). | | `snapshotsConfig` | `SnapshotsConfig` | **Required.** The base object-storage location snapshots are written under, plus the pause/commit/resume scopes. See [Snapshot Storage Layout](#snapshot-storage-layout). | -| `volumes` | `[]Volume` | Optional. Volumes the containers may mount, each either a `durableDir` or an `externalVolumeTemplate`. Every declared volume must be mounted by at least one container. A `microvm` template may declare several `durableDir` volumes; a `gvisor` template is limited to one, and `externalVolumeTemplate` is `gvisor`-only. | +| `volumes` | `[]Volume` | Optional. Volumes the containers may mount, each a `durableDir`, an `externalVolumeTemplate`, or a `systemInfo` volume (see [SystemInfo Volumes](#systeminfo-volumes)). Every declared volume must be mounted by at least one container. A `microvm` template may declare several `durableDir` volumes; a `gvisor` template is limited to one, and `externalVolumeTemplate` is `gvisor`-only. | The sandbox itself — the binaries (e.g. the gVisor `runsc` binary) and the `pauseImage` holding the sandbox's namespaces — is **not configured on the `ActorTemplate`**. It is resolved from the referenced `WorkerPool`'s [`SandboxConfig`](#3-sandboxconfig-the-sandbox-itself) — by name (`workerPool.spec.sandboxConfigName`) or, by default, the cluster default `SandboxConfig` for the pool's `sandboxClass`. @@ -163,8 +163,8 @@ To deliver identity information, including credentials, to a running actor, you Available information sources: -#### ActorIdentity -The ActorIdentity data source places a file that contains the actor's name (raw, with no trailing newline) at a configurable relative path in the volume. +#### actorMetadata +The actorMetadata data source projects the actor's identity fields to files, one per item, analogous to the [Kubernetes downwardAPI volume](https://kubernetes.io/docs/concepts/storage/downward-api/). Each item selects a `field` — `name` (unique within an atespace), `atespace` (together with the name, the actor's full identity and DNS name), or `uid` (server-generated, distinguishes incarnations of the same name) — and the relative `path` the value is written to, raw with no trailing newline. ```yaml spec: @@ -172,17 +172,23 @@ spec: - name: system-info systemInfo: dataSources: - - actorIdentity: - path: actor-id + - actorMetadata: + items: + - field: name + path: actor-name + - field: atespace + path: atespace + - field: uid + path: actor-uid containers: - name: main # ... volumeMounts: - name: system-info - mountPath: /run/ate # the actor reads /run/ate/actor-id + mountPath: /run/ate # the actor reads e.g. /run/ate/actor-name ``` -Read it fresh rather than caching it at process start. It is delivered as a file on a read-only per-actor bind mount, not an environment variable, precisely so it carries the correct name after a resume from the golden snapshot — an env var (or a file baked into the image) would be frozen at the *golden* actor's name, since it lives in the checkpointed process memory, and would therefore be identical for every actor of the template. +The values are delivered as files on a read-only per-actor bind mount, not environment variables, precisely so they carry the correct values after a resume from a shared snapshot — an env var (or a file baked into the image) would be frozen at the snapshot-source actor's values, since it lives in the checkpointed process memory, and would therefore be identical for every actor restored from that snapshot. The metadata fields themselves are fixed for the actor's lifetime, so workloads may cache them; future data sources that rotate (identity tokens and certificates) must be re-read at time of use. ### Container Fields @@ -393,7 +399,7 @@ Query the physical resource pool. ## 7. Advanced: Actor Identity Credentials -Workloads can exchange their ephemeral Kubernetes credentials for stable **Actor Identity** credentials that persist even as the process migrates between different physical workers. This is distinct from the `/run/ate/actor-id` bind mount described under [Actor Identity](#actor-identity), which only tells an actor its own name. +Workloads can exchange their ephemeral Kubernetes credentials for stable **Actor Identity** credentials that persist even as the process migrates between different physical workers. This is distinct from the `actorMetadata` data source described under [SystemInfo Volumes](#systeminfo-volumes), which only tells an actor its own identity fields (name, atespace, uid). ### Service: `ateapi.ActorIdentity` * **`MintJWT`:** Generates an OIDC-compatible JWT identifying the Substrate Actor. diff --git a/internal/e2e/fixtures/probe/main.go b/internal/e2e/fixtures/probe/main.go index 89fe88ed5..91ab4dc2d 100644 --- a/internal/e2e/fixtures/probe/main.go +++ b/internal/e2e/fixtures/probe/main.go @@ -27,9 +27,13 @@ import ( "os" ) -// identityFile is the actorIdentity data-source file of the systemInfo -// volume that probe.yaml.tmpl mounts at /run/ate. -const identityFile = "/run/ate/actor-id" +// The actorMetadata data-source files of the systemInfo volume that +// probe.yaml.tmpl mounts at /run/ate. +const ( + identityFile = "/run/ate/actor-id" + atespaceFile = "/run/ate/atespace" + uidFile = "/run/ate/actor-uid" +) // whoami reports the actor's identity as observed at request time from the // bind-mounted identity file. A read failure is reported in the response @@ -38,11 +42,18 @@ func whoami(w http.ResponseWriter, _ *http.Request) { host, _ := os.Hostname() resp := map[string]string{"hostname": host} - if b, err := os.ReadFile(identityFile); err == nil { - resp["file"] = string(b) - } else { - resp["file"] = "" - resp["error"] = err.Error() + for key, path := range map[string]string{ + "file": identityFile, + "atespace": atespaceFile, + "uid": uidFile, + } { + if b, err := os.ReadFile(path); err == nil { + resp[key] = string(b) + } else { + resp[key] = "" + // Concatenate: a failed assertion should explain every missing file. + resp["error"] += err.Error() + "; " + } } writeJSON(w, resp) diff --git a/internal/e2e/fixtures/probe/probe.yaml.tmpl b/internal/e2e/fixtures/probe/probe.yaml.tmpl index 890fa9777..a0fc50c4a 100644 --- a/internal/e2e/fixtures/probe/probe.yaml.tmpl +++ b/internal/e2e/fixtures/probe/probe.yaml.tmpl @@ -42,8 +42,14 @@ spec: - name: system-info systemInfo: dataSources: - - actorIdentity: - path: actor-id + - actorMetadata: + items: + - field: name + path: actor-id + - field: atespace + path: atespace + - field: uid + path: actor-uid containers: - name: probe image: ko://github.com/agent-substrate/substrate/internal/e2e/fixtures/probe diff --git a/internal/e2e/suites/identity/identity_test.go b/internal/e2e/suites/identity/identity_test.go index abfcf7e9f..742e22013 100644 --- a/internal/e2e/suites/identity/identity_test.go +++ b/internal/e2e/suites/identity/identity_test.go @@ -39,9 +39,11 @@ const ( type whoamiResponse struct { File string `json:"file"` + Atespace string `json:"atespace"` + UID string `json:"uid"` Hostname string `json:"hostname"` - // Error is the probe's identity-file read error, if any, so a failed - // assertion explains why the ID was missing. + // Error is the probe's file read error(s), if any, so a failed assertion + // explains why a value was missing. Error string `json:"error"` } @@ -75,6 +77,7 @@ func TestActorIdentity_AfterRestore_IsOwnID_NotGolden(t *testing.T) { defer rc.Close() seen := map[string]string{} + seenUIDs := map[string]string{} for _, id := range ids { got := whoami(t, ctx, rc, id) @@ -88,6 +91,25 @@ func TestActorIdentity_AfterRestore_IsOwnID_NotGolden(t *testing.T) { t.Errorf("actor %q and %q both report identity %q — actors are not distinct", id, other, got.File) } seen[got.File] = id + + if got.Atespace != probeNamespace { + t.Errorf("actor %q: /run/ate/atespace = %q, want %q (probe read error: %q)", id, got.Atespace, probeNamespace, got.Error) + } + + // The projected UID must match the control plane's authoritative view + // of this actor, and be distinct per actor even though both actors + // were seeded from the same golden snapshot. + actor, err := clients.SubstrateAPI.GetActor(ctx, &ateapipb.GetActorRequest{Actor: &ateapipb.ObjectRef{Atespace: probeNamespace, Name: id}}) + if err != nil { + t.Fatalf("GetActor %q: %v", id, err) + } + if wantUID := actor.GetMetadata().GetUid(); got.UID != wantUID { + t.Errorf("actor %q: /run/ate/actor-uid = %q, want %q (probe read error: %q)", id, got.UID, wantUID, got.Error) + } + if other, dup := seenUIDs[got.UID]; dup { + t.Errorf("actor %q and %q both report uid %q — actors are not distinct", id, other, got.UID) + } + seenUIDs[got.UID] = id } } diff --git a/internal/proto/ateletpb/atelet.pb.go b/internal/proto/ateletpb/atelet.pb.go index 9f4e24901..2f0250b4c 100644 --- a/internal/proto/ateletpb/atelet.pb.go +++ b/internal/proto/ateletpb/atelet.pb.go @@ -35,6 +35,59 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// ActorMetadataField selects one identity field of the actor. +type ActorMetadataField int32 + +const ( + ActorMetadataField_ACTOR_METADATA_FIELD_UNSPECIFIED ActorMetadataField = 0 + ActorMetadataField_ACTOR_METADATA_FIELD_NAME ActorMetadataField = 1 + ActorMetadataField_ACTOR_METADATA_FIELD_ATESPACE ActorMetadataField = 2 + ActorMetadataField_ACTOR_METADATA_FIELD_UID ActorMetadataField = 3 +) + +// Enum value maps for ActorMetadataField. +var ( + ActorMetadataField_name = map[int32]string{ + 0: "ACTOR_METADATA_FIELD_UNSPECIFIED", + 1: "ACTOR_METADATA_FIELD_NAME", + 2: "ACTOR_METADATA_FIELD_ATESPACE", + 3: "ACTOR_METADATA_FIELD_UID", + } + ActorMetadataField_value = map[string]int32{ + "ACTOR_METADATA_FIELD_UNSPECIFIED": 0, + "ACTOR_METADATA_FIELD_NAME": 1, + "ACTOR_METADATA_FIELD_ATESPACE": 2, + "ACTOR_METADATA_FIELD_UID": 3, + } +) + +func (x ActorMetadataField) Enum() *ActorMetadataField { + p := new(ActorMetadataField) + *p = x + return p +} + +func (x ActorMetadataField) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ActorMetadataField) Descriptor() protoreflect.EnumDescriptor { + return file_atelet_proto_enumTypes[0].Descriptor() +} + +func (ActorMetadataField) Type() protoreflect.EnumType { + return &file_atelet_proto_enumTypes[0] +} + +func (x ActorMetadataField) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ActorMetadataField.Descriptor instead. +func (ActorMetadataField) EnumDescriptor() ([]byte, []int) { + return file_atelet_proto_rawDescGZIP(), []int{0} +} + type CheckpointType int32 const ( @@ -71,11 +124,11 @@ func (x CheckpointType) String() string { } func (CheckpointType) Descriptor() protoreflect.EnumDescriptor { - return file_atelet_proto_enumTypes[0].Descriptor() + return file_atelet_proto_enumTypes[1].Descriptor() } func (CheckpointType) Type() protoreflect.EnumType { - return &file_atelet_proto_enumTypes[0] + return &file_atelet_proto_enumTypes[1] } func (x CheckpointType) Number() protoreflect.EnumNumber { @@ -84,7 +137,7 @@ func (x CheckpointType) Number() protoreflect.EnumNumber { // Deprecated: Use CheckpointType.Descriptor instead. func (CheckpointType) EnumDescriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{0} + return file_atelet_proto_rawDescGZIP(), []int{1} } type SnapshotScope int32 @@ -135,11 +188,11 @@ func (x SnapshotScope) String() string { } func (SnapshotScope) Descriptor() protoreflect.EnumDescriptor { - return file_atelet_proto_enumTypes[1].Descriptor() + return file_atelet_proto_enumTypes[2].Descriptor() } func (SnapshotScope) Type() protoreflect.EnumType { - return &file_atelet_proto_enumTypes[1] + return &file_atelet_proto_enumTypes[2] } func (x SnapshotScope) Number() protoreflect.EnumNumber { @@ -148,7 +201,7 @@ func (x SnapshotScope) Number() protoreflect.EnumNumber { // Deprecated: Use SnapshotScope.Descriptor instead. func (SnapshotScope) EnumDescriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{1} + return file_atelet_proto_rawDescGZIP(), []int{2} } type MintActorCertificateRequest struct { @@ -731,29 +784,30 @@ func (x *ExternalVolumeSource) GetVolumeContext() map[string]string { return nil } -// ActorIdentityDataSource writes the actor's name to a file at the given -// path, relative to the root of the enclosing system-info volume. -type ActorIdentityDataSource struct { +// ActorMetadataItem projects one actor identity field to one file at the +// given path, relative to the root of the enclosing system-info volume. +type ActorMetadataItem struct { state protoimpl.MessageState `protogen:"open.v1"` - Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + Field ActorMetadataField `protobuf:"varint,1,opt,name=field,proto3,enum=atelet.ActorMetadataField" json:"field,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *ActorIdentityDataSource) Reset() { - *x = ActorIdentityDataSource{} +func (x *ActorMetadataItem) Reset() { + *x = ActorMetadataItem{} mi := &file_atelet_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *ActorIdentityDataSource) String() string { +func (x *ActorMetadataItem) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ActorIdentityDataSource) ProtoMessage() {} +func (*ActorMetadataItem) ProtoMessage() {} -func (x *ActorIdentityDataSource) ProtoReflect() protoreflect.Message { +func (x *ActorMetadataItem) ProtoReflect() protoreflect.Message { mi := &file_atelet_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -765,23 +819,76 @@ func (x *ActorIdentityDataSource) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ActorIdentityDataSource.ProtoReflect.Descriptor instead. -func (*ActorIdentityDataSource) Descriptor() ([]byte, []int) { +// Deprecated: Use ActorMetadataItem.ProtoReflect.Descriptor instead. +func (*ActorMetadataItem) Descriptor() ([]byte, []int) { return file_atelet_proto_rawDescGZIP(), []int{10} } -func (x *ActorIdentityDataSource) GetPath() string { +func (x *ActorMetadataItem) GetField() ActorMetadataField { + if x != nil { + return x.Field + } + return ActorMetadataField_ACTOR_METADATA_FIELD_UNSPECIFIED +} + +func (x *ActorMetadataItem) GetPath() string { if x != nil { return x.Path } return "" } +// ActorMetadataDataSource projects the actor's identity fields to files, one +// per item. Values are written raw with no trailing newline. +type ActorMetadataDataSource struct { + state protoimpl.MessageState `protogen:"open.v1"` + Items []*ActorMetadataItem `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ActorMetadataDataSource) Reset() { + *x = ActorMetadataDataSource{} + mi := &file_atelet_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ActorMetadataDataSource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ActorMetadataDataSource) ProtoMessage() {} + +func (x *ActorMetadataDataSource) ProtoReflect() protoreflect.Message { + mi := &file_atelet_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ActorMetadataDataSource.ProtoReflect.Descriptor instead. +func (*ActorMetadataDataSource) Descriptor() ([]byte, []int) { + return file_atelet_proto_rawDescGZIP(), []int{11} +} + +func (x *ActorMetadataDataSource) GetItems() []*ActorMetadataItem { + if x != nil { + return x.Items + } + return nil +} + type SystemInfoDataSource struct { state protoimpl.MessageState `protogen:"open.v1"` // Types that are valid to be assigned to DataSource: // - // *SystemInfoDataSource_ActorIdentity + // *SystemInfoDataSource_ActorMetadata DataSource isSystemInfoDataSource_DataSource `protobuf_oneof:"data_source"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -789,7 +896,7 @@ type SystemInfoDataSource struct { func (x *SystemInfoDataSource) Reset() { *x = SystemInfoDataSource{} - mi := &file_atelet_proto_msgTypes[11] + mi := &file_atelet_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -801,7 +908,7 @@ func (x *SystemInfoDataSource) String() string { func (*SystemInfoDataSource) ProtoMessage() {} func (x *SystemInfoDataSource) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[11] + mi := &file_atelet_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -814,7 +921,7 @@ func (x *SystemInfoDataSource) ProtoReflect() protoreflect.Message { // Deprecated: Use SystemInfoDataSource.ProtoReflect.Descriptor instead. func (*SystemInfoDataSource) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{11} + return file_atelet_proto_rawDescGZIP(), []int{12} } func (x *SystemInfoDataSource) GetDataSource() isSystemInfoDataSource_DataSource { @@ -824,10 +931,10 @@ func (x *SystemInfoDataSource) GetDataSource() isSystemInfoDataSource_DataSource return nil } -func (x *SystemInfoDataSource) GetActorIdentity() *ActorIdentityDataSource { +func (x *SystemInfoDataSource) GetActorMetadata() *ActorMetadataDataSource { if x != nil { - if x, ok := x.DataSource.(*SystemInfoDataSource_ActorIdentity); ok { - return x.ActorIdentity + if x, ok := x.DataSource.(*SystemInfoDataSource_ActorMetadata); ok { + return x.ActorMetadata } } return nil @@ -837,15 +944,15 @@ type isSystemInfoDataSource_DataSource interface { isSystemInfoDataSource_DataSource() } -type SystemInfoDataSource_ActorIdentity struct { - ActorIdentity *ActorIdentityDataSource `protobuf:"bytes,1,opt,name=actor_identity,json=actorIdentity,proto3,oneof"` +type SystemInfoDataSource_ActorMetadata struct { + ActorMetadata *ActorMetadataDataSource `protobuf:"bytes,1,opt,name=actor_metadata,json=actorMetadata,proto3,oneof"` } -func (*SystemInfoDataSource_ActorIdentity) isSystemInfoDataSource_DataSource() {} +func (*SystemInfoDataSource_ActorMetadata) isSystemInfoDataSource_DataSource() {} // SystemInfoVolume is a read-only volume whose files are generated by atelet -// on every Run/Restore, so they carry per-actor values even after a restore -// from the golden snapshot. +// on every Run/Restore, so they carry the values of the actor actually being +// started, whatever checkpointed state it boots from. type SystemInfoVolume struct { state protoimpl.MessageState `protogen:"open.v1"` DataSources []*SystemInfoDataSource `protobuf:"bytes,1,rep,name=data_sources,json=dataSources,proto3" json:"data_sources,omitempty"` @@ -855,7 +962,7 @@ type SystemInfoVolume struct { func (x *SystemInfoVolume) Reset() { *x = SystemInfoVolume{} - mi := &file_atelet_proto_msgTypes[12] + mi := &file_atelet_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -867,7 +974,7 @@ func (x *SystemInfoVolume) String() string { func (*SystemInfoVolume) ProtoMessage() {} func (x *SystemInfoVolume) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[12] + mi := &file_atelet_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -880,7 +987,7 @@ func (x *SystemInfoVolume) ProtoReflect() protoreflect.Message { // Deprecated: Use SystemInfoVolume.ProtoReflect.Descriptor instead. func (*SystemInfoVolume) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{12} + return file_atelet_proto_rawDescGZIP(), []int{13} } func (x *SystemInfoVolume) GetDataSources() []*SystemInfoDataSource { @@ -905,7 +1012,7 @@ type Volume struct { func (x *Volume) Reset() { *x = Volume{} - mi := &file_atelet_proto_msgTypes[13] + mi := &file_atelet_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -917,7 +1024,7 @@ func (x *Volume) String() string { func (*Volume) ProtoMessage() {} func (x *Volume) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[13] + mi := &file_atelet_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -930,7 +1037,7 @@ func (x *Volume) ProtoReflect() protoreflect.Message { // Deprecated: Use Volume.ProtoReflect.Descriptor instead. func (*Volume) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{13} + return file_atelet_proto_rawDescGZIP(), []int{14} } func (x *Volume) GetName() string { @@ -1006,7 +1113,7 @@ type VolumeMount struct { func (x *VolumeMount) Reset() { *x = VolumeMount{} - mi := &file_atelet_proto_msgTypes[14] + mi := &file_atelet_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1018,7 +1125,7 @@ func (x *VolumeMount) String() string { func (*VolumeMount) ProtoMessage() {} func (x *VolumeMount) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[14] + mi := &file_atelet_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1031,7 +1138,7 @@ func (x *VolumeMount) ProtoReflect() protoreflect.Message { // Deprecated: Use VolumeMount.ProtoReflect.Descriptor instead. func (*VolumeMount) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{14} + return file_atelet_proto_rawDescGZIP(), []int{15} } func (x *VolumeMount) GetName() string { @@ -1063,7 +1170,7 @@ type Container struct { func (x *Container) Reset() { *x = Container{} - mi := &file_atelet_proto_msgTypes[15] + mi := &file_atelet_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1075,7 +1182,7 @@ func (x *Container) String() string { func (*Container) ProtoMessage() {} func (x *Container) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[15] + mi := &file_atelet_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1088,7 +1195,7 @@ func (x *Container) ProtoReflect() protoreflect.Message { // Deprecated: Use Container.ProtoReflect.Descriptor instead. func (*Container) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{15} + return file_atelet_proto_rawDescGZIP(), []int{16} } func (x *Container) GetName() string { @@ -1150,7 +1257,7 @@ type EnvEntry struct { func (x *EnvEntry) Reset() { *x = EnvEntry{} - mi := &file_atelet_proto_msgTypes[16] + mi := &file_atelet_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1162,7 +1269,7 @@ func (x *EnvEntry) String() string { func (*EnvEntry) ProtoMessage() {} func (x *EnvEntry) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[16] + mi := &file_atelet_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1175,7 +1282,7 @@ func (x *EnvEntry) ProtoReflect() protoreflect.Message { // Deprecated: Use EnvEntry.ProtoReflect.Descriptor instead. func (*EnvEntry) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{16} + return file_atelet_proto_rawDescGZIP(), []int{17} } func (x *EnvEntry) GetName() string { @@ -1206,7 +1313,7 @@ type Readyz struct { func (x *Readyz) Reset() { *x = Readyz{} - mi := &file_atelet_proto_msgTypes[17] + mi := &file_atelet_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1218,7 +1325,7 @@ func (x *Readyz) String() string { func (*Readyz) ProtoMessage() {} func (x *Readyz) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[17] + mi := &file_atelet_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1231,7 +1338,7 @@ func (x *Readyz) ProtoReflect() protoreflect.Message { // Deprecated: Use Readyz.ProtoReflect.Descriptor instead. func (*Readyz) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{17} + return file_atelet_proto_rawDescGZIP(), []int{18} } func (x *Readyz) GetHttpGet() *HTTPGetAction { @@ -1261,7 +1368,7 @@ type HTTPGetAction struct { func (x *HTTPGetAction) Reset() { *x = HTTPGetAction{} - mi := &file_atelet_proto_msgTypes[18] + mi := &file_atelet_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1273,7 +1380,7 @@ func (x *HTTPGetAction) String() string { func (*HTTPGetAction) ProtoMessage() {} func (x *HTTPGetAction) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[18] + mi := &file_atelet_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1286,7 +1393,7 @@ func (x *HTTPGetAction) ProtoReflect() protoreflect.Message { // Deprecated: Use HTTPGetAction.ProtoReflect.Descriptor instead. func (*HTTPGetAction) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{18} + return file_atelet_proto_rawDescGZIP(), []int{19} } func (x *HTTPGetAction) GetPath() string { @@ -1311,7 +1418,7 @@ type RunResponse struct { func (x *RunResponse) Reset() { *x = RunResponse{} - mi := &file_atelet_proto_msgTypes[19] + mi := &file_atelet_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1323,7 +1430,7 @@ func (x *RunResponse) String() string { func (*RunResponse) ProtoMessage() {} func (x *RunResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[19] + mi := &file_atelet_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1336,7 +1443,7 @@ func (x *RunResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RunResponse.ProtoReflect.Descriptor instead. func (*RunResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{19} + return file_atelet_proto_rawDescGZIP(), []int{20} } type LocalCheckpointConfiguration struct { @@ -1352,7 +1459,7 @@ type LocalCheckpointConfiguration struct { func (x *LocalCheckpointConfiguration) Reset() { *x = LocalCheckpointConfiguration{} - mi := &file_atelet_proto_msgTypes[20] + mi := &file_atelet_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1364,7 +1471,7 @@ func (x *LocalCheckpointConfiguration) String() string { func (*LocalCheckpointConfiguration) ProtoMessage() {} func (x *LocalCheckpointConfiguration) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[20] + mi := &file_atelet_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1377,7 +1484,7 @@ func (x *LocalCheckpointConfiguration) ProtoReflect() protoreflect.Message { // Deprecated: Use LocalCheckpointConfiguration.ProtoReflect.Descriptor instead. func (*LocalCheckpointConfiguration) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{20} + return file_atelet_proto_rawDescGZIP(), []int{21} } func (x *LocalCheckpointConfiguration) GetSnapshotName() string { @@ -1398,7 +1505,7 @@ type ExternalCheckpointConfiguration struct { func (x *ExternalCheckpointConfiguration) Reset() { *x = ExternalCheckpointConfiguration{} - mi := &file_atelet_proto_msgTypes[21] + mi := &file_atelet_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1410,7 +1517,7 @@ func (x *ExternalCheckpointConfiguration) String() string { func (*ExternalCheckpointConfiguration) ProtoMessage() {} func (x *ExternalCheckpointConfiguration) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[21] + mi := &file_atelet_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1423,7 +1530,7 @@ func (x *ExternalCheckpointConfiguration) ProtoReflect() protoreflect.Message { // Deprecated: Use ExternalCheckpointConfiguration.ProtoReflect.Descriptor instead. func (*ExternalCheckpointConfiguration) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{21} + return file_atelet_proto_rawDescGZIP(), []int{22} } func (x *ExternalCheckpointConfiguration) GetSnapshotUri() string { @@ -1461,7 +1568,7 @@ type CheckpointRequest struct { func (x *CheckpointRequest) Reset() { *x = CheckpointRequest{} - mi := &file_atelet_proto_msgTypes[22] + mi := &file_atelet_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1473,7 +1580,7 @@ func (x *CheckpointRequest) String() string { func (*CheckpointRequest) ProtoMessage() {} func (x *CheckpointRequest) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[22] + mi := &file_atelet_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1486,7 +1593,7 @@ func (x *CheckpointRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CheckpointRequest.ProtoReflect.Descriptor instead. func (*CheckpointRequest) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{22} + return file_atelet_proto_rawDescGZIP(), []int{23} } func (x *CheckpointRequest) GetTargetAteomUid() string { @@ -1601,7 +1708,7 @@ type CheckpointResponse struct { func (x *CheckpointResponse) Reset() { *x = CheckpointResponse{} - mi := &file_atelet_proto_msgTypes[23] + mi := &file_atelet_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1613,7 +1720,7 @@ func (x *CheckpointResponse) String() string { func (*CheckpointResponse) ProtoMessage() {} func (x *CheckpointResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[23] + mi := &file_atelet_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1626,7 +1733,7 @@ func (x *CheckpointResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CheckpointResponse.ProtoReflect.Descriptor instead. func (*CheckpointResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{23} + return file_atelet_proto_rawDescGZIP(), []int{24} } type UploadPausedCheckpointRequest struct { @@ -1654,7 +1761,7 @@ type UploadPausedCheckpointRequest struct { func (x *UploadPausedCheckpointRequest) Reset() { *x = UploadPausedCheckpointRequest{} - mi := &file_atelet_proto_msgTypes[24] + mi := &file_atelet_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1666,7 +1773,7 @@ func (x *UploadPausedCheckpointRequest) String() string { func (*UploadPausedCheckpointRequest) ProtoMessage() {} func (x *UploadPausedCheckpointRequest) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[24] + mi := &file_atelet_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1679,7 +1786,7 @@ func (x *UploadPausedCheckpointRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UploadPausedCheckpointRequest.ProtoReflect.Descriptor instead. func (*UploadPausedCheckpointRequest) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{24} + return file_atelet_proto_rawDescGZIP(), []int{25} } func (x *UploadPausedCheckpointRequest) GetAtespace() string { @@ -1746,7 +1853,7 @@ type UploadPausedCheckpointResponse struct { func (x *UploadPausedCheckpointResponse) Reset() { *x = UploadPausedCheckpointResponse{} - mi := &file_atelet_proto_msgTypes[25] + mi := &file_atelet_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1758,7 +1865,7 @@ func (x *UploadPausedCheckpointResponse) String() string { func (*UploadPausedCheckpointResponse) ProtoMessage() {} func (x *UploadPausedCheckpointResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[25] + mi := &file_atelet_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1771,7 +1878,7 @@ func (x *UploadPausedCheckpointResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UploadPausedCheckpointResponse.ProtoReflect.Descriptor instead. func (*UploadPausedCheckpointResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{25} + return file_atelet_proto_rawDescGZIP(), []int{26} } type RestoreRequest struct { @@ -1811,7 +1918,7 @@ type RestoreRequest struct { func (x *RestoreRequest) Reset() { *x = RestoreRequest{} - mi := &file_atelet_proto_msgTypes[26] + mi := &file_atelet_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1823,7 +1930,7 @@ func (x *RestoreRequest) String() string { func (*RestoreRequest) ProtoMessage() {} func (x *RestoreRequest) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[26] + mi := &file_atelet_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1836,7 +1943,7 @@ func (x *RestoreRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RestoreRequest.ProtoReflect.Descriptor instead. func (*RestoreRequest) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{26} + return file_atelet_proto_rawDescGZIP(), []int{27} } func (x *RestoreRequest) GetTargetAteomUid() string { @@ -1965,7 +2072,7 @@ type RestoreResponse struct { func (x *RestoreResponse) Reset() { *x = RestoreResponse{} - mi := &file_atelet_proto_msgTypes[27] + mi := &file_atelet_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1977,7 +2084,7 @@ func (x *RestoreResponse) String() string { func (*RestoreResponse) ProtoMessage() {} func (x *RestoreResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[27] + mi := &file_atelet_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1990,7 +2097,7 @@ func (x *RestoreResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RestoreResponse.ProtoReflect.Descriptor instead. func (*RestoreResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{27} + return file_atelet_proto_rawDescGZIP(), []int{28} } var File_atelet_proto protoreflect.FileDescriptor @@ -2049,11 +2156,14 @@ const file_atelet_proto_rawDesc = "" + "\x0evolume_context\x18\x03 \x03(\v2/.atelet.ExternalVolumeSource.VolumeContextEntryR\rvolumeContext\x1a@\n" + "\x12VolumeContextEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"-\n" + - "\x17ActorIdentityDataSource\x12\x12\n" + - "\x04path\x18\x01 \x01(\tR\x04path\"o\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"Y\n" + + "\x11ActorMetadataItem\x120\n" + + "\x05field\x18\x01 \x01(\x0e2\x1a.atelet.ActorMetadataFieldR\x05field\x12\x12\n" + + "\x04path\x18\x02 \x01(\tR\x04path\"J\n" + + "\x17ActorMetadataDataSource\x12/\n" + + "\x05items\x18\x01 \x03(\v2\x19.atelet.ActorMetadataItemR\x05items\"o\n" + "\x14SystemInfoDataSource\x12H\n" + - "\x0eactor_identity\x18\x01 \x01(\v2\x1f.atelet.ActorIdentityDataSourceH\x00R\ractorIdentityB\r\n" + + "\x0eactor_metadata\x18\x01 \x01(\v2\x1f.atelet.ActorMetadataDataSourceH\x00R\ractorMetadataB\r\n" + "\vdata_source\"S\n" + "\x10SystemInfoVolume\x12?\n" + "\fdata_sources\x18\x01 \x03(\v2\x1c.atelet.SystemInfoDataSourceR\vdataSources\"\xdc\x01\n" + @@ -2136,7 +2246,12 @@ const file_atelet_proto_rawDesc = "" + "\x0eegress_gateway\x18\r \x01(\v2\x15.atelet.EgressGatewayH\x01R\regressGateway\x88\x01\x01B\b\n" + "\x06configB\x11\n" + "\x0f_egress_gateway\"\x11\n" + - "\x0fRestoreResponse*j\n" + + "\x0fRestoreResponse*\x9a\x01\n" + + "\x12ActorMetadataField\x12$\n" + + " ACTOR_METADATA_FIELD_UNSPECIFIED\x10\x00\x12\x1d\n" + + "\x19ACTOR_METADATA_FIELD_NAME\x10\x01\x12!\n" + + "\x1dACTOR_METADATA_FIELD_ATESPACE\x10\x02\x12\x1c\n" + + "\x18ACTOR_METADATA_FIELD_UID\x10\x03*j\n" + "\x0eCheckpointType\x12\x1f\n" + "\x1bCHECKPOINT_TYPE_UNSPECIFIED\x10\x00\x12\x19\n" + "\x15CHECKPOINT_TYPE_LOCAL\x10\x01\x12\x1c\n" + @@ -2167,90 +2282,94 @@ func file_atelet_proto_rawDescGZIP() []byte { return file_atelet_proto_rawDescData } -var file_atelet_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_atelet_proto_msgTypes = make([]protoimpl.MessageInfo, 31) +var file_atelet_proto_enumTypes = make([]protoimpl.EnumInfo, 3) +var file_atelet_proto_msgTypes = make([]protoimpl.MessageInfo, 32) var file_atelet_proto_goTypes = []any{ - (CheckpointType)(0), // 0: atelet.CheckpointType - (SnapshotScope)(0), // 1: atelet.SnapshotScope - (*MintActorCertificateRequest)(nil), // 2: atelet.MintActorCertificateRequest - (*MintActorCertificateResponse)(nil), // 3: atelet.MintActorCertificateResponse - (*RunRequest)(nil), // 4: atelet.RunRequest - (*EgressGateway)(nil), // 5: atelet.EgressGateway - (*AssetFile)(nil), // 6: atelet.AssetFile - (*ArchAssets)(nil), // 7: atelet.ArchAssets - (*SandboxAssets)(nil), // 8: atelet.SandboxAssets - (*WorkloadSpec)(nil), // 9: atelet.WorkloadSpec - (*DurableDirVolume)(nil), // 10: atelet.DurableDirVolume - (*ExternalVolumeSource)(nil), // 11: atelet.ExternalVolumeSource - (*ActorIdentityDataSource)(nil), // 12: atelet.ActorIdentityDataSource - (*SystemInfoDataSource)(nil), // 13: atelet.SystemInfoDataSource - (*SystemInfoVolume)(nil), // 14: atelet.SystemInfoVolume - (*Volume)(nil), // 15: atelet.Volume - (*VolumeMount)(nil), // 16: atelet.VolumeMount - (*Container)(nil), // 17: atelet.Container - (*EnvEntry)(nil), // 18: atelet.EnvEntry - (*Readyz)(nil), // 19: atelet.Readyz - (*HTTPGetAction)(nil), // 20: atelet.HTTPGetAction - (*RunResponse)(nil), // 21: atelet.RunResponse - (*LocalCheckpointConfiguration)(nil), // 22: atelet.LocalCheckpointConfiguration - (*ExternalCheckpointConfiguration)(nil), // 23: atelet.ExternalCheckpointConfiguration - (*CheckpointRequest)(nil), // 24: atelet.CheckpointRequest - (*CheckpointResponse)(nil), // 25: atelet.CheckpointResponse - (*UploadPausedCheckpointRequest)(nil), // 26: atelet.UploadPausedCheckpointRequest - (*UploadPausedCheckpointResponse)(nil), // 27: atelet.UploadPausedCheckpointResponse - (*RestoreRequest)(nil), // 28: atelet.RestoreRequest - (*RestoreResponse)(nil), // 29: atelet.RestoreResponse - nil, // 30: atelet.ArchAssets.FilesEntry - nil, // 31: atelet.SandboxAssets.AssetsEntry - nil, // 32: atelet.ExternalVolumeSource.VolumeContextEntry + (ActorMetadataField)(0), // 0: atelet.ActorMetadataField + (CheckpointType)(0), // 1: atelet.CheckpointType + (SnapshotScope)(0), // 2: atelet.SnapshotScope + (*MintActorCertificateRequest)(nil), // 3: atelet.MintActorCertificateRequest + (*MintActorCertificateResponse)(nil), // 4: atelet.MintActorCertificateResponse + (*RunRequest)(nil), // 5: atelet.RunRequest + (*EgressGateway)(nil), // 6: atelet.EgressGateway + (*AssetFile)(nil), // 7: atelet.AssetFile + (*ArchAssets)(nil), // 8: atelet.ArchAssets + (*SandboxAssets)(nil), // 9: atelet.SandboxAssets + (*WorkloadSpec)(nil), // 10: atelet.WorkloadSpec + (*DurableDirVolume)(nil), // 11: atelet.DurableDirVolume + (*ExternalVolumeSource)(nil), // 12: atelet.ExternalVolumeSource + (*ActorMetadataItem)(nil), // 13: atelet.ActorMetadataItem + (*ActorMetadataDataSource)(nil), // 14: atelet.ActorMetadataDataSource + (*SystemInfoDataSource)(nil), // 15: atelet.SystemInfoDataSource + (*SystemInfoVolume)(nil), // 16: atelet.SystemInfoVolume + (*Volume)(nil), // 17: atelet.Volume + (*VolumeMount)(nil), // 18: atelet.VolumeMount + (*Container)(nil), // 19: atelet.Container + (*EnvEntry)(nil), // 20: atelet.EnvEntry + (*Readyz)(nil), // 21: atelet.Readyz + (*HTTPGetAction)(nil), // 22: atelet.HTTPGetAction + (*RunResponse)(nil), // 23: atelet.RunResponse + (*LocalCheckpointConfiguration)(nil), // 24: atelet.LocalCheckpointConfiguration + (*ExternalCheckpointConfiguration)(nil), // 25: atelet.ExternalCheckpointConfiguration + (*CheckpointRequest)(nil), // 26: atelet.CheckpointRequest + (*CheckpointResponse)(nil), // 27: atelet.CheckpointResponse + (*UploadPausedCheckpointRequest)(nil), // 28: atelet.UploadPausedCheckpointRequest + (*UploadPausedCheckpointResponse)(nil), // 29: atelet.UploadPausedCheckpointResponse + (*RestoreRequest)(nil), // 30: atelet.RestoreRequest + (*RestoreResponse)(nil), // 31: atelet.RestoreResponse + nil, // 32: atelet.ArchAssets.FilesEntry + nil, // 33: atelet.SandboxAssets.AssetsEntry + nil, // 34: atelet.ExternalVolumeSource.VolumeContextEntry } var file_atelet_proto_depIdxs = []int32{ - 9, // 0: atelet.RunRequest.spec:type_name -> atelet.WorkloadSpec - 8, // 1: atelet.RunRequest.sandbox_assets:type_name -> atelet.SandboxAssets - 5, // 2: atelet.RunRequest.egress_gateway:type_name -> atelet.EgressGateway - 30, // 3: atelet.ArchAssets.files:type_name -> atelet.ArchAssets.FilesEntry - 31, // 4: atelet.SandboxAssets.assets:type_name -> atelet.SandboxAssets.AssetsEntry - 17, // 5: atelet.WorkloadSpec.containers:type_name -> atelet.Container - 15, // 6: atelet.WorkloadSpec.volumes:type_name -> atelet.Volume - 32, // 7: atelet.ExternalVolumeSource.volume_context:type_name -> atelet.ExternalVolumeSource.VolumeContextEntry - 12, // 8: atelet.SystemInfoDataSource.actor_identity:type_name -> atelet.ActorIdentityDataSource - 13, // 9: atelet.SystemInfoVolume.data_sources:type_name -> atelet.SystemInfoDataSource - 10, // 10: atelet.Volume.durable_dir:type_name -> atelet.DurableDirVolume - 11, // 11: atelet.Volume.external:type_name -> atelet.ExternalVolumeSource - 14, // 12: atelet.Volume.system_info:type_name -> atelet.SystemInfoVolume - 18, // 13: atelet.Container.env:type_name -> atelet.EnvEntry - 19, // 14: atelet.Container.readyz:type_name -> atelet.Readyz - 16, // 15: atelet.Container.volume_mounts:type_name -> atelet.VolumeMount - 20, // 16: atelet.Readyz.http_get:type_name -> atelet.HTTPGetAction - 9, // 17: atelet.CheckpointRequest.spec:type_name -> atelet.WorkloadSpec - 0, // 18: atelet.CheckpointRequest.type:type_name -> atelet.CheckpointType - 22, // 19: atelet.CheckpointRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration - 23, // 20: atelet.CheckpointRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration - 1, // 21: atelet.CheckpointRequest.scope:type_name -> atelet.SnapshotScope - 1, // 22: atelet.UploadPausedCheckpointRequest.desired_scope:type_name -> atelet.SnapshotScope - 9, // 23: atelet.RestoreRequest.spec:type_name -> atelet.WorkloadSpec - 0, // 24: atelet.RestoreRequest.type:type_name -> atelet.CheckpointType - 22, // 25: atelet.RestoreRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration - 23, // 26: atelet.RestoreRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration - 1, // 27: atelet.RestoreRequest.scope:type_name -> atelet.SnapshotScope - 5, // 28: atelet.RestoreRequest.egress_gateway:type_name -> atelet.EgressGateway - 6, // 29: atelet.ArchAssets.FilesEntry.value:type_name -> atelet.AssetFile - 7, // 30: atelet.SandboxAssets.AssetsEntry.value:type_name -> atelet.ArchAssets - 2, // 31: atelet.CredentialBroker.MintActorCertificate:input_type -> atelet.MintActorCertificateRequest - 4, // 32: atelet.AteomHerder.Run:input_type -> atelet.RunRequest - 24, // 33: atelet.AteomHerder.Checkpoint:input_type -> atelet.CheckpointRequest - 28, // 34: atelet.AteomHerder.Restore:input_type -> atelet.RestoreRequest - 26, // 35: atelet.AteomHerder.UploadPausedCheckpoint:input_type -> atelet.UploadPausedCheckpointRequest - 3, // 36: atelet.CredentialBroker.MintActorCertificate:output_type -> atelet.MintActorCertificateResponse - 21, // 37: atelet.AteomHerder.Run:output_type -> atelet.RunResponse - 25, // 38: atelet.AteomHerder.Checkpoint:output_type -> atelet.CheckpointResponse - 29, // 39: atelet.AteomHerder.Restore:output_type -> atelet.RestoreResponse - 27, // 40: atelet.AteomHerder.UploadPausedCheckpoint:output_type -> atelet.UploadPausedCheckpointResponse - 36, // [36:41] is the sub-list for method output_type - 31, // [31:36] is the sub-list for method input_type - 31, // [31:31] is the sub-list for extension type_name - 31, // [31:31] is the sub-list for extension extendee - 0, // [0:31] is the sub-list for field type_name + 10, // 0: atelet.RunRequest.spec:type_name -> atelet.WorkloadSpec + 9, // 1: atelet.RunRequest.sandbox_assets:type_name -> atelet.SandboxAssets + 6, // 2: atelet.RunRequest.egress_gateway:type_name -> atelet.EgressGateway + 32, // 3: atelet.ArchAssets.files:type_name -> atelet.ArchAssets.FilesEntry + 33, // 4: atelet.SandboxAssets.assets:type_name -> atelet.SandboxAssets.AssetsEntry + 19, // 5: atelet.WorkloadSpec.containers:type_name -> atelet.Container + 17, // 6: atelet.WorkloadSpec.volumes:type_name -> atelet.Volume + 34, // 7: atelet.ExternalVolumeSource.volume_context:type_name -> atelet.ExternalVolumeSource.VolumeContextEntry + 0, // 8: atelet.ActorMetadataItem.field:type_name -> atelet.ActorMetadataField + 13, // 9: atelet.ActorMetadataDataSource.items:type_name -> atelet.ActorMetadataItem + 14, // 10: atelet.SystemInfoDataSource.actor_metadata:type_name -> atelet.ActorMetadataDataSource + 15, // 11: atelet.SystemInfoVolume.data_sources:type_name -> atelet.SystemInfoDataSource + 11, // 12: atelet.Volume.durable_dir:type_name -> atelet.DurableDirVolume + 12, // 13: atelet.Volume.external:type_name -> atelet.ExternalVolumeSource + 16, // 14: atelet.Volume.system_info:type_name -> atelet.SystemInfoVolume + 20, // 15: atelet.Container.env:type_name -> atelet.EnvEntry + 21, // 16: atelet.Container.readyz:type_name -> atelet.Readyz + 18, // 17: atelet.Container.volume_mounts:type_name -> atelet.VolumeMount + 22, // 18: atelet.Readyz.http_get:type_name -> atelet.HTTPGetAction + 10, // 19: atelet.CheckpointRequest.spec:type_name -> atelet.WorkloadSpec + 1, // 20: atelet.CheckpointRequest.type:type_name -> atelet.CheckpointType + 24, // 21: atelet.CheckpointRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration + 25, // 22: atelet.CheckpointRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration + 2, // 23: atelet.CheckpointRequest.scope:type_name -> atelet.SnapshotScope + 2, // 24: atelet.UploadPausedCheckpointRequest.desired_scope:type_name -> atelet.SnapshotScope + 10, // 25: atelet.RestoreRequest.spec:type_name -> atelet.WorkloadSpec + 1, // 26: atelet.RestoreRequest.type:type_name -> atelet.CheckpointType + 24, // 27: atelet.RestoreRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration + 25, // 28: atelet.RestoreRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration + 2, // 29: atelet.RestoreRequest.scope:type_name -> atelet.SnapshotScope + 6, // 30: atelet.RestoreRequest.egress_gateway:type_name -> atelet.EgressGateway + 7, // 31: atelet.ArchAssets.FilesEntry.value:type_name -> atelet.AssetFile + 8, // 32: atelet.SandboxAssets.AssetsEntry.value:type_name -> atelet.ArchAssets + 3, // 33: atelet.CredentialBroker.MintActorCertificate:input_type -> atelet.MintActorCertificateRequest + 5, // 34: atelet.AteomHerder.Run:input_type -> atelet.RunRequest + 26, // 35: atelet.AteomHerder.Checkpoint:input_type -> atelet.CheckpointRequest + 30, // 36: atelet.AteomHerder.Restore:input_type -> atelet.RestoreRequest + 28, // 37: atelet.AteomHerder.UploadPausedCheckpoint:input_type -> atelet.UploadPausedCheckpointRequest + 4, // 38: atelet.CredentialBroker.MintActorCertificate:output_type -> atelet.MintActorCertificateResponse + 23, // 39: atelet.AteomHerder.Run:output_type -> atelet.RunResponse + 27, // 40: atelet.AteomHerder.Checkpoint:output_type -> atelet.CheckpointResponse + 31, // 41: atelet.AteomHerder.Restore:output_type -> atelet.RestoreResponse + 29, // 42: atelet.AteomHerder.UploadPausedCheckpoint:output_type -> atelet.UploadPausedCheckpointResponse + 38, // [38:43] is the sub-list for method output_type + 33, // [33:38] is the sub-list for method input_type + 33, // [33:33] is the sub-list for extension type_name + 33, // [33:33] is the sub-list for extension extendee + 0, // [0:33] is the sub-list for field type_name } func init() { file_atelet_proto_init() } @@ -2259,19 +2378,19 @@ func file_atelet_proto_init() { return } file_atelet_proto_msgTypes[2].OneofWrappers = []any{} - file_atelet_proto_msgTypes[11].OneofWrappers = []any{ - (*SystemInfoDataSource_ActorIdentity)(nil), + file_atelet_proto_msgTypes[12].OneofWrappers = []any{ + (*SystemInfoDataSource_ActorMetadata)(nil), } - file_atelet_proto_msgTypes[13].OneofWrappers = []any{ + file_atelet_proto_msgTypes[14].OneofWrappers = []any{ (*Volume_DurableDir)(nil), (*Volume_External)(nil), (*Volume_SystemInfo)(nil), } - file_atelet_proto_msgTypes[22].OneofWrappers = []any{ + file_atelet_proto_msgTypes[23].OneofWrappers = []any{ (*CheckpointRequest_LocalConfig)(nil), (*CheckpointRequest_ExternalConfig)(nil), } - file_atelet_proto_msgTypes[26].OneofWrappers = []any{ + file_atelet_proto_msgTypes[27].OneofWrappers = []any{ (*RestoreRequest_LocalConfig)(nil), (*RestoreRequest_ExternalConfig)(nil), } @@ -2280,8 +2399,8 @@ func file_atelet_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_atelet_proto_rawDesc), len(file_atelet_proto_rawDesc)), - NumEnums: 2, - NumMessages: 31, + NumEnums: 3, + NumMessages: 32, NumExtensions: 0, NumServices: 2, }, diff --git a/internal/proto/ateletpb/atelet.proto b/internal/proto/ateletpb/atelet.proto index 83d00a659..d6524da7f 100644 --- a/internal/proto/ateletpb/atelet.proto +++ b/internal/proto/ateletpb/atelet.proto @@ -135,21 +135,36 @@ message ExternalVolumeSource { map volume_context = 3; } -// ActorIdentityDataSource writes the actor's name to a file at the given -// path, relative to the root of the enclosing system-info volume. -message ActorIdentityDataSource { - string path = 1; +// ActorMetadataField selects one identity field of the actor. +enum ActorMetadataField { + ACTOR_METADATA_FIELD_UNSPECIFIED = 0; + ACTOR_METADATA_FIELD_NAME = 1; + ACTOR_METADATA_FIELD_ATESPACE = 2; + ACTOR_METADATA_FIELD_UID = 3; +} + +// ActorMetadataItem projects one actor identity field to one file at the +// given path, relative to the root of the enclosing system-info volume. +message ActorMetadataItem { + ActorMetadataField field = 1; + string path = 2; +} + +// ActorMetadataDataSource projects the actor's identity fields to files, one +// per item. Values are written raw with no trailing newline. +message ActorMetadataDataSource { + repeated ActorMetadataItem items = 1; } message SystemInfoDataSource { oneof data_source { - ActorIdentityDataSource actor_identity = 1; + ActorMetadataDataSource actor_metadata = 1; } } // SystemInfoVolume is a read-only volume whose files are generated by atelet -// on every Run/Restore, so they carry per-actor values even after a restore -// from the golden snapshot. +// on every Run/Restore, so they carry the values of the actor actually being +// started, whatever checkpointed state it boots from. message SystemInfoVolume { repeated SystemInfoDataSource data_sources = 1; } diff --git a/manifests/ate-install/generated/ate.dev_actortemplates.yaml b/manifests/ate-install/generated/ate.dev_actortemplates.yaml index f3e338ff3..1b0128c41 100644 --- a/manifests/ate-install/generated/ate.dev_actortemplates.yaml +++ b/manifests/ate-install/generated/ate.dev_actortemplates.yaml @@ -351,6 +351,10 @@ spec: description: |- DataSources is the list of data sources to place within the SystemInfo volume. + + At most one actorMetadata entry may appear; this is what keeps file + paths unique across the whole volume (uniqueness within the entry is + enforced on its items). items: description: |- SystemInfoDataSource is a container allowing you to pick a particular @@ -358,43 +362,78 @@ spec: Exactly one member must be set. properties: - actorIdentity: + actorMetadata: description: |- - ActorIdentityDataSource is a SystemInfo volume data source that writes the - actor's ID to a file. + ActorMetadataDataSource is a SystemInfo volume data source that projects the + actor's identity fields (name, atespace, uid) to files, one per item — + analogous to the Kubernetes downwardAPI volume. Values are written raw with + no trailing newline, and are fixed for the actor's lifetime across + suspend/resume/migration. properties: - path: + items: description: |- - Relative path from the root of the SystemInfo volume that the actor - identity file should be written. Must be a clean relative Unix path: - must not start or end with '/', and contain no ':', '..', '.', '//', - or control characters. - maxLength: 255 - minLength: 1 - type: string + Items is the list of fields to project and the file path each is + written to. + items: + description: ActorMetadataItem projects one + actor identity field to one file. + properties: + field: + description: Field selects which identity + field to project. + enum: + - name + - atespace + - uid + type: string + path: + description: |- + Relative path from the root of the SystemInfo volume at which the + field's value is written. Must be a clean relative Unix path: must not + start or end with '/', and contain no ':', '..', '.', '//', or control + characters. + maxLength: 255 + minLength: 1 + type: string + x-kubernetes-validations: + - message: 'path must be a clean relative + Unix path: must not start or end with + ''/'', and contain no '':'', ''..'', + ''.'', ''//'', or control characters' + rule: '!self.startsWith(''/'') && !self.endsWith(''/'') + && !self.contains(''//'') && !self.contains('':'') + && !self.matches(''[\x00-\x1f\x7f]'') + && !self.matches(''(^|/)[.][.]?(/|$)'')' + required: + - field + - path + type: object + maxItems: 8 + minItems: 1 + type: array x-kubernetes-validations: - - message: 'path must be a clean relative Unix - path: must not start or end with ''/'', and - contain no '':'', ''..'', ''.'', ''//'', or - control characters' - rule: '!self.startsWith(''/'') && !self.endsWith(''/'') - && !self.contains(''//'') && !self.contains('':'') - && !self.matches(''[\x00-\x1f\x7f]'') && !self.matches(''(^|/)[.][.]?(/|$)'')' + - message: items must not project the same field + twice + rule: self.all(x, self.exists_one(y, y.field + == x.field)) + - message: items must not contain duplicate paths + rule: self.all(x, self.exists_one(y, y.path + == x.path)) required: - - path + - items type: object type: object x-kubernetes-validations: - - message: exactly one of the fields in [actorIdentity] + - message: exactly one of the fields in [actorMetadata] must be set - rule: '[has(self.actorIdentity)].filter(x,x==true).size() + rule: '[has(self.actorMetadata)].filter(x,x==true).size() == 1' maxItems: 32 type: array x-kubernetes-validations: - - message: dataSources must not contain duplicate paths - rule: self.all(x, !has(x.actorIdentity) || self.exists_one(y, - has(y.actorIdentity) && y.actorIdentity.path == x.actorIdentity.path)) + - message: dataSources must contain at most one actorMetadata + entry + rule: self.filter(x, has(x.actorMetadata)).size() <= 1 type: object required: - name diff --git a/pkg/api/v1alpha1/actortemplate_types.go b/pkg/api/v1alpha1/actortemplate_types.go index daa065607..a0239caaa 100644 --- a/pkg/api/v1alpha1/actortemplate_types.go +++ b/pkg/api/v1alpha1/actortemplate_types.go @@ -45,13 +45,34 @@ type ExternalVolumeTemplate struct { StorageClassName string `json:"storageClassName"` } -// ActorIdentityDataSource is a SystemInfo volume data source that writes the -// actor's ID to a file. -type ActorIdentityDataSource struct { - // Relative path from the root of the SystemInfo volume that the actor - // identity file should be written. Must be a clean relative Unix path: - // must not start or end with '/', and contain no ':', '..', '.', '//', - // or control characters. +// ActorMetadataField selects one identity field of the actor, following the +// resource identity model (see docs/api-style-guide.md#2-resource-naming-and-identity). +// +// +kubebuilder:validation:Enum=name;atespace;uid +type ActorMetadataField string + +const ( + // ActorMetadataFieldName is the actor's metadata.name, unique within its + // atespace. + ActorMetadataFieldName ActorMetadataField = "name" + // ActorMetadataFieldAtespace is the atespace the actor belongs to. + ActorMetadataFieldAtespace ActorMetadataField = "atespace" + // ActorMetadataFieldUID is the actor's server-generated UID, which + // distinguishes incarnations of the same (atespace, name). + ActorMetadataFieldUID ActorMetadataField = "uid" +) + +// ActorMetadataItem projects one actor identity field to one file. +type ActorMetadataItem struct { + // Field selects which identity field to project. + // + // +required + Field ActorMetadataField `json:"field"` + + // Relative path from the root of the SystemInfo volume at which the + // field's value is written. Must be a clean relative Unix path: must not + // start or end with '/', and contain no ':', '..', '.', '//', or control + // characters. // // +required // +kubebuilder:validation:MinLength=1 @@ -60,24 +81,46 @@ type ActorIdentityDataSource struct { Path string `json:"path"` } +// ActorMetadataDataSource is a SystemInfo volume data source that projects the +// actor's identity fields (name, atespace, uid) to files, one per item — +// analogous to the Kubernetes downwardAPI volume. Values are written raw with +// no trailing newline, and are fixed for the actor's lifetime across +// suspend/resume/migration. +type ActorMetadataDataSource struct { + // Items is the list of fields to project and the file path each is + // written to. + // + // +required + // +kubebuilder:validation:MinItems=1 + // +kubebuilder:validation:MaxItems=8 + // +kubebuilder:validation:XValidation:rule="self.all(x, self.exists_one(y, y.field == x.field))",message="items must not project the same field twice" + // +kubebuilder:validation:XValidation:rule="self.all(x, self.exists_one(y, y.path == x.path))",message="items must not contain duplicate paths" + Items []ActorMetadataItem `json:"items"` +} + // SystemInfoDataSource is a container allowing you to pick a particular // SystemInfo data source. // // Exactly one member must be set. // -// +kubebuilder:validation:ExactlyOneOf={actorIdentity} +// +kubebuilder:validation:ExactlyOneOf={actorMetadata} type SystemInfoDataSource struct { - ActorIdentity *ActorIdentityDataSource `json:"actorIdentity,omitempty"` + ActorMetadata *ActorMetadataDataSource `json:"actorMetadata,omitempty"` } -// Represents a system information volume, which provides files containing the -// actor ID, an actor identity JWT, and an actor identity certificate. +// Represents a system information volume, which provides files containing +// substrate-generated per-actor data such as the actor's identity fields +// (and, in the future, identity JWTs and certificates). type SystemInfoVolumeSource struct { // DataSources is the list of data sources to place within the SystemInfo // volume. // + // At most one actorMetadata entry may appear; this is what keeps file + // paths unique across the whole volume (uniqueness within the entry is + // enforced on its items). + // // +kubebuilder:validation:MaxItems=32 - // +kubebuilder:validation:XValidation:rule="self.all(x, !has(x.actorIdentity) || self.exists_one(y, has(y.actorIdentity) && y.actorIdentity.path == x.actorIdentity.path))",message="dataSources must not contain duplicate paths" + // +kubebuilder:validation:XValidation:rule="self.filter(x, has(x.actorMetadata)).size() <= 1",message="dataSources must contain at most one actorMetadata entry" DataSources []SystemInfoDataSource `json:"dataSources,omitempty"` } diff --git a/pkg/api/v1alpha1/actortemplate_validation_test.go b/pkg/api/v1alpha1/actortemplate_validation_test.go index 1c3baacd9..af5d0e07d 100644 --- a/pkg/api/v1alpha1/actortemplate_validation_test.go +++ b/pkg/api/v1alpha1/actortemplate_validation_test.go @@ -702,7 +702,7 @@ func TestActorTemplateValidation(t *testing.T) { wantErr: true, errMsg: "exactly one of the fields in [durableDir externalVolumeTemplate systemInfo] must be set", }, { - name: "Volumes: SystemInfo volume with an ActorIdentity data source is valid", + name: "Volumes: SystemInfo volume projecting all actor metadata fields is valid", mutate: func(at *ActorTemplate) { at.Spec.Volumes = []Volume{ { @@ -710,7 +710,13 @@ func TestActorTemplateValidation(t *testing.T) { VolumeSource: VolumeSource{ SystemInfo: &SystemInfoVolumeSource{ DataSources: []SystemInfoDataSource{ - {ActorIdentity: &ActorIdentityDataSource{Path: "actor-id"}}, + {ActorMetadata: &ActorMetadataDataSource{ + Items: []ActorMetadataItem{ + {Field: ActorMetadataFieldName, Path: "actor-name"}, + {Field: ActorMetadataFieldAtespace, Path: "atespace"}, + {Field: ActorMetadataFieldUID, Path: "identity/actor-uid"}, + }, + }}, }, }, }, @@ -722,7 +728,23 @@ func TestActorTemplateValidation(t *testing.T) { }, wantErr: false, }, { - name: "Volumes: SystemInfo data source with nested relative path is valid", + name: "Volumes: SystemInfo data source with no member set is invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{{}}, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "exactly one of the fields in [actorMetadata] must be set", + }, { + name: "Volumes: SystemInfo actorMetadata with no items is invalid", mutate: func(at *ActorTemplate) { at.Spec.Volumes = []Volume{ { @@ -730,35 +752,37 @@ func TestActorTemplateValidation(t *testing.T) { VolumeSource: VolumeSource{ SystemInfo: &SystemInfoVolumeSource{ DataSources: []SystemInfoDataSource{ - {ActorIdentity: &ActorIdentityDataSource{Path: "identity/actor-id"}}, + {ActorMetadata: &ActorMetadataDataSource{Items: []ActorMetadataItem{}}}, }, }, }, }, } - at.Spec.Containers[0].VolumeMounts = []VolumeMount{ - {Name: "system-info", MountPath: "/run/ate"}, - } }, - wantErr: false, + wantErr: true, }, { - name: "Volumes: SystemInfo data source with no member set is invalid", + name: "Volumes: SystemInfo item with unknown field is invalid", mutate: func(at *ActorTemplate) { at.Spec.Volumes = []Volume{ { Name: "system-info", VolumeSource: VolumeSource{ SystemInfo: &SystemInfoVolumeSource{ - DataSources: []SystemInfoDataSource{{}}, + DataSources: []SystemInfoDataSource{ + {ActorMetadata: &ActorMetadataDataSource{ + Items: []ActorMetadataItem{ + {Field: ActorMetadataField("hostname"), Path: "hostname"}, + }, + }}, + }, }, }, }, } }, wantErr: true, - errMsg: "exactly one of the fields in [actorIdentity] must be set", }, { - name: "Volumes: SystemInfo data source with empty path is invalid", + name: "Volumes: SystemInfo item with empty path is invalid", mutate: func(at *ActorTemplate) { at.Spec.Volumes = []Volume{ { @@ -766,7 +790,11 @@ func TestActorTemplateValidation(t *testing.T) { VolumeSource: VolumeSource{ SystemInfo: &SystemInfoVolumeSource{ DataSources: []SystemInfoDataSource{ - {ActorIdentity: &ActorIdentityDataSource{Path: ""}}, + {ActorMetadata: &ActorMetadataDataSource{ + Items: []ActorMetadataItem{ + {Field: ActorMetadataFieldName, Path: ""}, + }, + }}, }, }, }, @@ -775,7 +803,7 @@ func TestActorTemplateValidation(t *testing.T) { }, wantErr: true, }, { - name: "Volumes: SystemInfo data source with absolute path is invalid", + name: "Volumes: SystemInfo item with absolute path is invalid", mutate: func(at *ActorTemplate) { at.Spec.Volumes = []Volume{ { @@ -783,7 +811,11 @@ func TestActorTemplateValidation(t *testing.T) { VolumeSource: VolumeSource{ SystemInfo: &SystemInfoVolumeSource{ DataSources: []SystemInfoDataSource{ - {ActorIdentity: &ActorIdentityDataSource{Path: "/etc/actor-id"}}, + {ActorMetadata: &ActorMetadataDataSource{ + Items: []ActorMetadataItem{ + {Field: ActorMetadataFieldName, Path: "/etc/actor-name"}, + }, + }}, }, }, }, @@ -793,7 +825,7 @@ func TestActorTemplateValidation(t *testing.T) { wantErr: true, errMsg: "path must be a clean relative Unix path", }, { - name: "Volumes: SystemInfo data source with path traversal is invalid", + name: "Volumes: SystemInfo item with path traversal is invalid", mutate: func(at *ActorTemplate) { at.Spec.Volumes = []Volume{ { @@ -801,7 +833,11 @@ func TestActorTemplateValidation(t *testing.T) { VolumeSource: VolumeSource{ SystemInfo: &SystemInfoVolumeSource{ DataSources: []SystemInfoDataSource{ - {ActorIdentity: &ActorIdentityDataSource{Path: "../escape"}}, + {ActorMetadata: &ActorMetadataDataSource{ + Items: []ActorMetadataItem{ + {Field: ActorMetadataFieldName, Path: "../escape"}, + }, + }}, }, }, }, @@ -811,7 +847,53 @@ func TestActorTemplateValidation(t *testing.T) { wantErr: true, errMsg: "path must be a clean relative Unix path", }, { - name: "Volumes: SystemInfo data sources with duplicate paths are invalid", + name: "Volumes: SystemInfo items projecting the same field twice are invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ActorMetadata: &ActorMetadataDataSource{ + Items: []ActorMetadataItem{ + {Field: ActorMetadataFieldName, Path: "actor-name"}, + {Field: ActorMetadataFieldName, Path: "name-again"}, + }, + }}, + }, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "items must not project the same field twice", + }, { + name: "Volumes: SystemInfo items with duplicate paths are invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ActorMetadata: &ActorMetadataDataSource{ + Items: []ActorMetadataItem{ + {Field: ActorMetadataFieldName, Path: "actor-name"}, + {Field: ActorMetadataFieldUID, Path: "actor-name"}, + }, + }}, + }, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "items must not contain duplicate paths", + }, { + name: "Volumes: SystemInfo with two actorMetadata entries is invalid", mutate: func(at *ActorTemplate) { at.Spec.Volumes = []Volume{ { @@ -819,8 +901,12 @@ func TestActorTemplateValidation(t *testing.T) { VolumeSource: VolumeSource{ SystemInfo: &SystemInfoVolumeSource{ DataSources: []SystemInfoDataSource{ - {ActorIdentity: &ActorIdentityDataSource{Path: "actor-id"}}, - {ActorIdentity: &ActorIdentityDataSource{Path: "actor-id"}}, + {ActorMetadata: &ActorMetadataDataSource{ + Items: []ActorMetadataItem{{Field: ActorMetadataFieldName, Path: "actor-name"}}, + }}, + {ActorMetadata: &ActorMetadataDataSource{ + Items: []ActorMetadataItem{{Field: ActorMetadataFieldUID, Path: "actor-uid"}}, + }}, }, }, }, @@ -828,7 +914,7 @@ func TestActorTemplateValidation(t *testing.T) { } }, wantErr: true, - errMsg: "dataSources must not contain duplicate paths", + errMsg: "dataSources must contain at most one actorMetadata entry", }, { name: "Volumes: DurableDir MountPath with nested absolute path is valid", mutate: func(at *ActorTemplate) { diff --git a/pkg/api/v1alpha1/zz_generated.deepcopy.go b/pkg/api/v1alpha1/zz_generated.deepcopy.go index 1652e2597..9b329e607 100644 --- a/pkg/api/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/api/v1alpha1/zz_generated.deepcopy.go @@ -25,16 +25,36 @@ import ( ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ActorIdentityDataSource) DeepCopyInto(out *ActorIdentityDataSource) { +func (in *ActorMetadataDataSource) DeepCopyInto(out *ActorMetadataDataSource) { *out = *in + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ActorMetadataItem, len(*in)) + copy(*out, *in) + } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActorIdentityDataSource. -func (in *ActorIdentityDataSource) DeepCopy() *ActorIdentityDataSource { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActorMetadataDataSource. +func (in *ActorMetadataDataSource) DeepCopy() *ActorMetadataDataSource { if in == nil { return nil } - out := new(ActorIdentityDataSource) + out := new(ActorMetadataDataSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ActorMetadataItem) DeepCopyInto(out *ActorMetadataItem) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActorMetadataItem. +func (in *ActorMetadataItem) DeepCopy() *ActorMetadataItem { + if in == nil { + return nil + } + out := new(ActorMetadataItem) in.DeepCopyInto(out) return out } @@ -490,10 +510,10 @@ func (in *SnapshotsConfig) DeepCopy() *SnapshotsConfig { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SystemInfoDataSource) DeepCopyInto(out *SystemInfoDataSource) { *out = *in - if in.ActorIdentity != nil { - in, out := &in.ActorIdentity, &out.ActorIdentity - *out = new(ActorIdentityDataSource) - **out = **in + if in.ActorMetadata != nil { + in, out := &in.ActorMetadata, &out.ActorMetadata + *out = new(ActorMetadataDataSource) + (*in).DeepCopyInto(*out) } } From 4c34cdc40bf706e80f341c250747ad116948ae04 Mon Sep 17 00:00:00 2001 From: Max Thompson Date: Mon, 10 Aug 2026 17:03:19 -0700 Subject: [PATCH 5/7] microvm: mount system-info volumes over a read-only virtio-fs share SystemInfo volumes were gVisor-only; per the #802 discussion, micro-VM support lands with Part 1 rather than as a follow-up. The mechanism mirrors the durable-dir share: - ateom proto: containers carry system_info_volume_mounts (volume name + mount path), populated by atelet's buildAteomWorkloadSpec. - ateom-microvm serves ateompath.SystemInfoVolumeRootsDir(actorUID) over a third virtiofsd (cache=auto: atelet rewrites the contents underneath the guest on every restore). The agent mounts the share at sandbox creation, and each declaring container gets a READ-ONLY bind from the share's per-volume subdirectory to its declared mount path. - Restore restarts the share's virtiofsd and rewrites its vhost-user socket in the snapshot's VM config (matched by fs tag). Nothing is restored from the snapshot itself: atelet has already regenerated the files with the resumed actor's values, which is the point of system-info volumes. - Checkpoint deliberately ignores the share: the volume roots live outside the durable-dir tree precisely so the durable tar can never capture generated identity data. - Replace the stale "KNOWN GAP" comment in spec.go: dropping host-path binds in the kata spec shaper is fine because volumes reach micro-VM containers via the shares, not spec.Mounts. --- cmd/atelet/main.go | 13 +- cmd/atelet/main_test.go | 9 +- cmd/ateom-microvm/checkpoint.go | 7 +- cmd/ateom-microvm/durable.go | 10 +- .../internal/kata/overlay_linux.go | 32 ++- cmd/ateom-microvm/internal/kata/restore.go | 6 + cmd/ateom-microvm/restore.go | 21 +- cmd/ateom-microvm/run.go | 63 +++-- cmd/ateom-microvm/spec.go | 13 +- cmd/ateom-microvm/systeminfo.go | 117 ++++++++++ internal/proto/ateompb/ateom.pb.go | 215 ++++++++++++------ internal/proto/ateompb/ateom.proto | 16 ++ 12 files changed, 418 insertions(+), 104 deletions(-) create mode 100644 cmd/ateom-microvm/systeminfo.go diff --git a/cmd/atelet/main.go b/cmd/atelet/main.go index 7f9465176..6356f7120 100644 --- a/cmd/atelet/main.go +++ b/cmd/atelet/main.go @@ -1513,27 +1513,38 @@ func (s *AteomHerder) dialAteom(ctx context.Context, targetAteomUid string) (ate // the ateom-facing one. func buildAteomWorkloadSpec(spec *ateletpb.WorkloadSpec) *ateompb.WorkloadSpec { ddVolumes := make(map[string]bool) + siVolumes := make(map[string]bool) for _, vol := range spec.GetVolumes() { switch vol.GetSource().(type) { case *ateletpb.Volume_DurableDir: ddVolumes[vol.GetName()] = true + case *ateletpb.Volume_SystemInfo: + siVolumes[vol.GetName()] = true } } out := &ateompb.WorkloadSpec{} for _, ctr := range spec.GetContainers() { var ddMounts []*ateompb.DurableDirVolumeMount + var siMounts []*ateompb.SystemInfoVolumeMount for _, vm := range ctr.GetVolumeMounts() { - if ddVolumes[vm.GetName()] { + switch { + case ddVolumes[vm.GetName()]: ddMounts = append(ddMounts, &ateompb.DurableDirVolumeMount{ VolumeName: vm.GetName(), MountPath: vm.GetMountPath(), }) + case siVolumes[vm.GetName()]: + siMounts = append(siMounts, &ateompb.SystemInfoVolumeMount{ + VolumeName: vm.GetName(), + MountPath: vm.GetMountPath(), + }) } } out.Containers = append(out.Containers, &ateompb.Container{ Name: ctr.GetName(), DurableDirVolumeMounts: ddMounts, + SystemInfoVolumeMounts: siMounts, Readyz: toAteomReadyz(ctr.GetReadyz()), }) } diff --git a/cmd/atelet/main_test.go b/cmd/atelet/main_test.go index 1ff751e70..4eed97933 100644 --- a/cmd/atelet/main_test.go +++ b/cmd/atelet/main_test.go @@ -760,6 +760,7 @@ func TestBuildAteomWorkloadSpecForwardsDurableDirMounts(t *testing.T) { {Name: "data", Source: &ateletpb.Volume_DurableDir{DurableDir: &ateletpb.DurableDirVolume{}}}, {Name: "cache", Source: &ateletpb.Volume_DurableDir{DurableDir: &ateletpb.DurableDirVolume{}}}, {Name: "scratch", Source: &ateletpb.Volume_External{External: &ateletpb.ExternalVolumeSource{}}}, + {Name: "system-info", Source: &ateletpb.Volume_SystemInfo{SystemInfo: &ateletpb.SystemInfoVolume{}}}, }, Containers: []*ateletpb.Container{ { @@ -767,9 +768,10 @@ func TestBuildAteomWorkloadSpecForwardsDurableDirMounts(t *testing.T) { VolumeMounts: []*ateletpb.VolumeMount{ {Name: "data", MountPath: "/home/counter"}, {Name: "cache", MountPath: "/var/cache"}, - // Only durable-dir volumes cross to ateom; other volume - // types are mounted by atelet itself. + // External volumes do not cross to ateom; they are + // mounted by atelet itself. {Name: "scratch", MountPath: "/scratch"}, + {Name: "system-info", MountPath: "/run/ate"}, }, }, { @@ -791,6 +793,9 @@ func TestBuildAteomWorkloadSpecForwardsDurableDirMounts(t *testing.T) { {VolumeName: "data", MountPath: "/home/counter"}, {VolumeName: "cache", MountPath: "/var/cache"}, }, + SystemInfoVolumeMounts: []*ateompb.SystemInfoVolumeMount{ + {VolumeName: "system-info", MountPath: "/run/ate"}, + }, }, { Name: "sidecar", diff --git a/cmd/ateom-microvm/checkpoint.go b/cmd/ateom-microvm/checkpoint.go index 78244df21..0ea41672d 100644 --- a/cmd/ateom-microvm/checkpoint.go +++ b/cmd/ateom-microvm/checkpoint.go @@ -295,9 +295,10 @@ func (s *AteomService) teardownActor(ctx context.Context, id string, ra *running _ = ra.chCmd.Process.Kill() _, _ = ra.chCmd.Process.Wait() } - // Kill the virtiofsds (after CH, their only client): the overlay RO lower's - // and, when the actor has durable-dir volumes, the writable share's. - for _, cmd := range []*exec.Cmd{ra.vfsdCmd, ra.durableVfsdCmd} { + // Kill the virtiofsds (after CH, their only client): the overlay RO + // lower's and, when the actor declares such volumes, the writable + // durable share's and the read-only system-info share's. + for _, cmd := range []*exec.Cmd{ra.vfsdCmd, ra.durableVfsdCmd, ra.systemInfoVfsdCmd} { if cmd != nil && cmd.Process != nil { _ = cmd.Process.Kill() _, _ = cmd.Process.Wait() diff --git a/cmd/ateom-microvm/durable.go b/cmd/ateom-microvm/durable.go index a28a2186a..c8d481858 100644 --- a/cmd/ateom-microvm/durable.go +++ b/cmd/ateom-microvm/durable.go @@ -88,16 +88,20 @@ func durableMounts(mounts []*ateompb.DurableDirVolumeMount) []specs.Mount { } // workloadSpec returns the OCI spec to start a container's overlay workload -// with: the prepared spec, plus a bind for each durable-dir volume it mounts. +// with: the prepared spec, plus a bind for each durable-dir volume it mounts +// (writable) and each system-info volume it mounts (read-only). // // The spec is copied rather than mutated so the bundle's on-disk config.json and // the carrier's view stay as prepared — only the workload sees the binds. func workloadSpec(c actorContainer) *specs.Spec { - if len(c.durableMounts) == 0 { + if len(c.durableMounts) == 0 && len(c.systemInfoMounts) == 0 { return c.spec } spec := *c.spec - spec.Mounts = append(append([]specs.Mount(nil), c.spec.Mounts...), durableMounts(c.durableMounts)...) + mounts := append([]specs.Mount(nil), c.spec.Mounts...) + mounts = append(mounts, durableMounts(c.durableMounts)...) + mounts = append(mounts, systemInfoMounts(c.systemInfoMounts)...) + spec.Mounts = mounts return &spec } diff --git a/cmd/ateom-microvm/internal/kata/overlay_linux.go b/cmd/ateom-microvm/internal/kata/overlay_linux.go index 741a1a446..e7022ee99 100644 --- a/cmd/ateom-microvm/internal/kata/overlay_linux.go +++ b/cmd/ateom-microvm/internal/kata/overlay_linux.go @@ -54,6 +54,16 @@ const ( // volume's contents live at / and are bind-mounted // from there into the containers that declare the volume. guestDurableDir = "/run/ateom-durable" + + // SystemInfoFsTag is the virtio-fs tag for the actor's system-info share, + // served by a third virtiofsd. Contents are generated by atelet on the + // host on every Run/Restore; containers see them read-only. + SystemInfoFsTag = "ateSystemInfo" + // guestSystemInfoDir is where the agent mounts SystemInfoFsTag in the + // guest; each volume's contents live at / + // and are bind-mounted read-only into the containers that declare the + // volume. + guestSystemInfoDir = "/run/ateom-system-info" ) // GuestDurableVolumeDir is the in-guest path holding one durable volume's @@ -62,6 +72,13 @@ func GuestDurableVolumeDir(volumeName string) string { return guestDurableDir + "/" + volumeName } +// GuestSystemInfoVolumeDir is the in-guest path holding one system-info +// volume's contents, i.e. the bind source for that volume's container mount +// points. +func GuestSystemInfoVolumeDir(volumeName string) string { + return guestSystemInfoDir + "/" + volumeName +} + // SharedDir is the host directory virtiofsd serves into the guest as the RO base. // Its layout (/rootfs) is what find-paths re-opens by path on restore. func SharedDir(id string) string { @@ -216,9 +233,10 @@ func ReconstructSharedDirFromImage(ctx context.Context, bundleRootfs, restoreID, // CreateSandboxForActor creates the guest sandbox with the kataShared virtio-fs mount // (the RO base backing every container's rootfs). Mirrors kata startSandbox. // -// withDurableShare additionally mounts the writable durable-dir share, whose -// per-volume subdirectories the containers bind-mount at their declared paths. -func (a *AgentClient) CreateSandboxForActor(ctx context.Context, sandboxID, hostname string, withDurableShare bool) error { +// withDurableShare additionally mounts the writable durable-dir share, and +// withSystemInfoShare the system-info share; the per-volume subdirectories of +// each are what the containers bind-mount at their declared paths. +func (a *AgentClient) CreateSandboxForActor(ctx context.Context, sandboxID, hostname string, withDurableShare, withSystemInfoShare bool) error { storages := []*agentpb.Storage{{ Driver: virtioFSDriver, Source: FsTag, @@ -233,6 +251,14 @@ func (a *AgentClient) CreateSandboxForActor(ctx context.Context, sandboxID, host MountPoint: guestDurableDir, }) } + if withSystemInfoShare { + storages = append(storages, &agentpb.Storage{ + Driver: virtioFSDriver, + Source: SystemInfoFsTag, + Fstype: typeVirtioFS, + MountPoint: guestSystemInfoDir, + }) + } return a.CreateSandbox(ctx, &agentpb.CreateSandboxRequest{ Hostname: hostname, SandboxId: sandboxID, diff --git a/cmd/ateom-microvm/internal/kata/restore.go b/cmd/ateom-microvm/internal/kata/restore.go index 0b71bea9d..e3d54433a 100644 --- a/cmd/ateom-microvm/internal/kata/restore.go +++ b/cmd/ateom-microvm/internal/kata/restore.go @@ -35,3 +35,9 @@ func VsockSocketPath(id string) string { return filepath.Join(VMDir(id), "clh.so func DurableVirtiofsdSocketPath(id string) string { return filepath.Join(VMDir(id), "virtiofsd-durable.sock") } + +// SystemInfoVirtiofsdSocketPath is the vhost-user-fs socket for the actor's +// system-info share, served by a third virtiofsd alongside the others. +func SystemInfoVirtiofsdSocketPath(id string) string { + return filepath.Join(VMDir(id), "virtiofsd-system-info.sock") +} diff --git a/cmd/ateom-microvm/restore.go b/cmd/ateom-microvm/restore.go index 229640e58..f845dc746 100644 --- a/cmd/ateom-microvm/restore.go +++ b/cmd/ateom-microvm/restore.go @@ -236,6 +236,23 @@ func (s *AteomService) restoreFullScope(ctx context.Context, p actorBootParams, }() } + // Restart the system-info share's virtiofsd over the contents atelet + // regenerated for THIS restore: unlike the durable share, nothing is + // restored from the snapshot — the files already carry the resumed actor's + // own values, which is the point of system-info volumes. + var systemInfoVfsdCmd *exec.Cmd + if hasSystemInfoVolumes(containers) { + if systemInfoVfsdCmd, err = s.stageSystemInfoShare(ctx, rr, actorUID); err != nil { + return err + } + defer func() { + if retErr != nil && systemInfoVfsdCmd.Process != nil { + _ = systemInfoVfsdCmd.Process.Kill() + _, _ = systemInfoVfsdCmd.Process.Wait() + } + }() + } + // Networking: rebuild the per-activation veth + tap; the snapshot's virtio-net // is fd-backed, so CH needs fresh tap FDs (net_fds) on restore. if err := ateomnet.SetupActorNetwork(ctx, ateomnet.NetworkConfig{ @@ -342,7 +359,7 @@ func (s *AteomService) restoreFullScope(ctx context.Context, p actorBootParams, } ra := &runningActor{ - chCmd: chCmd, vfsdCmd: vfsdCmd, durableVfsdCmd: durableVfsdCmd, + chCmd: chCmd, vfsdCmd: vfsdCmd, durableVfsdCmd: durableVfsdCmd, systemInfoVfsdCmd: systemInfoVfsdCmd, apiSocket: apiSocket, baseID: srcID, restoreSourceDir: restoreDir, snapshotIsSelfContained: memMode == ch.MemRestoreEager, } @@ -432,6 +449,8 @@ func rewriteSnapshotSocketPaths(snapshotDir, id string) error { fm["socket"] = kata.VirtiofsdSocketPath(id) case kata.DurableFsTag: fm["socket"] = kata.DurableVirtiofsdSocketPath(id) + case kata.SystemInfoFsTag: + fm["socket"] = kata.SystemInfoVirtiofsdSocketPath(id) default: return fmt.Errorf("snapshot config %q has fs device with unknown tag %q", cfgPath, tag) } diff --git a/cmd/ateom-microvm/run.go b/cmd/ateom-microvm/run.go index 2b3dc406b..5a81a074d 100644 --- a/cmd/ateom-microvm/run.go +++ b/cmd/ateom-microvm/run.go @@ -66,6 +66,10 @@ type runningActor struct { // durable-dir volumes. nil when the actor declares none. Owned and torn down // exactly like vfsdCmd. durableVfsdCmd *exec.Cmd + // systemInfoVfsdCmd is the third virtiofsd, serving the actor's read-only + // system-info volumes. nil when the actor declares none. Owned and torn + // down exactly like vfsdCmd. + systemInfoVfsdCmd *exec.Cmd // apiSocket is the CH api-socket for this ateom-owned VMM. apiSocket string @@ -143,6 +147,9 @@ type actorContainer struct { // durableMounts are the durable-dir volumes this container mounts, and where // (see durable.go). Empty for containers that declare none. durableMounts []*ateompb.DurableDirVolumeMount + // systemInfoMounts are the system-info volumes this container mounts, and + // where (see systeminfo.go). Empty for containers that declare none. + systemInfoMounts []*ateompb.SystemInfoVolumeMount } // resolvedRuntime holds the concrete binary/config paths for a request, taken @@ -413,6 +420,23 @@ func (s *AteomService) coldBootActor(ctx context.Context, p actorBootParams) (re }() } + // System-info volumes (if any) share one read-only virtio-fs share, served + // by a third virtiofsd from the host directory atelet populated; each + // volume is a subdirectory of it. + systemInfo := hasSystemInfoVolumes(containers) + var systemInfoVfsdCmd *exec.Cmd + if systemInfo { + if systemInfoVfsdCmd, err = s.stageSystemInfoShare(ctx, rr, actorUID); err != nil { + return err + } + defer func() { + if retErr != nil && systemInfoVfsdCmd.Process != nil { + _ = systemInfoVfsdCmd.Process.Kill() + _, _ = systemInfoVfsdCmd.Process.Wait() + } + }() + } + // Launch a bare VMM (CH + api-socket); ateom owns this process for teardown. apiSocket := filepath.Join(kata.VMDir(actorUID), "clh-api.sock") chCmd, client, err := ch.LaunchVMM(ctx, ch.LaunchVMMOptions{ @@ -436,7 +460,7 @@ func (s *AteomService) coldBootActor(ctx context.Context, p actorBootParams) (re // writable upper is a guest tmpfs). serialLog is also read on a failed agent dial // below, so keep it here. serialLog := filepath.Join(kata.VMDir(actorUID), "serial.log") - vmCfg := buildVMConfig(actorUID, kernel, image, kparams, serialLog, memMiB, vcpus, durable) + vmCfg := buildVMConfig(actorUID, kernel, image, kparams, serialLog, memMiB, vcpus, durable, systemInfo) if err := client.CreateVM(ctx, vmCfg); err != nil { return fmt.Errorf("while creating VM: %w", err) } @@ -490,7 +514,7 @@ func (s *AteomService) coldBootActor(ctx context.Context, p actorBootParams) (re }() // Post-boot kata-agent setup: sandbox, guest networking, start each container. - if err := s.startActorContainers(ctx, ac, actorUID, vsockPath, ctrs, durable); err != nil { + if err := s.startActorContainers(ctx, ac, actorUID, vsockPath, ctrs, durable, systemInfo); err != nil { return err } @@ -499,7 +523,7 @@ func (s *AteomService) coldBootActor(ctx context.Context, p actorBootParams) (re return fmt.Errorf("while waiting for container readyz: %w", err) } - ra := &runningActor{chCmd: chCmd, vfsdCmd: vfsdCmd, durableVfsdCmd: durableVfsdCmd, apiSocket: apiSocket, baseID: actorUID, guestAgent: ac} + ra := &runningActor{chCmd: chCmd, vfsdCmd: vfsdCmd, durableVfsdCmd: durableVfsdCmd, systemInfoVfsdCmd: systemInfoVfsdCmd, apiSocket: apiSocket, baseID: actorUID, guestAgent: ac} if err := s.activateActorNetworking(p.actorRef.Atespace, p.actorRef.Name, egress); err != nil { return err } @@ -559,10 +583,11 @@ func (s *AteomService) buildActorContainers(actorUID string, containers []*ateom return nil, fmt.Errorf("while writing guest resolv.conf for %q: %w", cn, err) } ctrs[i] = actorContainer{ - name: cn, - bundleRootfs: bundleRootfs, - spec: spec, - durableMounts: c.GetDurableDirVolumeMounts(), + name: cn, + bundleRootfs: bundleRootfs, + spec: spec, + durableMounts: c.GetDurableDirVolumeMounts(), + systemInfoMounts: c.GetSystemInfoVolumeMounts(), } } return ctrs, nil @@ -621,7 +646,7 @@ func (s *AteomService) guestConfig(rr resolvedRuntime) (memMiB, vcpus int, kpara // // withDurable adds a second virtio-fs device for the actor's writable durable-dir // volumes (see durable.go), served by its own virtiofsd on the same PCI segment. -func buildVMConfig(id, kernel, image, kparams, serialLog string, memMiB, vcpus int, withDurable bool) ch.VmConfig { +func buildVMConfig(id, kernel, image, kparams, serialLog string, memMiB, vcpus int, withDurable, withSystemInfo bool) ch.VmConfig { console := "ttyS0" if runtime.GOARCH == "arm64" { console = "ttyAMA0" @@ -639,7 +664,7 @@ func buildVMConfig(id, kernel, image, kparams, serialLog string, memMiB, vcpus i Disks: []ch.DiskConfig{ {Path: image, Readonly: true, ImageType: "Raw", NumQueues: int32(vcpus), QueueSize: 1024}, }, - Fs: buildFsConfigs(id, withDurable), + Fs: buildFsConfigs(id, withDurable, withSystemInfo), Platform: &ch.PlatformConfig{NumPciSegments: 2}, Rng: &ch.RngConfig{Src: "/dev/urandom"}, Serial: &ch.ConsoleConfig{Mode: "File", File: serialLog}, @@ -648,9 +673,10 @@ func buildVMConfig(id, kernel, image, kparams, serialLog string, memMiB, vcpus i } // buildFsConfigs returns the VM's virtio-fs devices: the overlay RO lower's -// share, plus the writable durable-dir share when the actor has one. Both sit on -// PCI segment 1 (the segment buildVMConfig reserves for virtio-fs). -func buildFsConfigs(id string, withDurable bool) []ch.FsConfig { +// share, plus the writable durable-dir share and the read-only system-info +// share when the actor has them. All sit on PCI segment 1 (the segment +// buildVMConfig reserves for virtio-fs). +func buildFsConfigs(id string, withDurable, withSystemInfo bool) []ch.FsConfig { fs := []ch.FsConfig{{ Tag: kata.FsTag, Socket: kata.VirtiofsdSocketPath(id), NumQueues: 1, QueueSize: 1024, PciSegment: 1, @@ -661,6 +687,12 @@ func buildFsConfigs(id string, withDurable bool) []ch.FsConfig { NumQueues: 1, QueueSize: 1024, PciSegment: 1, }) } + if withSystemInfo { + fs = append(fs, ch.FsConfig{ + Tag: kata.SystemInfoFsTag, Socket: kata.SystemInfoVirtiofsdSocketPath(id), + NumQueues: 1, QueueSize: 1024, PciSegment: 1, + }) + } return fs } @@ -670,13 +702,14 @@ func buildFsConfigs(id string, withDurable bool) []ch.FsConfig { // container on its own overlay rootfs. On failure it dumps guest diagnostics. // // durable says the actor has durable-dir volumes: the sandbox then also mounts -// the writable durable share, and each container binds the volumes it declared. -func (s *AteomService) startActorContainers(ctx context.Context, ac *kata.AgentClient, id, vsockPath string, ctrs []actorContainer, durable bool) error { +// the writable durable share. systemInfo likewise mounts the read-only +// system-info share. Each container binds the volumes it declared. +func (s *AteomService) startActorContainers(ctx context.Context, ac *kata.AgentClient, id, vsockPath string, ctrs []actorContainer, durable, systemInfo bool) error { // Establish the agent sandbox + the kataShared virtio-fs mount (the RO base for // every container's overlay lower). All containers share it, so use the first // container's hostname. sbCtx, sbCancel := context.WithTimeout(ctx, 20*time.Second) - err := ac.CreateSandboxForActor(sbCtx, id, ctrs[0].spec.Hostname, durable) + err := ac.CreateSandboxForActor(sbCtx, id, ctrs[0].spec.Hostname, durable, systemInfo) sbCancel() if err != nil { return fmt.Errorf("while creating agent sandbox: %w", err) diff --git a/cmd/ateom-microvm/spec.go b/cmd/ateom-microvm/spec.go index 52565704c..a5b7d80da 100644 --- a/cmd/ateom-microvm/spec.go +++ b/cmd/ateom-microvm/spec.go @@ -88,13 +88,12 @@ func ensureKataCompatibleSpec(bundle, id, netnsPath string) (*specs.Spec, error) // the exact set `ctr run --runtime io.containerd.kata.v2` emits, which kata's // agent accepts. (Static shaper; pod DNS integration is future work.) // - // KNOWN GAP vs the gVisor runtime: this also drops atelet's read-only - // systemInfo volume bind mounts (e.g. the actorMetadata data-source files). - // The micro-VM guest can't see host paths (the rootfs is an overlay of a - // virtio-fs base + a guest-RAM upper, not a host bind), so atelet's - // host-path volume roots have nothing to bind to. Exposing them needs a - // per-actor volume plumbed into the guest; not yet implemented. No - // micro-VM workload depends on it today. + // Dropping atelet's volume bind mounts here is fine: host-path binds can't + // attach inside the guest anyway. Volumes reach micro-VM containers over + // per-actor virtio-fs shares instead — durable-dir volumes via the + // writable share (durable.go) and system-info volumes via the read-only + // share (systeminfo.go) — with the binds added to the workload specs ateom + // drives through the kata-agent (see workloadSpec). spec.Mounts = defaultKataMounts() out, err := json.MarshalIndent(&spec, "", " ") diff --git a/cmd/ateom-microvm/systeminfo.go b/cmd/ateom-microvm/systeminfo.go new file mode 100644 index 000000000..db448cdcf --- /dev/null +++ b/cmd/ateom-microvm/systeminfo.go @@ -0,0 +1,117 @@ +//go:build linux + +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// System-info volume support for the micro-VM runtime. +// +// A system-info volume is a read-only directory of files generated by atelet +// on the host on every Run/Restore (e.g. the actorMetadata data-source files), +// so its contents always describe the actor actually being started, whatever +// checkpointed state it boots from. The host side is owned by atelet, which +// creates one directory per volume under +// ateompath.SystemInfoVolumeRootsDir(actorUID) and wipes/rebuilds them when +// the actor's directories are reset. +// +// ateom exposes that host directory to the guest over a THIRD virtiofsd — +// alongside the RO overlay lower (kataShared) and the writable durable-dir +// share — mounted by the agent at sandbox creation. Each volume is a +// subdirectory of the one share, at kata.GuestSystemInfoVolumeDir(volume), +// bind-mounted READ-ONLY from there into every container that declares it. +// +// Unlike durable-dir volumes, system-info volumes are deliberately absent +// from the checkpoint path: their contents must never be captured into +// snapshots (see the SystemInfo semantics in docs/api-guide.md). Like the +// durable share, this one runs with cache=auto: the host contents change +// underneath the guest whenever atelet regenerates them for a restore. + +package main + +import ( + "context" + "fmt" + "os" + "os/exec" + "path/filepath" + + "github.com/agent-substrate/substrate/cmd/ateom-microvm/internal/kata" + "github.com/agent-substrate/substrate/internal/ateompath" + "github.com/agent-substrate/substrate/internal/proto/ateompb" + specs "github.com/opencontainers/runtime-spec/specs-go" +) + +// hasSystemInfoVolumes reports whether any container mounts a system-info +// volume. +func hasSystemInfoVolumes(containers []*ateompb.Container) bool { + for _, c := range containers { + if len(c.GetSystemInfoVolumeMounts()) > 0 { + return true + } + } + return false +} + +// systemInfoMounts returns the OCI mounts that expose a container's +// system-info volumes at the paths it declared, read-only. Each source is that +// volume's directory inside the guest's system-info share, which the agent +// mounts at sandbox creation. +func systemInfoMounts(mounts []*ateompb.SystemInfoVolumeMount) []specs.Mount { + out := make([]specs.Mount, 0, len(mounts)) + for _, m := range mounts { + out = append(out, specs.Mount{ + Destination: m.GetMountPath(), + Source: kata.GuestSystemInfoVolumeDir(m.GetVolumeName()), + Type: "bind", + Options: []string{"rbind", "ro"}, + }) + } + return out +} + +// systemInfoVirtiofsdLogPath is where the system-info share's virtiofsd logs, +// beside the overlay lower's and the durable share's under the actor's VM dir. +func systemInfoVirtiofsdLogPath(id string) string { + return filepath.Join(kata.VMDir(id), "virtiofsd-system-info.log") +} + +// stageSystemInfoShare starts the virtiofsd serving the actor's system-info +// volumes. +// +// It serves ateompath.SystemInfoVolumeRootsDir directly, like the durable +// share, and runs with cache=auto for the same reason: atelet rewrites the +// contents underneath the guest on every restore. Read-only enforcement +// happens at the container binds (see systemInfoMounts), not here — virtiofsd +// serves the share write-through, and the guest never gets a writable mount +// of it. +// +// The returned cmd outlives this call (CH talks to it for the VM's lifetime); +// the caller owns it (tracked on runningActor, killed in teardownActor). +func (s *AteomService) stageSystemInfoShare(ctx context.Context, rr resolvedRuntime, actorUID string) (*exec.Cmd, error) { + shared := ateompath.SystemInfoVolumeRootsDir(actorUID) + if _, err := os.Stat(shared); err != nil { + return nil, fmt.Errorf("while checking system-info volumes dir %q: %w", shared, err) + } + log, _ := os.OpenFile(systemInfoVirtiofsdLogPath(actorUID), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o600) + cmd, err := kata.StartVirtiofsd(ctx, kata.VirtiofsdOptions{ + Binary: rr.virtiofsd, + SocketPath: kata.SystemInfoVirtiofsdSocketPath(actorUID), + SharedDir: shared, + Cache: "auto", + Log: log, + }) + if err != nil { + return nil, fmt.Errorf("while starting system-info virtiofsd: %w", err) + } + return cmd, nil +} diff --git a/internal/proto/ateompb/ateom.pb.go b/internal/proto/ateompb/ateom.pb.go index 3ff384612..350afdc65 100644 --- a/internal/proto/ateompb/ateom.pb.go +++ b/internal/proto/ateompb/ateom.pb.go @@ -424,6 +424,10 @@ type Container struct { // durable_dir_volume_mounts are the durable-dir volumes this container // mounts, if any. DurableDirVolumeMounts []*DurableDirVolumeMount `protobuf:"bytes,4,rep,name=durable_dir_volume_mounts,json=durableDirVolumeMounts,proto3" json:"durable_dir_volume_mounts,omitempty"` + // system_info_volume_mounts are the system-info volumes this container + // mounts, if any. Contents are generated by atelet on the host; the + // container sees them read-only. + SystemInfoVolumeMounts []*SystemInfoVolumeMount `protobuf:"bytes,5,rep,name=system_info_volume_mounts,json=systemInfoVolumeMounts,proto3" json:"system_info_volume_mounts,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -479,6 +483,13 @@ func (x *Container) GetDurableDirVolumeMounts() []*DurableDirVolumeMount { return nil } +func (x *Container) GetSystemInfoVolumeMounts() []*SystemInfoVolumeMount { + if x != nil { + return x.SystemInfoVolumeMounts + } + return nil +} + // DurableDirVolumeMount is one durable-dir volume mounted into a container. type DurableDirVolumeMount struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -535,6 +546,64 @@ func (x *DurableDirVolumeMount) GetMountPath() string { return "" } +// SystemInfoVolumeMount is one system-info volume mounted (read-only) into a +// container. Unlike durable-dir volumes, system-info contents are generated +// by atelet on every Run/Restore and are never captured into snapshots. +type SystemInfoVolumeMount struct { + state protoimpl.MessageState `protogen:"open.v1"` + // volume_name is the name the ActorTemplate gave the volume. It selects the + // per-volume directory atelet prepared for the actor on the host. + VolumeName string `protobuf:"bytes,1,opt,name=volume_name,json=volumeName,proto3" json:"volume_name,omitempty"` + // mount_path is where the container sees the volume. + MountPath string `protobuf:"bytes,2,opt,name=mount_path,json=mountPath,proto3" json:"mount_path,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SystemInfoVolumeMount) Reset() { + *x = SystemInfoVolumeMount{} + mi := &file_ateom_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SystemInfoVolumeMount) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SystemInfoVolumeMount) ProtoMessage() {} + +func (x *SystemInfoVolumeMount) ProtoReflect() protoreflect.Message { + mi := &file_ateom_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SystemInfoVolumeMount.ProtoReflect.Descriptor instead. +func (*SystemInfoVolumeMount) Descriptor() ([]byte, []int) { + return file_ateom_proto_rawDescGZIP(), []int{5} +} + +func (x *SystemInfoVolumeMount) GetVolumeName() string { + if x != nil { + return x.VolumeName + } + return "" +} + +func (x *SystemInfoVolumeMount) GetMountPath() string { + if x != nil { + return x.MountPath + } + return "" +} + // Readyz describes how to check that a container is ready to serve. // Only HTTP is supported today. type Readyz struct { @@ -549,7 +618,7 @@ type Readyz struct { func (x *Readyz) Reset() { *x = Readyz{} - mi := &file_ateom_proto_msgTypes[5] + mi := &file_ateom_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -561,7 +630,7 @@ func (x *Readyz) String() string { func (*Readyz) ProtoMessage() {} func (x *Readyz) ProtoReflect() protoreflect.Message { - mi := &file_ateom_proto_msgTypes[5] + mi := &file_ateom_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -574,7 +643,7 @@ func (x *Readyz) ProtoReflect() protoreflect.Message { // Deprecated: Use Readyz.ProtoReflect.Descriptor instead. func (*Readyz) Descriptor() ([]byte, []int) { - return file_ateom_proto_rawDescGZIP(), []int{5} + return file_ateom_proto_rawDescGZIP(), []int{6} } func (x *Readyz) GetHttpGet() *HTTPGetAction { @@ -604,7 +673,7 @@ type HTTPGetAction struct { func (x *HTTPGetAction) Reset() { *x = HTTPGetAction{} - mi := &file_ateom_proto_msgTypes[6] + mi := &file_ateom_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -616,7 +685,7 @@ func (x *HTTPGetAction) String() string { func (*HTTPGetAction) ProtoMessage() {} func (x *HTTPGetAction) ProtoReflect() protoreflect.Message { - mi := &file_ateom_proto_msgTypes[6] + mi := &file_ateom_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -629,7 +698,7 @@ func (x *HTTPGetAction) ProtoReflect() protoreflect.Message { // Deprecated: Use HTTPGetAction.ProtoReflect.Descriptor instead. func (*HTTPGetAction) Descriptor() ([]byte, []int) { - return file_ateom_proto_rawDescGZIP(), []int{6} + return file_ateom_proto_rawDescGZIP(), []int{7} } func (x *HTTPGetAction) GetPath() string { @@ -654,7 +723,7 @@ type RunWorkloadResponse struct { func (x *RunWorkloadResponse) Reset() { *x = RunWorkloadResponse{} - mi := &file_ateom_proto_msgTypes[7] + mi := &file_ateom_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -666,7 +735,7 @@ func (x *RunWorkloadResponse) String() string { func (*RunWorkloadResponse) ProtoMessage() {} func (x *RunWorkloadResponse) ProtoReflect() protoreflect.Message { - mi := &file_ateom_proto_msgTypes[7] + mi := &file_ateom_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -679,7 +748,7 @@ func (x *RunWorkloadResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RunWorkloadResponse.ProtoReflect.Descriptor instead. func (*RunWorkloadResponse) Descriptor() ([]byte, []int) { - return file_ateom_proto_rawDescGZIP(), []int{7} + return file_ateom_proto_rawDescGZIP(), []int{8} } type CheckpointWorkloadRequest struct { @@ -713,7 +782,7 @@ type CheckpointWorkloadRequest struct { func (x *CheckpointWorkloadRequest) Reset() { *x = CheckpointWorkloadRequest{} - mi := &file_ateom_proto_msgTypes[8] + mi := &file_ateom_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -725,7 +794,7 @@ func (x *CheckpointWorkloadRequest) String() string { func (*CheckpointWorkloadRequest) ProtoMessage() {} func (x *CheckpointWorkloadRequest) ProtoReflect() protoreflect.Message { - mi := &file_ateom_proto_msgTypes[8] + mi := &file_ateom_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -738,7 +807,7 @@ func (x *CheckpointWorkloadRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CheckpointWorkloadRequest.ProtoReflect.Descriptor instead. func (*CheckpointWorkloadRequest) Descriptor() ([]byte, []int) { - return file_ateom_proto_rawDescGZIP(), []int{8} + return file_ateom_proto_rawDescGZIP(), []int{9} } func (x *CheckpointWorkloadRequest) GetAtespace() string { @@ -823,7 +892,7 @@ type CheckpointWorkloadResponse struct { func (x *CheckpointWorkloadResponse) Reset() { *x = CheckpointWorkloadResponse{} - mi := &file_ateom_proto_msgTypes[9] + mi := &file_ateom_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -835,7 +904,7 @@ func (x *CheckpointWorkloadResponse) String() string { func (*CheckpointWorkloadResponse) ProtoMessage() {} func (x *CheckpointWorkloadResponse) ProtoReflect() protoreflect.Message { - mi := &file_ateom_proto_msgTypes[9] + mi := &file_ateom_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -848,7 +917,7 @@ func (x *CheckpointWorkloadResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CheckpointWorkloadResponse.ProtoReflect.Descriptor instead. func (*CheckpointWorkloadResponse) Descriptor() ([]byte, []int) { - return file_ateom_proto_rawDescGZIP(), []int{9} + return file_ateom_proto_rawDescGZIP(), []int{10} } func (x *CheckpointWorkloadResponse) GetSnapshotFiles() []string { @@ -887,7 +956,7 @@ type RestoreWorkloadRequest struct { func (x *RestoreWorkloadRequest) Reset() { *x = RestoreWorkloadRequest{} - mi := &file_ateom_proto_msgTypes[10] + mi := &file_ateom_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -899,7 +968,7 @@ func (x *RestoreWorkloadRequest) String() string { func (*RestoreWorkloadRequest) ProtoMessage() {} func (x *RestoreWorkloadRequest) ProtoReflect() protoreflect.Message { - mi := &file_ateom_proto_msgTypes[10] + mi := &file_ateom_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -912,7 +981,7 @@ func (x *RestoreWorkloadRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RestoreWorkloadRequest.ProtoReflect.Descriptor instead. func (*RestoreWorkloadRequest) Descriptor() ([]byte, []int) { - return file_ateom_proto_rawDescGZIP(), []int{10} + return file_ateom_proto_rawDescGZIP(), []int{11} } func (x *RestoreWorkloadRequest) GetAtespace() string { @@ -1007,7 +1076,7 @@ type RestoreWorkloadResponse struct { func (x *RestoreWorkloadResponse) Reset() { *x = RestoreWorkloadResponse{} - mi := &file_ateom_proto_msgTypes[11] + mi := &file_ateom_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1019,7 +1088,7 @@ func (x *RestoreWorkloadResponse) String() string { func (*RestoreWorkloadResponse) ProtoMessage() {} func (x *RestoreWorkloadResponse) ProtoReflect() protoreflect.Message { - mi := &file_ateom_proto_msgTypes[11] + mi := &file_ateom_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1032,7 +1101,7 @@ func (x *RestoreWorkloadResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RestoreWorkloadResponse.ProtoReflect.Descriptor instead. func (*RestoreWorkloadResponse) Descriptor() ([]byte, []int) { - return file_ateom_proto_rawDescGZIP(), []int{11} + return file_ateom_proto_rawDescGZIP(), []int{12} } type GetWorkloadStatsRequest struct { @@ -1048,7 +1117,7 @@ type GetWorkloadStatsRequest struct { func (x *GetWorkloadStatsRequest) Reset() { *x = GetWorkloadStatsRequest{} - mi := &file_ateom_proto_msgTypes[12] + mi := &file_ateom_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1060,7 +1129,7 @@ func (x *GetWorkloadStatsRequest) String() string { func (*GetWorkloadStatsRequest) ProtoMessage() {} func (x *GetWorkloadStatsRequest) ProtoReflect() protoreflect.Message { - mi := &file_ateom_proto_msgTypes[12] + mi := &file_ateom_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1073,7 +1142,7 @@ func (x *GetWorkloadStatsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetWorkloadStatsRequest.ProtoReflect.Descriptor instead. func (*GetWorkloadStatsRequest) Descriptor() ([]byte, []int) { - return file_ateom_proto_rawDescGZIP(), []int{12} + return file_ateom_proto_rawDescGZIP(), []int{13} } func (x *GetWorkloadStatsRequest) GetActorUid() string { @@ -1137,7 +1206,7 @@ type GetWorkloadStatsResponse struct { func (x *GetWorkloadStatsResponse) Reset() { *x = GetWorkloadStatsResponse{} - mi := &file_ateom_proto_msgTypes[13] + mi := &file_ateom_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1149,7 +1218,7 @@ func (x *GetWorkloadStatsResponse) String() string { func (*GetWorkloadStatsResponse) ProtoMessage() {} func (x *GetWorkloadStatsResponse) ProtoReflect() protoreflect.Message { - mi := &file_ateom_proto_msgTypes[13] + mi := &file_ateom_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1162,7 +1231,7 @@ func (x *GetWorkloadStatsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetWorkloadStatsResponse.ProtoReflect.Descriptor instead. func (*GetWorkloadStatsResponse) Descriptor() ([]byte, []int) { - return file_ateom_proto_rawDescGZIP(), []int{13} + return file_ateom_proto_rawDescGZIP(), []int{14} } func (x *GetWorkloadStatsResponse) GetAtespace() string { @@ -1276,15 +1345,21 @@ const file_ateom_proto_rawDesc = "" + "\fWorkloadSpec\x120\n" + "\n" + "containers\x18\x01 \x03(\v2\x10.ateom.ContainerR\n" + - "containers\"\xba\x01\n" + + "containers\"\x93\x02\n" + "\tContainer\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12%\n" + "\x06readyz\x18\x02 \x01(\v2\r.ateom.ReadyzR\x06readyz\x12W\n" + - "\x19durable_dir_volume_mounts\x18\x04 \x03(\v2\x1c.ateom.DurableDirVolumeMountR\x16durableDirVolumeMountsJ\x04\b\x03\x10\x04R\x13durable_dir_volumes\"W\n" + + "\x19durable_dir_volume_mounts\x18\x04 \x03(\v2\x1c.ateom.DurableDirVolumeMountR\x16durableDirVolumeMounts\x12W\n" + + "\x19system_info_volume_mounts\x18\x05 \x03(\v2\x1c.ateom.SystemInfoVolumeMountR\x16systemInfoVolumeMountsJ\x04\b\x03\x10\x04R\x13durable_dir_volumes\"W\n" + "\x15DurableDirVolumeMount\x12\x1f\n" + "\vvolume_name\x18\x01 \x01(\tR\n" + "volumeName\x12\x1d\n" + "\n" + + "mount_path\x18\x02 \x01(\tR\tmountPath\"W\n" + + "\x15SystemInfoVolumeMount\x12\x1f\n" + + "\vvolume_name\x18\x01 \x01(\tR\n" + + "volumeName\x12\x1d\n" + + "\n" + "mount_path\x18\x02 \x01(\tR\tmountPath\"b\n" + "\x06Readyz\x12/\n" + "\bhttp_get\x18\x01 \x01(\v2\x14.ateom.HTTPGetActionR\ahttpGet\x12'\n" + @@ -1382,7 +1457,7 @@ func file_ateom_proto_rawDescGZIP() []byte { } var file_ateom_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_ateom_proto_msgTypes = make([]protoimpl.MessageInfo, 17) +var file_ateom_proto_msgTypes = make([]protoimpl.MessageInfo, 18) var file_ateom_proto_goTypes = []any{ (SnapshotScope)(0), // 0: ateom.SnapshotScope (SandboxClass)(0), // 1: ateom.SandboxClass @@ -1392,49 +1467,51 @@ var file_ateom_proto_goTypes = []any{ (*WorkloadSpec)(nil), // 5: ateom.WorkloadSpec (*Container)(nil), // 6: ateom.Container (*DurableDirVolumeMount)(nil), // 7: ateom.DurableDirVolumeMount - (*Readyz)(nil), // 8: ateom.Readyz - (*HTTPGetAction)(nil), // 9: ateom.HTTPGetAction - (*RunWorkloadResponse)(nil), // 10: ateom.RunWorkloadResponse - (*CheckpointWorkloadRequest)(nil), // 11: ateom.CheckpointWorkloadRequest - (*CheckpointWorkloadResponse)(nil), // 12: ateom.CheckpointWorkloadResponse - (*RestoreWorkloadRequest)(nil), // 13: ateom.RestoreWorkloadRequest - (*RestoreWorkloadResponse)(nil), // 14: ateom.RestoreWorkloadResponse - (*GetWorkloadStatsRequest)(nil), // 15: ateom.GetWorkloadStatsRequest - (*GetWorkloadStatsResponse)(nil), // 16: ateom.GetWorkloadStatsResponse - nil, // 17: ateom.RunWorkloadRequest.RuntimeAssetPathsEntry - nil, // 18: ateom.CheckpointWorkloadRequest.RuntimeAssetPathsEntry - nil, // 19: ateom.RestoreWorkloadRequest.RuntimeAssetPathsEntry + (*SystemInfoVolumeMount)(nil), // 8: ateom.SystemInfoVolumeMount + (*Readyz)(nil), // 9: ateom.Readyz + (*HTTPGetAction)(nil), // 10: ateom.HTTPGetAction + (*RunWorkloadResponse)(nil), // 11: ateom.RunWorkloadResponse + (*CheckpointWorkloadRequest)(nil), // 12: ateom.CheckpointWorkloadRequest + (*CheckpointWorkloadResponse)(nil), // 13: ateom.CheckpointWorkloadResponse + (*RestoreWorkloadRequest)(nil), // 14: ateom.RestoreWorkloadRequest + (*RestoreWorkloadResponse)(nil), // 15: ateom.RestoreWorkloadResponse + (*GetWorkloadStatsRequest)(nil), // 16: ateom.GetWorkloadStatsRequest + (*GetWorkloadStatsResponse)(nil), // 17: ateom.GetWorkloadStatsResponse + nil, // 18: ateom.RunWorkloadRequest.RuntimeAssetPathsEntry + nil, // 19: ateom.CheckpointWorkloadRequest.RuntimeAssetPathsEntry + nil, // 20: ateom.RestoreWorkloadRequest.RuntimeAssetPathsEntry } var file_ateom_proto_depIdxs = []int32{ 5, // 0: ateom.RunWorkloadRequest.spec:type_name -> ateom.WorkloadSpec - 17, // 1: ateom.RunWorkloadRequest.runtime_asset_paths:type_name -> ateom.RunWorkloadRequest.RuntimeAssetPathsEntry + 18, // 1: ateom.RunWorkloadRequest.runtime_asset_paths:type_name -> ateom.RunWorkloadRequest.RuntimeAssetPathsEntry 4, // 2: ateom.RunWorkloadRequest.egress_gateway:type_name -> ateom.EgressGateway 6, // 3: ateom.WorkloadSpec.containers:type_name -> ateom.Container - 8, // 4: ateom.Container.readyz:type_name -> ateom.Readyz + 9, // 4: ateom.Container.readyz:type_name -> ateom.Readyz 7, // 5: ateom.Container.durable_dir_volume_mounts:type_name -> ateom.DurableDirVolumeMount - 9, // 6: ateom.Readyz.http_get:type_name -> ateom.HTTPGetAction - 5, // 7: ateom.CheckpointWorkloadRequest.spec:type_name -> ateom.WorkloadSpec - 18, // 8: ateom.CheckpointWorkloadRequest.runtime_asset_paths:type_name -> ateom.CheckpointWorkloadRequest.RuntimeAssetPathsEntry - 0, // 9: ateom.CheckpointWorkloadRequest.scope:type_name -> ateom.SnapshotScope - 5, // 10: ateom.RestoreWorkloadRequest.spec:type_name -> ateom.WorkloadSpec - 19, // 11: ateom.RestoreWorkloadRequest.runtime_asset_paths:type_name -> ateom.RestoreWorkloadRequest.RuntimeAssetPathsEntry - 0, // 12: ateom.RestoreWorkloadRequest.scope:type_name -> ateom.SnapshotScope - 4, // 13: ateom.RestoreWorkloadRequest.egress_gateway:type_name -> ateom.EgressGateway - 1, // 14: ateom.GetWorkloadStatsResponse.sandbox_class:type_name -> ateom.SandboxClass - 2, // 15: ateom.GetWorkloadStatsResponse.source:type_name -> ateom.StatsSource - 3, // 16: ateom.Ateom.RunWorkload:input_type -> ateom.RunWorkloadRequest - 11, // 17: ateom.Ateom.CheckpointWorkload:input_type -> ateom.CheckpointWorkloadRequest - 13, // 18: ateom.Ateom.RestoreWorkload:input_type -> ateom.RestoreWorkloadRequest - 15, // 19: ateom.Ateom.GetWorkloadStats:input_type -> ateom.GetWorkloadStatsRequest - 10, // 20: ateom.Ateom.RunWorkload:output_type -> ateom.RunWorkloadResponse - 12, // 21: ateom.Ateom.CheckpointWorkload:output_type -> ateom.CheckpointWorkloadResponse - 14, // 22: ateom.Ateom.RestoreWorkload:output_type -> ateom.RestoreWorkloadResponse - 16, // 23: ateom.Ateom.GetWorkloadStats:output_type -> ateom.GetWorkloadStatsResponse - 20, // [20:24] is the sub-list for method output_type - 16, // [16:20] is the sub-list for method input_type - 16, // [16:16] is the sub-list for extension type_name - 16, // [16:16] is the sub-list for extension extendee - 0, // [0:16] is the sub-list for field type_name + 8, // 6: ateom.Container.system_info_volume_mounts:type_name -> ateom.SystemInfoVolumeMount + 10, // 7: ateom.Readyz.http_get:type_name -> ateom.HTTPGetAction + 5, // 8: ateom.CheckpointWorkloadRequest.spec:type_name -> ateom.WorkloadSpec + 19, // 9: ateom.CheckpointWorkloadRequest.runtime_asset_paths:type_name -> ateom.CheckpointWorkloadRequest.RuntimeAssetPathsEntry + 0, // 10: ateom.CheckpointWorkloadRequest.scope:type_name -> ateom.SnapshotScope + 5, // 11: ateom.RestoreWorkloadRequest.spec:type_name -> ateom.WorkloadSpec + 20, // 12: ateom.RestoreWorkloadRequest.runtime_asset_paths:type_name -> ateom.RestoreWorkloadRequest.RuntimeAssetPathsEntry + 0, // 13: ateom.RestoreWorkloadRequest.scope:type_name -> ateom.SnapshotScope + 4, // 14: ateom.RestoreWorkloadRequest.egress_gateway:type_name -> ateom.EgressGateway + 1, // 15: ateom.GetWorkloadStatsResponse.sandbox_class:type_name -> ateom.SandboxClass + 2, // 16: ateom.GetWorkloadStatsResponse.source:type_name -> ateom.StatsSource + 3, // 17: ateom.Ateom.RunWorkload:input_type -> ateom.RunWorkloadRequest + 12, // 18: ateom.Ateom.CheckpointWorkload:input_type -> ateom.CheckpointWorkloadRequest + 14, // 19: ateom.Ateom.RestoreWorkload:input_type -> ateom.RestoreWorkloadRequest + 16, // 20: ateom.Ateom.GetWorkloadStats:input_type -> ateom.GetWorkloadStatsRequest + 11, // 21: ateom.Ateom.RunWorkload:output_type -> ateom.RunWorkloadResponse + 13, // 22: ateom.Ateom.CheckpointWorkload:output_type -> ateom.CheckpointWorkloadResponse + 15, // 23: ateom.Ateom.RestoreWorkload:output_type -> ateom.RestoreWorkloadResponse + 17, // 24: ateom.Ateom.GetWorkloadStats:output_type -> ateom.GetWorkloadStatsResponse + 21, // [21:25] is the sub-list for method output_type + 17, // [17:21] is the sub-list for method input_type + 17, // [17:17] is the sub-list for extension type_name + 17, // [17:17] is the sub-list for extension extendee + 0, // [0:17] is the sub-list for field type_name } func init() { file_ateom_proto_init() } @@ -1443,14 +1520,14 @@ func file_ateom_proto_init() { return } file_ateom_proto_msgTypes[0].OneofWrappers = []any{} - file_ateom_proto_msgTypes[10].OneofWrappers = []any{} + file_ateom_proto_msgTypes[11].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_ateom_proto_rawDesc), len(file_ateom_proto_rawDesc)), NumEnums: 3, - NumMessages: 17, + NumMessages: 18, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/proto/ateompb/ateom.proto b/internal/proto/ateompb/ateom.proto index f190fcd15..fd832a296 100644 --- a/internal/proto/ateompb/ateom.proto +++ b/internal/proto/ateompb/ateom.proto @@ -124,6 +124,11 @@ message Container { // durable_dir_volume_mounts are the durable-dir volumes this container // mounts, if any. repeated DurableDirVolumeMount durable_dir_volume_mounts = 4; + + // system_info_volume_mounts are the system-info volumes this container + // mounts, if any. Contents are generated by atelet on the host; the + // container sees them read-only. + repeated SystemInfoVolumeMount system_info_volume_mounts = 5; } // DurableDirVolumeMount is one durable-dir volume mounted into a container. @@ -135,6 +140,17 @@ message DurableDirVolumeMount { string mount_path = 2; } +// SystemInfoVolumeMount is one system-info volume mounted (read-only) into a +// container. Unlike durable-dir volumes, system-info contents are generated +// by atelet on every Run/Restore and are never captured into snapshots. +message SystemInfoVolumeMount { + // volume_name is the name the ActorTemplate gave the volume. It selects the + // per-volume directory atelet prepared for the actor on the host. + string volume_name = 1; + // mount_path is where the container sees the volume. + string mount_path = 2; +} + // Readyz describes how to check that a container is ready to serve. // Only HTTP is supported today. message Readyz { From 22da91b0eed217352c601bc0ad78e138fbcd4aea Mon Sep 17 00:00:00 2001 From: Max Thompson Date: Thu, 13 Aug 2026 10:43:26 -0700 Subject: [PATCH 6/7] third_party/atomicwriter: record provenance and delineate local changes Add a README pinning the upstream source (k8s.io/kubernetes pkg/volume/util, delta verified against kubernetes/kubernetes@52ba9013) and enumerating every class of local modification, plus maintenance rules (mechanical adaptations only in upstream-derived files; behavioral changes go in substrate-owned files) and a re-sync procedure. Mark each copied file with a greppable '// substrate:' header so the patch surface is discoverable without diffing against upstream. --- .../third_party/atomicwriter/README.md | 57 +++++++++++++++++++ .../third_party/atomicwriter/atomic_writer.go | 5 ++ .../atomicwriter/atomic_writer_linux.go | 3 + .../atomicwriter/atomic_writer_test.go | 5 ++ .../atomicwriter/atomic_writer_unsupported.go | 3 + 5 files changed, 73 insertions(+) create mode 100644 cmd/atelet/internal/third_party/atomicwriter/README.md diff --git a/cmd/atelet/internal/third_party/atomicwriter/README.md b/cmd/atelet/internal/third_party/atomicwriter/README.md new file mode 100644 index 000000000..1719030e0 --- /dev/null +++ b/cmd/atelet/internal/third_party/atomicwriter/README.md @@ -0,0 +1,57 @@ +# third_party/atomicwriter + +Kubelet's atomic writer, copied from the Kubernetes monorepo: + +- **Upstream source:** `k8s.io/kubernetes/pkg/volume/util/` + (`atomic_writer.go`, `atomic_writer_linux.go`, `atomic_writer_unsupported.go`, + `atomic_writer_test.go`) +- **Delta last verified against:** [`kubernetes/kubernetes@52ba9013`](https://github.com/kubernetes/kubernetes/commit/52ba90138eb40cab0987dac73e05c838149bdd1c) (master, 2026-08-13) +- **License:** Apache-2.0; the upstream copyright headers are retained in every file. + +It is copied, not imported, because upstream lives in the `k8s.io/kubernetes` +monorepo, which is not consumable as a Go module. Expect this to remain a +permanent fork: the algorithm has been stable upstream since ~2016, and our +adaptations below are ones upstream would not take. Occasional manual re-syncs +for upstream bugfixes (e.g. path-validation hardening) are the only planned +convergence. + +## Local modifications + +Every modified file carries a `// substrate:` marker below its license header; +`grep -rn "substrate:" .` from this directory lists the patched files. The +changes, by class: + +1. Package renamed `util` → `atomicwriter`. +2. Kubernetes-internal dependencies dropped: `k8s.io/klog/v2`, + `k8s.io/apiserver/pkg/util/feature`, and `k8s.io/kubernetes/pkg/features` + (`k8s.io/apimachinery/pkg/util/sets` is kept — substrate already vendors it). + In the test file, `k8s.io/client-go/util/testing` is replaced by a local + `mkTmpdir` helper. +3. Logging converted from klog to `log/slog`, threading a `context.Context` + through `Write`, `pathsToRemove`, and `removeUserVisiblePaths` for + `slog.*Context`. The `logContext` field/constructor parameter this obsoletes + is removed: `NewAtomicWriter(targetDir, logContext)` → + `NewAtomicWriter(targetDir)`. +4. Error handling restyled: upstream's log-then-`return err` sites return + wrapped errors (`fmt.Errorf("while ...: %w", err)`) per substrate + convention; klog error logs that accompanied a `return` are dropped in + favor of the wrapped error. +5. Upstream's `ResolvesFsUser` helper (KEP-5936, feature-gate dependent) is + omitted; substrate does not use FsUser resolution. + +## Maintenance rules + +- Only mechanical adaptations (the classes above) belong in the + upstream-derived files. Anything behavioral goes in a separate, + substrate-owned file in this package (none exist today). +- When touching these files, keep the diff against upstream minimal and update + the modification list here if a new class of change is introduced. + +## Re-syncing with upstream + +1. Fetch the files listed above from `k8s.io/kubernetes` at the new commit. +2. Diff against this copy, ignoring the modification classes above + (the delta is ~80 lines; it is meant to stay readable by hand). +3. Apply upstream's changes, re-apply our classes to any new code, run + `go test ./cmd/atelet/internal/third_party/atomicwriter/`, and update the + "Delta last verified against" commit above. diff --git a/cmd/atelet/internal/third_party/atomicwriter/atomic_writer.go b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer.go index d2f3a6e0b..0fb6732f0 100644 --- a/cmd/atelet/internal/third_party/atomicwriter/atomic_writer.go +++ b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer.go @@ -14,6 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. */ +// substrate: modified from upstream k8s.io/kubernetes/pkg/volume/util — +// package renamed, klog→slog with context threading, errors wrapped instead +// of logged, logContext and ResolvesFsUser removed. See README.md for the +// full modification list. + package atomicwriter import ( diff --git a/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_linux.go b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_linux.go index 1d5f7d34e..706f87eaf 100644 --- a/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_linux.go +++ b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_linux.go @@ -16,6 +16,9 @@ See the License for the specific language governing permissions and limitations under the License. */ +// substrate: modified from upstream k8s.io/kubernetes/pkg/volume/util — +// package renamed. See README.md for the full modification list. + package atomicwriter import "os" diff --git a/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_test.go b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_test.go index 09d9e5232..037b13495 100644 --- a/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_test.go +++ b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_test.go @@ -16,6 +16,11 @@ See the License for the specific language governing permissions and limitations under the License. */ +// substrate: modified from upstream k8s.io/kubernetes/pkg/volume/util — +// package renamed, context threading on Write, k8s.io/client-go test dep +// replaced by a local mkTmpdir helper. See README.md for the full +// modification list. + package atomicwriter import ( diff --git a/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_unsupported.go b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_unsupported.go index 2de802794..50948ec69 100644 --- a/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_unsupported.go +++ b/cmd/atelet/internal/third_party/atomicwriter/atomic_writer_unsupported.go @@ -16,6 +16,9 @@ See the License for the specific language governing permissions and limitations under the License. */ +// substrate: modified from upstream k8s.io/kubernetes/pkg/volume/util — +// package renamed, klog→slog. See README.md for the full modification list. + package atomicwriter import ( From 8afe3db15b4fa591ffe640b52921a445fe4ed7a6 Mon Sep 17 00:00:00 2001 From: Max Thompson Date: Thu, 13 Aug 2026 13:21:36 -0700 Subject: [PATCH 7/7] Add clusterTrustBundle as a SystemInfo volume data source A clusterTrustBundle data source projects the trust anchors of a named ClusterTrustBundle (certificates.k8s.io/v1beta1) to a PEM file in a SystemInfo volume -- the substrate analog of the Kubernetes clusterTrustBundle projected volume source: systemInfo: dataSources: - clusterTrustBundle: name: my-trust-bundle path: ca.pem ateapi resolves the bundle at actor start through a new informer-backed lister and sanitizes the PEM the way kubelet does for projections (only CERTIFICATE blocks, deduplicated, headers stripped -- internal/pemutil). The wire spec carries only {path, pem_bundle}: atelet writes the resolved bytes via the existing atomic writer and never talks to the Kubernetes API. Starting the actor fails with an error naming the bundle when it is missing, empty, or contains no certificates. Because certificates.k8s.io/v1beta1 is feature-gated (enabled by hack/create-kind-cluster.sh), ateapi probes for the API at startup and degrades to a nil lister when absent -- registering the informer blindly would hang WaitForCacheSync and with it ateapi boot. envtest now serves the API so the functional suite matches real clusters. Validation extends the SystemInfo CEL rules: clean relative paths, unique paths across all data sources (dataSources MaxItems drops 32->8 to keep the cross-source rule inside the CEL cost budget), and the ate-api-server ClusterRole gains read access to clustertrustbundles. The identity e2e suite now creates a fixture bundle (junk PEM and a duplicate certificate around a real one), projects it into the probe, and asserts the delivered file is the sanitized PEM byte-for-byte. Part of #932 (PR 1); the SystemInfo volume mechanism is #802. --- .github/workflows/pr-workflow.yaml | 8 + .../controlapi/cluster_trust_bundle.go | 100 ++++++ .../controlapi/cluster_trust_bundle_test.go | 149 ++++++++ .../internal/controlapi/functional_test.go | 3 +- cmd/ateapi/internal/controlapi/service.go | 4 +- cmd/ateapi/internal/controlapi/workflow.go | 48 +-- .../internal/controlapi/workflow_resume.go | 6 + .../controlapi/workflow_suspend_test.go | 2 +- .../controlapi/workflow_testutil_test.go | 2 +- .../internal/controlapi/workload_spec.go | 12 + .../internal/controlapi/workload_spec_test.go | 56 +++ cmd/ateapi/main.go | 32 +- cmd/atelet/main.go | 12 + cmd/atelet/main_test.go | 39 +++ docs/api-guide.md | 22 ++ internal/e2e/fixtures/probe/main.go | 7 +- internal/e2e/fixtures/probe/probe.yaml.tmpl | 19 +- internal/e2e/suites/identity/identity_test.go | 182 +++++++++- internal/pemutil/pemutil.go | 54 +++ internal/pemutil/pemutil_test.go | 90 +++++ internal/proto/ateletpb/atelet.pb.go | 323 +++++++++++------- internal/proto/ateletpb/atelet.proto | 11 + internal/testenv/testenv.go | 7 + manifests/ate-install/ate-api-server.yaml | 5 + .../generated/ate.dev_actortemplates.yaml | 61 +++- pkg/api/v1alpha1/actortemplate_types.go | 48 ++- .../v1alpha1/actortemplate_validation_test.go | 116 ++++++- pkg/api/v1alpha1/zz_generated.deepcopy.go | 20 ++ 28 files changed, 1261 insertions(+), 177 deletions(-) create mode 100644 cmd/ateapi/internal/controlapi/cluster_trust_bundle.go create mode 100644 cmd/ateapi/internal/controlapi/cluster_trust_bundle_test.go create mode 100644 internal/pemutil/pemutil.go create mode 100644 internal/pemutil/pemutil_test.go diff --git a/.github/workflows/pr-workflow.yaml b/.github/workflows/pr-workflow.yaml index e1441aaa6..a6d3ee59b 100644 --- a/.github/workflows/pr-workflow.yaml +++ b/.github/workflows/pr-workflow.yaml @@ -114,6 +114,14 @@ jobs: E2E_TEMPLATE_NAME: counter-microvm E2E_TEMPLATE_READY_TIMEOUT: 600s run: hack/run-e2e-kind.sh ./internal/e2e/suites/demo -v -args --no-color + - name: Run E2E tests (micro-VM identity) + # Same identity suite (actorMetadata + clusterTrustBundle SystemInfo + # projections, restore-identity, bundle rotation), re-run with the probe + # on the micro-VM runtime so both sandboxes' volume delivery is covered. + env: + E2E_PROBE_SANDBOX_CLASS: microvm + E2E_PROBE_READY_TIMEOUT: 600s + run: hack/run-e2e-kind.sh ./internal/e2e/suites/identity -v -args --no-color - name: Dump diagnostics on failure if: failure() run: | diff --git a/cmd/ateapi/internal/controlapi/cluster_trust_bundle.go b/cmd/ateapi/internal/controlapi/cluster_trust_bundle.go new file mode 100644 index 000000000..da264c8b6 --- /dev/null +++ b/cmd/ateapi/internal/controlapi/cluster_trust_bundle.go @@ -0,0 +1,100 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package controlapi + +import ( + "fmt" + + "github.com/agent-substrate/substrate/internal/pemutil" + "github.com/agent-substrate/substrate/internal/proto/ateletpb" + atev1alpha1 "github.com/agent-substrate/substrate/pkg/api/v1alpha1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + certlisters "k8s.io/client-go/listers/certificates/v1beta1" +) + +// resolveClusterTrustBundles fills the PemBundle bytes of every +// clusterTrustBundle data source in workloadSpec, resolving each referenced +// ClusterTrustBundle through the lister and sanitizing its PEM the way +// kubelet does for projections (CERTIFICATE blocks only, deduplicated). +// +// The wire spec carries only {path, pem_bundle}; the bundle NAME lives in the +// ActorTemplate, so resolution walks the template and locates the matching +// wire entry by volume name + path. It must run on the resume path, before +// the spec is sent to atelet: a missing, empty, or unparseable bundle fails +// the actor start with an error naming the bundle, per the SystemInfo volume +// contract. atelet never talks to the Kubernetes API. +func resolveClusterTrustBundles(lister certlisters.ClusterTrustBundleLister, template *atev1alpha1.ActorTemplate, workloadSpec *ateletpb.WorkloadSpec) error { + if template == nil { + return nil + } + + // Wire entries indexed by (volume name, path) for filling in place. + type key struct{ volume, path string } + wire := map[key]*ateletpb.ClusterTrustBundleDataSource{} + for _, vol := range workloadSpec.GetVolumes() { + for _, ds := range vol.GetSystemInfo().GetDataSources() { + if ctb := ds.GetClusterTrustBundle(); ctb != nil { + wire[key{vol.GetName(), ctb.GetPath()}] = ctb + } + } + } + if len(wire) == 0 { + return nil + } + // A nil lister means ateapi found the ClusterTrustBundle API unavailable + // at startup (certificates.k8s.io/v1beta1 is feature-gated; see + // cmd/ateapi/main.go). Fail the start rather than panic on the lister. + if lister == nil { + return fmt.Errorf("this cluster does not serve the ClusterTrustBundle API (certificates.k8s.io/v1beta1), required by this actor's SystemInfo volumes") + } + + // One resolution per distinct bundle name, shared across references. + resolved := map[string][]byte{} + for _, vol := range template.Spec.Volumes { + if vol.VolumeSource.SystemInfo == nil { + continue + } + for _, ds := range vol.VolumeSource.SystemInfo.DataSources { + if ds.ClusterTrustBundle == nil { + continue + } + name := ds.ClusterTrustBundle.Name + + pemBundle, ok := resolved[name] + if !ok { + bundle, err := lister.Get(name) + if apierrors.IsNotFound(err) { + return fmt.Errorf("ClusterTrustBundle %q not found (referenced by volume %q)", name, vol.Name) + } else if err != nil { + return fmt.Errorf("while reading ClusterTrustBundle %q: %w", name, err) + } + pemBundle, err = pemutil.SanitizeCertificateBundle([]byte(bundle.Spec.TrustBundle)) + if err != nil { + return fmt.Errorf("ClusterTrustBundle %q has an unusable trust bundle: %w", name, err) + } + resolved[name] = pemBundle + } + + entry, ok := wire[key{vol.Name, ds.ClusterTrustBundle.Path}] + if !ok { + // The wire spec is built from this same template, so a missing + // entry means the two views diverged — a bug, not user error. + return fmt.Errorf("internal error: no wire entry for ClusterTrustBundle %q at volume %q path %q", name, vol.Name, ds.ClusterTrustBundle.Path) + } + entry.PemBundle = pemBundle + } + } + return nil +} diff --git a/cmd/ateapi/internal/controlapi/cluster_trust_bundle_test.go b/cmd/ateapi/internal/controlapi/cluster_trust_bundle_test.go new file mode 100644 index 000000000..e08cf40ee --- /dev/null +++ b/cmd/ateapi/internal/controlapi/cluster_trust_bundle_test.go @@ -0,0 +1,149 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package controlapi + +import ( + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "math/big" + "strings" + "testing" + "time" + + atev1alpha1 "github.com/agent-substrate/substrate/pkg/api/v1alpha1" + certsv1beta1 "k8s.io/api/certificates/v1beta1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + certlisters "k8s.io/client-go/listers/certificates/v1beta1" + "k8s.io/client-go/tools/cache" +) + +// testCertPEM mints a throwaway self-signed certificate, PEM-encoded. +func testCertPEM(t *testing.T) []byte { + t.Helper() + key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + t.Fatal(err) + } + der, err := x509.CreateCertificate(rand.Reader, &x509.Certificate{ + SerialNumber: big.NewInt(1), + Subject: pkix.Name{CommonName: "test"}, + NotBefore: time.Now(), + NotAfter: time.Now().Add(time.Hour), + }, &x509.Certificate{SerialNumber: big.NewInt(1)}, &key.PublicKey, key) + if err != nil { + t.Fatal(err) + } + return pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: der}) +} + +func ctbLister(t *testing.T, bundles ...*certsv1beta1.ClusterTrustBundle) certlisters.ClusterTrustBundleLister { + t.Helper() + indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{}) + for _, b := range bundles { + if err := indexer.Add(b); err != nil { + t.Fatal(err) + } + } + return certlisters.NewClusterTrustBundleLister(indexer) +} + +func ctbTemplate(volumeName, bundleName, path string) *atev1alpha1.ActorTemplate { + return &atev1alpha1.ActorTemplate{ + Spec: atev1alpha1.ActorTemplateSpec{ + Volumes: []atev1alpha1.Volume{{ + Name: volumeName, + VolumeSource: atev1alpha1.VolumeSource{ + SystemInfo: &atev1alpha1.SystemInfoVolumeSource{ + DataSources: []atev1alpha1.SystemInfoDataSource{ + {ClusterTrustBundle: &atev1alpha1.ClusterTrustBundleDataSource{Name: bundleName, Path: path}}, + }, + }, + }, + }}, + }, + } +} + +func TestResolveClusterTrustBundles(t *testing.T) { + certPEM := testCertPEM(t) + junk := "garbage\n" + string(pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: []byte("x")})) + + template := ctbTemplate("system-info", "egress-trust", "trust/ca.pem") + spec, err := workloadSpecFromActorTemplate(template, nil) + if err != nil { + t.Fatalf("workloadSpecFromActorTemplate: %v", err) + } + + t.Run("resolves and sanitizes into the wire spec", func(t *testing.T) { + lister := ctbLister(t, &certsv1beta1.ClusterTrustBundle{ + ObjectMeta: metav1.ObjectMeta{Name: "egress-trust"}, + // Junk around the certificate proves kubelet-style sanitization: + // only the CERTIFICATE block survives, and the duplicate is dropped. + Spec: certsv1beta1.ClusterTrustBundleSpec{TrustBundle: junk + string(certPEM) + string(certPEM)}, + }) + if err := resolveClusterTrustBundles(lister, template, spec); err != nil { + t.Fatalf("resolveClusterTrustBundles: %v", err) + } + got := spec.GetVolumes()[0].GetSystemInfo().GetDataSources()[0].GetClusterTrustBundle() + if got.GetPath() != "trust/ca.pem" { + t.Errorf("path = %q, want %q", got.GetPath(), "trust/ca.pem") + } + if string(got.GetPemBundle()) != string(certPEM) { + t.Errorf("pem bundle = %q, want the sanitized certificate", got.GetPemBundle()) + } + }) + + t.Run("missing bundle fails naming it", func(t *testing.T) { + spec, _ := workloadSpecFromActorTemplate(template, nil) + err := resolveClusterTrustBundles(ctbLister(t), template, spec) + if err == nil || !strings.Contains(err.Error(), `"egress-trust"`) || !strings.Contains(err.Error(), "not found") { + t.Errorf("error = %v, want not-found naming the bundle", err) + } + }) + + t.Run("unusable bundle fails naming it", func(t *testing.T) { + spec, _ := workloadSpecFromActorTemplate(template, nil) + lister := ctbLister(t, &certsv1beta1.ClusterTrustBundle{ + ObjectMeta: metav1.ObjectMeta{Name: "egress-trust"}, + Spec: certsv1beta1.ClusterTrustBundleSpec{TrustBundle: junk}, + }) + err := resolveClusterTrustBundles(lister, template, spec) + if err == nil || !strings.Contains(err.Error(), `"egress-trust"`) || !strings.Contains(err.Error(), "unusable") { + t.Errorf("error = %v, want unusable-bundle naming the bundle", err) + } + }) + + t.Run("no CTB sources is a no-op even with a nil lister", func(t *testing.T) { + plain := &atev1alpha1.ActorTemplate{} + spec, _ := workloadSpecFromActorTemplate(plain, nil) + if err := resolveClusterTrustBundles(nil, plain, spec); err != nil { + t.Fatalf("resolveClusterTrustBundles: %v", err) + } + }) + + t.Run("CTB sources with a nil lister fail with a clear error, not a panic", func(t *testing.T) { + // nil lister = ateapi booted on a cluster without the feature-gated + // ClusterTrustBundle API (see cmd/ateapi/main.go). + spec, _ := workloadSpecFromActorTemplate(template, nil) + err := resolveClusterTrustBundles(nil, template, spec) + if err == nil || !strings.Contains(err.Error(), "does not serve the ClusterTrustBundle API") { + t.Errorf("error = %v, want API-unavailable error", err) + } + }) +} diff --git a/cmd/ateapi/internal/controlapi/functional_test.go b/cmd/ateapi/internal/controlapi/functional_test.go index fd126c3ae..fea032dca 100644 --- a/cmd/ateapi/internal/controlapi/functional_test.go +++ b/cmd/ateapi/internal/controlapi/functional_test.go @@ -315,6 +315,7 @@ func setupTest(t *testing.T, ns string) *testContext { ateletFactory, ateletInformer := AteletInformer(k8sClient) scFactory := informers.NewSharedInformerFactory(k8sClient, 0) scLister := scFactory.Storage().V1().StorageClasses().Lister() + ctbLister := scFactory.Certificates().V1beta1().ClusterTrustBundles().Lister() substrateInformerFactory := externalversions.NewSharedInformerFactory(substrateClient, 0) actorTemplateLister := substrateInformerFactory.Api().V1alpha1().ActorTemplates().Lister() @@ -366,7 +367,7 @@ func setupTest(t *testing.T, ns string) *testContext { volPlugins := map[string]volume.VolumePluginControlPlane{ mockDriverName: mockPlugin, } - service := NewService(persistence, wc, actorTemplateLister, workerPoolLister, sandboxConfigLister, csiDriverConfigLister, scLister, dialer, instruments, "", volPlugins) + service := NewService(persistence, wc, actorTemplateLister, workerPoolLister, sandboxConfigLister, csiDriverConfigLister, scLister, ctbLister, dialer, instruments, "", volPlugins) // 5. Start REAL gRPC Server for ATE API grpcServer := grpc.NewServer(grpc.UnaryInterceptor(ateinterceptors.ServerUnaryInterceptor)) diff --git a/cmd/ateapi/internal/controlapi/service.go b/cmd/ateapi/internal/controlapi/service.go index fd5fd52bf..efbd381ce 100644 --- a/cmd/ateapi/internal/controlapi/service.go +++ b/cmd/ateapi/internal/controlapi/service.go @@ -24,6 +24,7 @@ import ( "github.com/agent-substrate/substrate/internal/volume/csi" listersv1alpha1 "github.com/agent-substrate/substrate/pkg/client/listers/api/v1alpha1" "github.com/agent-substrate/substrate/pkg/proto/ateapipb" + certlisters "k8s.io/client-go/listers/certificates/v1beta1" storagev1listers "k8s.io/client-go/listers/storage/v1" ) @@ -59,6 +60,7 @@ func NewService( sandboxConfigLister listersv1alpha1.SandboxConfigLister, csiDriverConfigLister listersv1alpha1.CSIDriverConfigLister, storageClassLister storagev1listers.StorageClassLister, + clusterTrustBundleLister certlisters.ClusterTrustBundleLister, dialer *AteletDialer, instruments *Instruments, egressGatewayAddress string, @@ -75,7 +77,7 @@ func NewService( instruments: instruments, volumePlugins: volumePlugins, } - s.actorWorkflow = NewActorWorkflow(persistence, workerCache, dialer, actorTemplateLister, workerPoolLister, sandboxConfigLister, storageClassLister, instruments, egressGatewayAddress, s) + s.actorWorkflow = NewActorWorkflow(persistence, workerCache, dialer, actorTemplateLister, workerPoolLister, sandboxConfigLister, storageClassLister, clusterTrustBundleLister, instruments, egressGatewayAddress, s) return s } diff --git a/cmd/ateapi/internal/controlapi/workflow.go b/cmd/ateapi/internal/controlapi/workflow.go index 49092f4a5..aaf1489d9 100644 --- a/cmd/ateapi/internal/controlapi/workflow.go +++ b/cmd/ateapi/internal/controlapi/workflow.go @@ -30,6 +30,7 @@ import ( "go.opentelemetry.io/otel/trace" grpcCodes "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + certlisters "k8s.io/client-go/listers/certificates/v1beta1" storagev1listers "k8s.io/client-go/listers/storage/v1" ) @@ -67,17 +68,18 @@ func markSkipped(ctx context.Context, reason string) { // ActorWorkflow handles the workflows for actor's resume / suspend operations. type ActorWorkflow struct { - store store.Interface - workerCache *workercache.Cache - scheduler scheduling.Scheduler - dialer *AteletDialer - actorTemplateLister listersv1alpha1.ActorTemplateLister - workerPoolLister listersv1alpha1.WorkerPoolLister - sandboxConfigLister listersv1alpha1.SandboxConfigLister - storageClassLister storagev1listers.StorageClassLister - instruments *Instruments - egressGatewayAddress string - pluginRegistry VolumePluginRegistry + store store.Interface + workerCache *workercache.Cache + scheduler scheduling.Scheduler + dialer *AteletDialer + actorTemplateLister listersv1alpha1.ActorTemplateLister + workerPoolLister listersv1alpha1.WorkerPoolLister + sandboxConfigLister listersv1alpha1.SandboxConfigLister + storageClassLister storagev1listers.StorageClassLister + clusterTrustBundleLister certlisters.ClusterTrustBundleLister + instruments *Instruments + egressGatewayAddress string + pluginRegistry VolumePluginRegistry } // NewActorWorkflow creates a new ActorWorkflow. instruments may be nil. @@ -89,22 +91,24 @@ func NewActorWorkflow( workerPoolLister listersv1alpha1.WorkerPoolLister, sandboxConfigLister listersv1alpha1.SandboxConfigLister, storageClassLister storagev1listers.StorageClassLister, + clusterTrustBundleLister certlisters.ClusterTrustBundleLister, instruments *Instruments, egressGatewayAddress string, pluginRegistry VolumePluginRegistry, ) *ActorWorkflow { return &ActorWorkflow{ - store: store, - workerCache: workerCache, - scheduler: scheduling.New(workerCache, scheduling.WithMeter(otel.Meter("ateapi"))), - dialer: dialer, - actorTemplateLister: actorTemplateLister, - workerPoolLister: workerPoolLister, - sandboxConfigLister: sandboxConfigLister, - storageClassLister: storageClassLister, - instruments: instruments, - egressGatewayAddress: egressGatewayAddress, - pluginRegistry: pluginRegistry, + store: store, + workerCache: workerCache, + scheduler: scheduling.New(workerCache, scheduling.WithMeter(otel.Meter("ateapi"))), + dialer: dialer, + actorTemplateLister: actorTemplateLister, + workerPoolLister: workerPoolLister, + sandboxConfigLister: sandboxConfigLister, + storageClassLister: storageClassLister, + clusterTrustBundleLister: clusterTrustBundleLister, + instruments: instruments, + egressGatewayAddress: egressGatewayAddress, + pluginRegistry: pluginRegistry, } } diff --git a/cmd/ateapi/internal/controlapi/workflow_resume.go b/cmd/ateapi/internal/controlapi/workflow_resume.go index 6666168d0..7944ff3ef 100644 --- a/cmd/ateapi/internal/controlapi/workflow_resume.go +++ b/cmd/ateapi/internal/controlapi/workflow_resume.go @@ -611,6 +611,12 @@ func (w *ActorWorkflow) ensureAteletRestored(ctx context.Context, actorRef resou if err != nil { return tele, err } + // The spec is about to be sent to atelet, so resolve referenced + // ClusterTrustBundles into it now; a missing or unusable bundle fails the + // actor start here, with an error naming the bundle. + if err := resolveClusterTrustBundles(w.clusterTrustBundleLister, actorTemplate, workloadSpec); err != nil { + return tele, err + } egressGateway := w.egressGateway() if local := actor.GetLocalSnapshotInfo(); local != nil { diff --git a/cmd/ateapi/internal/controlapi/workflow_suspend_test.go b/cmd/ateapi/internal/controlapi/workflow_suspend_test.go index 38c42c318..810129a20 100644 --- a/cmd/ateapi/internal/controlapi/workflow_suspend_test.go +++ b/cmd/ateapi/internal/controlapi/workflow_suspend_test.go @@ -679,7 +679,7 @@ func TestSuspendActor_PausedWithoutLocalSnapshotCrashes(t *testing.T) { }); err != nil { t.Fatalf("add template to indexer: %v", err) } - w := NewActorWorkflow(st, nil, nil, listersv1alpha1.NewActorTemplateLister(indexer), nil, nil, nil, nil, "", nil) + w := NewActorWorkflow(st, nil, nil, listersv1alpha1.NewActorTemplateLister(indexer), nil, nil, nil, nil, nil, "", nil) seedWorkflowActor(t, ctx, st, resources.ActorRef{Atespace: "team-a", Name: "id1"}, "ns", "tmpl1", ateapipb.Actor_STATUS_PAUSED) diff --git a/cmd/ateapi/internal/controlapi/workflow_testutil_test.go b/cmd/ateapi/internal/controlapi/workflow_testutil_test.go index b0afec726..ae013f5cc 100644 --- a/cmd/ateapi/internal/controlapi/workflow_testutil_test.go +++ b/cmd/ateapi/internal/controlapi/workflow_testutil_test.go @@ -42,7 +42,7 @@ func newTestActorWorkflow(t *testing.T, st store.Interface, tmplNamespace, tmplN }); err != nil { t.Fatalf("add template to indexer: %v", err) } - return NewActorWorkflow(st, nil, nil, listersv1alpha1.NewActorTemplateLister(indexer), nil, nil, nil, nil, "", nil) + return NewActorWorkflow(st, nil, nil, listersv1alpha1.NewActorTemplateLister(indexer), nil, nil, nil, nil, nil, "", nil) } // seedWorkflowActor stores an actor with the given status, bound to the given diff --git a/cmd/ateapi/internal/controlapi/workload_spec.go b/cmd/ateapi/internal/controlapi/workload_spec.go index b2420c368..7d1e61e8e 100644 --- a/cmd/ateapi/internal/controlapi/workload_spec.go +++ b/cmd/ateapi/internal/controlapi/workload_spec.go @@ -56,6 +56,18 @@ func workloadSpecFromActorTemplate(actorTemplate *atev1alpha1.ActorTemplate, act ActorMetadata: actorMetadata, }, }) + case dataSource.ClusterTrustBundle != nil: + // PemBundle stays empty here: resolveClusterTrustBundles + // fills it on the resume path, immediately before the spec + // is sent to atelet. Pause/suspend specs keep it empty — + // nothing reads system-info contents at checkpoint time. + ateletSystemInfo.DataSources = append(ateletSystemInfo.DataSources, &ateletpb.SystemInfoDataSource{ + DataSource: &ateletpb.SystemInfoDataSource_ClusterTrustBundle{ + ClusterTrustBundle: &ateletpb.ClusterTrustBundleDataSource{ + Path: dataSource.ClusterTrustBundle.Path, + }, + }, + }) default: continue // Drop unrecognized data sources } diff --git a/cmd/ateapi/internal/controlapi/workload_spec_test.go b/cmd/ateapi/internal/controlapi/workload_spec_test.go index 3e1b4a276..000945bd7 100644 --- a/cmd/ateapi/internal/controlapi/workload_spec_test.go +++ b/cmd/ateapi/internal/controlapi/workload_spec_test.go @@ -136,6 +136,62 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) { }, }, }, + { + name: "converts clusterTrustBundle data sources with unresolved bytes", + template: &atev1alpha1.ActorTemplate{ + ObjectMeta: metav1.ObjectMeta{Name: "tmpl1", Namespace: "agent-ns"}, + Spec: atev1alpha1.ActorTemplateSpec{ + Volumes: []atev1alpha1.Volume{ + { + Name: "system-info", + VolumeSource: atev1alpha1.VolumeSource{ + SystemInfo: &atev1alpha1.SystemInfoVolumeSource{ + DataSources: []atev1alpha1.SystemInfoDataSource{ + {ClusterTrustBundle: &atev1alpha1.ClusterTrustBundleDataSource{Name: "egress-trust", Path: "trust/ca.pem"}}, + }, + }, + }, + }, + }, + Containers: []atev1alpha1.Container{ + { + Name: "main", + Image: "main", + VolumeMounts: []atev1alpha1.VolumeMount{ + {Name: "system-info", MountPath: "/run/substrate/certs"}, + }, + }, + }, + }, + }, + // The bundle NAME does not cross the wire, and PemBundle stays + // empty: resolveClusterTrustBundles fills it on the resume path. + want: &ateletpb.WorkloadSpec{ + Volumes: []*ateletpb.Volume{ + { + Name: "system-info", + Source: &ateletpb.Volume_SystemInfo{ + SystemInfo: &ateletpb.SystemInfoVolume{ + DataSources: []*ateletpb.SystemInfoDataSource{ + {DataSource: &ateletpb.SystemInfoDataSource_ClusterTrustBundle{ + ClusterTrustBundle: &ateletpb.ClusterTrustBundleDataSource{Path: "trust/ca.pem"}, + }}, + }, + }, + }, + }, + }, + Containers: []*ateletpb.Container{ + { + Name: "main", + Image: "main", + VolumeMounts: []*ateletpb.VolumeMount{ + {Name: "system-info", MountPath: "/run/substrate/certs"}, + }, + }, + }, + }, + }, { name: "skips non-DurableDir volumes", template: &atev1alpha1.ActorTemplate{ diff --git a/cmd/ateapi/main.go b/cmd/ateapi/main.go index 31e119934..7d8ee3403 100644 --- a/cmd/ateapi/main.go +++ b/cmd/ateapi/main.go @@ -57,6 +57,7 @@ import ( "google.golang.org/grpc/reflection" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" + certlisters "k8s.io/client-go/listers/certificates/v1beta1" "k8s.io/client-go/rest" ) @@ -160,6 +161,19 @@ func main() { ateletPodInformerFactory, ateletPodInformer := controlapi.AteletInformer(clientset) scInformerFactory := informers.NewSharedInformerFactory(clientset, 0) storageClassLister := scInformerFactory.Storage().V1().StorageClasses().Lister() + // ClusterTrustBundles are resolved into SystemInfo volumes at actor + // start; the lister keeps that off the per-resume apiserver path. The + // v1beta1 API is feature-gated, so probe for it first: registering the + // informer against a cluster that does not serve it would hang the + // factory's WaitForCacheSync below and with it ateapi startup. Without + // the API the lister stays nil and actors that reference a + // clusterTrustBundle data source fail to start with a clear error. + clusterTrustBundleLister := certlisters.ClusterTrustBundleLister(nil) + if hasClusterTrustBundleAPI(clientset) { + clusterTrustBundleLister = scInformerFactory.Certificates().V1beta1().ClusterTrustBundles().Lister() + } else { + slog.WarnContext(ctx, "certificates.k8s.io/v1beta1 ClusterTrustBundles not served by this cluster; SystemInfo clusterTrustBundle data sources will fail actor start") + } syncer := controlapi.NewWorkerPoolSyncer(persistence, workerPodInformer, workerPoolLister) syncer.Start(ctx) @@ -190,7 +204,7 @@ func main() { volPlugins := make(map[string]volume.VolumePluginControlPlane) ateletDialer := controlapi.NewAteletDialer(workerPodInformer.GetIndexer(), ateletPodInformer.GetIndexer(), *ateletClientCredBundle, *podIdentityCACerts) - sm := controlapi.NewService(persistence, workerCache, actorTemplateLister, workerPoolLister, sandboxConfigLister, csiDriverConfigLister, storageClassLister, ateletDialer, instruments, *egressGatewayAddress, volPlugins) + sm := controlapi.NewService(persistence, workerCache, actorTemplateLister, workerPoolLister, sandboxConfigLister, csiDriverConfigLister, storageClassLister, clusterTrustBundleLister, ateletDialer, instruments, *egressGatewayAddress, volPlugins) jwtIssuerDiscoveryClient := buildK8sServiceAccountIssuerDiscoveryClient(ctx, *clientJWTCAFile, *clientJWTIssuer) @@ -582,3 +596,19 @@ func isInClusterKubernetesIssuer(issuer string) bool { } return u.Scheme == "https" && (u.Host == "kubernetes.default.svc" || u.Host == "kubernetes.default.svc.cluster.local") } + +// hasClusterTrustBundleAPI reports whether the cluster serves the +// clustertrustbundles resource (certificates.k8s.io/v1beta1 is feature-gated +// as of Kubernetes v1.36; hack/create-kind-cluster.sh enables it). +func hasClusterTrustBundleAPI(clientset kubernetes.Interface) bool { + resources, err := clientset.Discovery().ServerResourcesForGroupVersion("certificates.k8s.io/v1beta1") + if err != nil { + return false + } + for _, r := range resources.APIResources { + if r.Name == "clustertrustbundles" { + return true + } + } + return false +} diff --git a/cmd/atelet/main.go b/cmd/atelet/main.go index 6356f7120..22a965d13 100644 --- a/cmd/atelet/main.go +++ b/cmd/atelet/main.go @@ -1470,6 +1470,18 @@ func writeSystemInfoVolume(ctx context.Context, rootPath string, actorRef resour contents := map[string]atomicwriter.FileProjection{} for _, dataSourceAny := range si.GetDataSources() { switch dataSource := dataSourceAny.GetDataSource().(type) { + case *ateletpb.SystemInfoDataSource_ClusterTrustBundle: + ctb := dataSource.ClusterTrustBundle + // ateapi resolves the bundle before sending the spec; empty bytes + // mean it did not, and an empty trust file would fail the workload + // in far more confusing ways than failing the start does. + if len(ctb.GetPemBundle()) == 0 { + return fmt.Errorf("cluster trust bundle for %q has no resolved PEM bytes", ctb.GetPath()) + } + contents[ctb.GetPath()] = atomicwriter.FileProjection{ + Data: ctb.GetPemBundle(), + Mode: 0o644, + } case *ateletpb.SystemInfoDataSource_ActorMetadata: for _, item := range dataSource.ActorMetadata.GetItems() { var value string diff --git a/cmd/atelet/main_test.go b/cmd/atelet/main_test.go index 4eed97933..8b97eedb6 100644 --- a/cmd/atelet/main_test.go +++ b/cmd/atelet/main_test.go @@ -174,6 +174,45 @@ func TestWriteSystemInfoVolume(t *testing.T) { } } +func TestWriteSystemInfoVolume_ClusterTrustBundle(t *testing.T) { + ctx := context.Background() + pemBundle := []byte("-----BEGIN CERTIFICATE-----\nZmFrZQ==\n-----END CERTIFICATE-----\n") + si := &ateletpb.SystemInfoVolume{ + DataSources: []*ateletpb.SystemInfoDataSource{ + {DataSource: &ateletpb.SystemInfoDataSource_ClusterTrustBundle{ + ClusterTrustBundle: &ateletpb.ClusterTrustBundleDataSource{Path: "trust/ca.pem", PemBundle: pemBundle}, + }}, + }, + } + + root := filepath.Join(t.TempDir(), "system-info", "vol1") + ref := resources.ActorRef{Atespace: "team-a", Name: "actor-1"} + if err := writeSystemInfoVolume(ctx, root, ref, "uid-1", si); err != nil { + t.Fatalf("writeSystemInfoVolume: %v", err) + } + got, err := os.ReadFile(filepath.Join(root, "trust/ca.pem")) + if err != nil { + t.Fatalf("reading projected bundle: %v", err) + } + if string(got) != string(pemBundle) { + t.Errorf("content = %q, want %q", got, pemBundle) + } + + t.Run("unresolved bytes fail rather than write an empty trust file", func(t *testing.T) { + unresolved := &ateletpb.SystemInfoVolume{ + DataSources: []*ateletpb.SystemInfoDataSource{ + {DataSource: &ateletpb.SystemInfoDataSource_ClusterTrustBundle{ + ClusterTrustBundle: &ateletpb.ClusterTrustBundleDataSource{Path: "ca.pem"}, + }}, + }, + } + err := writeSystemInfoVolume(ctx, filepath.Join(t.TempDir(), "vol2"), ref, "uid-1", unresolved) + if err == nil || !strings.Contains(err.Error(), "no resolved PEM bytes") { + t.Errorf("writeSystemInfoVolume = %v, want no-resolved-PEM error", err) + } + }) +} + func TestWriteFileAtomic(t *testing.T) { dir := t.TempDir() target := filepath.Join(dir, "actor-id") diff --git a/docs/api-guide.md b/docs/api-guide.md index 0ad4555d0..0daa87962 100644 --- a/docs/api-guide.md +++ b/docs/api-guide.md @@ -190,6 +190,28 @@ spec: The values are delivered as files on a read-only per-actor bind mount, not environment variables, precisely so they carry the correct values after a resume from a shared snapshot — an env var (or a file baked into the image) would be frozen at the snapshot-source actor's values, since it lives in the checkpointed process memory, and would therefore be identical for every actor restored from that snapshot. The metadata fields themselves are fixed for the actor's lifetime, so workloads may cache them; future data sources that rotate (identity tokens and certificates) must be re-read at time of use. +#### clusterTrustBundle +The clusterTrustBundle data source projects the trust anchors of a named [ClusterTrustBundle](https://kubernetes.io/docs/reference/access-authn-authz/certificate-signing-requests/#cluster-trust-bundles) (`certificates.k8s.io/v1beta1`) to a single PEM file — analogous to the [Kubernetes clusterTrustBundle projected volume source](https://kubernetes.io/docs/concepts/storage/projected-volumes/#clustertrustbundle). + +```yaml +spec: + volumes: + - name: trust + systemInfo: + dataSources: + - clusterTrustBundle: + name: my-trust-bundle + path: ca.pem + containers: + - name: main + # ... + volumeMounts: + - name: trust + mountPath: /run/substrate/certs # the actor reads /run/substrate/certs/ca.pem +``` + +ateapi resolves the bundle when the actor starts and sanitizes it the way kubelet does for projections: only `CERTIFICATE` PEM blocks are kept, deduplicated, with block headers stripped. The actor itself never talks to the Kubernetes API. Starting the actor fails, with an error naming the bundle, if the referenced ClusterTrustBundle is missing, empty, or contains no certificates. Bundle contents are re-resolved on every Run/Restore; selection by `signerName`/label selector is not yet supported. + ### Container Fields Each entry in `containers` describes one process to run in the actor's sandbox. diff --git a/internal/e2e/fixtures/probe/main.go b/internal/e2e/fixtures/probe/main.go index 91ab4dc2d..143b2667c 100644 --- a/internal/e2e/fixtures/probe/main.go +++ b/internal/e2e/fixtures/probe/main.go @@ -27,12 +27,14 @@ import ( "os" ) -// The actorMetadata data-source files of the systemInfo volume that -// probe.yaml.tmpl mounts at /run/ate. +// The systemInfo volume data-source files that probe.yaml.tmpl mounts at +// /run/ate: the actorMetadata projections plus a clusterTrustBundle +// projection. const ( identityFile = "/run/ate/actor-id" atespaceFile = "/run/ate/atespace" uidFile = "/run/ate/actor-uid" + trustFile = "/run/ate/trust-bundle.pem" ) // whoami reports the actor's identity as observed at request time from the @@ -46,6 +48,7 @@ func whoami(w http.ResponseWriter, _ *http.Request) { "file": identityFile, "atespace": atespaceFile, "uid": uidFile, + "trust": trustFile, } { if b, err := os.ReadFile(path); err == nil { resp[key] = string(b) diff --git a/internal/e2e/fixtures/probe/probe.yaml.tmpl b/internal/e2e/fixtures/probe/probe.yaml.tmpl index a0fc50c4a..ccca587dd 100644 --- a/internal/e2e/fixtures/probe/probe.yaml.tmpl +++ b/internal/e2e/fixtures/probe/probe.yaml.tmpl @@ -15,7 +15,7 @@ apiVersion: v1 kind: Namespace metadata: - name: ate-e2e-probe + name: ${PROBE_NAMESPACE} --- @@ -23,22 +23,22 @@ apiVersion: ate.dev/v1alpha1 kind: WorkerPool metadata: name: probe - namespace: ate-e2e-probe + namespace: ${PROBE_NAMESPACE} labels: workload: probe spec: replicas: 3 - ateomImage: ko://github.com/agent-substrate/substrate/cmd/ateom-gvisor - + ateomImage: ${ATEOM_IMAGE} +${POOL_SANDBOX} --- apiVersion: ate.dev/v1alpha1 kind: ActorTemplate metadata: name: probe - namespace: ate-e2e-probe + namespace: ${PROBE_NAMESPACE} spec: - volumes: +${TEMPLATE_SANDBOX} volumes: - name: system-info systemInfo: dataSources: @@ -50,6 +50,11 @@ spec: path: atespace - field: uid path: actor-uid + # Created by the identity e2e suite before this template is applied; + # actors fail to start if the referenced bundle is missing. + - clusterTrustBundle: + name: ${TRUST_BUNDLE_NAME} + path: trust-bundle.pem containers: - name: probe image: ko://github.com/agent-substrate/substrate/internal/e2e/fixtures/probe @@ -70,4 +75,4 @@ spec: matchLabels: workload: probe snapshotsConfig: - location: gs://${BUCKET_NAME}/ate-e2e-probe/ + location: gs://${BUCKET_NAME}/${PROBE_NAMESPACE}/ diff --git a/internal/e2e/suites/identity/identity_test.go b/internal/e2e/suites/identity/identity_test.go index 742e22013..c09df16ce 100644 --- a/internal/e2e/suites/identity/identity_test.go +++ b/internal/e2e/suites/identity/identity_test.go @@ -16,8 +16,15 @@ package identity import ( "context" + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/x509" + "crypto/x509/pkix" "encoding/json" + "encoding/pem" "io" + "math/big" "net/http" "os" "path/filepath" @@ -29,24 +36,133 @@ import ( "github.com/agent-substrate/substrate/internal/resources" "github.com/agent-substrate/substrate/pkg/api/v1alpha1" "github.com/agent-substrate/substrate/pkg/proto/ateapipb" + certsv1beta1 "k8s.io/api/certificates/v1beta1" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -const ( - probeNamespace = "ate-e2e-probe" - probeTemplate = "probe" +const probeTemplate = "probe" + +// sandboxClass selects the runtime the probe runs on: "gvisor" (default) or +// "microvm". CI's micro-VM leg sets E2E_PROBE_SANDBOX_CLASS=microvm after +// staging the micro-VM runtime assets (see hack/run-microvm-demo-kind.sh); +// the microvm SandboxConfig must already exist in the cluster. The namespace +// and bundle name carry a per-class suffix so a micro-VM run cannot collide +// with a still-terminating gVisor run's resources. +var ( + sandboxClass = envOr("E2E_PROBE_SANDBOX_CLASS", "gvisor") + + probeNamespace = "ate-e2e-probe" + nsSuffix() + // trustBundleName is the ClusterTrustBundle probe.yaml.tmpl projects; the + // suite creates it before the template, because actors (including the + // template's snapshot boot) fail to start while it is missing. + trustBundleName = probeNamespace + "-trust" ) +func envOr(key, def string) string { + if v := os.Getenv(key); v != "" { + return v + } + return def +} + +func nsSuffix() string { + if sandboxClass == "microvm" { + return "-mvm" + } + return "" +} + type whoamiResponse struct { File string `json:"file"` Atespace string `json:"atespace"` UID string `json:"uid"` + Trust string `json:"trust"` Hostname string `json:"hostname"` // Error is the probe's file read error(s), if any, so a failed assertion // explains why a value was missing. Error string `json:"error"` } +// newTrustAnchorPEM mints a self-signed CA certificate, PEM-encoded. cn keeps +// successive anchors distinguishable in failure output. +func newTrustAnchorPEM(t *testing.T, cn string) string { + t.Helper() + key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + t.Fatalf("generating trust bundle key: %v", err) + } + tmpl := &x509.Certificate{ + SerialNumber: big.NewInt(1), + Subject: pkix.Name{CommonName: cn}, + NotBefore: time.Now().Add(-time.Hour), + NotAfter: time.Now().Add(24 * time.Hour), + IsCA: true, + BasicConstraintsValid: true, + KeyUsage: x509.KeyUsageCertSign, + } + der, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &key.PublicKey, key) + if err != nil { + t.Fatalf("creating trust bundle certificate: %v", err) + } + return string(pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: der})) +} + +// junkPEM is a non-certificate block; sanitization must drop it. +func junkPEM() string { + return string(pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: []byte("junk")})) +} + +// createTrustBundle creates the suite's ClusterTrustBundle with junk PEM and a +// duplicate certificate around one real certificate, and returns the sanitized +// PEM the projection must deliver — proving kubelet-style sanitization +// end-to-end, not just pass-through. +func createTrustBundle(t *testing.T, ctx context.Context, clients *e2e.Clients) string { + t.Helper() + certPEM := newTrustAnchorPEM(t, "ate-e2e-probe-trust") + + ctb := &certsv1beta1.ClusterTrustBundle{ + ObjectMeta: metav1.ObjectMeta{Name: trustBundleName}, + Spec: certsv1beta1.ClusterTrustBundleSpec{TrustBundle: junkPEM() + certPEM + certPEM}, + } + if _, err := clients.K8s.CertificatesV1beta1().ClusterTrustBundles().Create(ctx, ctb, metav1.CreateOptions{}); err != nil { + if !apierrors.IsAlreadyExists(err) { + t.Fatalf("creating ClusterTrustBundle %q: %v", trustBundleName, err) + } + // Leftover from an earlier failed run: replace its contents so the + // assertion below is against THIS run's certificate. + existing, getErr := clients.K8s.CertificatesV1beta1().ClusterTrustBundles().Get(ctx, trustBundleName, metav1.GetOptions{}) + if getErr != nil { + t.Fatalf("reading existing ClusterTrustBundle %q: %v", trustBundleName, getErr) + } + existing.Spec.TrustBundle = ctb.Spec.TrustBundle + if _, err := clients.K8s.CertificatesV1beta1().ClusterTrustBundles().Update(ctx, existing, metav1.UpdateOptions{}); err != nil { + t.Fatalf("updating ClusterTrustBundle %q: %v", trustBundleName, err) + } + } + t.Cleanup(func() { + _ = clients.K8s.CertificatesV1beta1().ClusterTrustBundles().Delete(context.Background(), trustBundleName, metav1.DeleteOptions{}) + }) + return certPEM +} + +// rotateTrustBundle replaces the suite bundle's contents with a fresh trust +// anchor (again wrapped in junk to keep sanitization honest) and returns the +// new sanitized PEM. +func rotateTrustBundle(t *testing.T, ctx context.Context, clients *e2e.Clients) string { + t.Helper() + certPEM := newTrustAnchorPEM(t, "ate-e2e-probe-trust-rotated") + existing, err := clients.K8s.CertificatesV1beta1().ClusterTrustBundles().Get(ctx, trustBundleName, metav1.GetOptions{}) + if err != nil { + t.Fatalf("reading ClusterTrustBundle %q for rotation: %v", trustBundleName, err) + } + existing.Spec.TrustBundle = junkPEM() + certPEM + if _, err := clients.K8s.CertificatesV1beta1().ClusterTrustBundles().Update(ctx, existing, metav1.UpdateOptions{}); err != nil { + t.Fatalf("rotating ClusterTrustBundle %q: %v", trustBundleName, err) + } + return certPEM +} + // TestActorIdentity_AfterRestore_IsOwnID_NotGolden is the regression gate for // per-actor identity. The env-var approach passed unit tests and config.json // inspection yet was broken at runtime: actors restored from the shared golden @@ -61,6 +177,7 @@ func TestActorIdentity_AfterRestore_IsOwnID_NotGolden(t *testing.T) { ctx := context.Background() clients := e2e.GetClients() + wantTrust := createTrustBundle(t, ctx, clients) deployProbe(t, env["BUCKET_NAME"]) golden := waitForGolden(t, ctx, clients) @@ -96,6 +213,12 @@ func TestActorIdentity_AfterRestore_IsOwnID_NotGolden(t *testing.T) { t.Errorf("actor %q: /run/ate/atespace = %q, want %q (probe read error: %q)", id, got.Atespace, probeNamespace, got.Error) } + // The projected trust bundle must be the sanitized PEM: junk blocks + // and the duplicate certificate from the ClusterTrustBundle dropped. + if got.Trust != wantTrust { + t.Errorf("actor %q: /run/ate/trust-bundle.pem = %q, want the sanitized bundle %q (probe read error: %q)", id, got.Trust, wantTrust, got.Error) + } + // The projected UID must match the control plane's authoritative view // of this actor, and be distinct per actor even though both actors // were seeded from the same golden snapshot. @@ -111,6 +234,29 @@ func TestActorIdentity_AfterRestore_IsOwnID_NotGolden(t *testing.T) { } seenUIDs[got.UID] = id } + + // Refresh-on-resume: rotate the bundle, cycle one actor through + // suspend/resume, and assert it observes the NEW sanitized contents — + // the "bundle contents refresh on every Run/Restore" semantic, end to + // end. (Live propagation to running actors, without a resume, is #932 + // PR 2; until then a running actor's file is the bundle as of its last + // Run/Restore.) + rotated := rotateTrustBundle(t, ctx, clients) + id := ids[0] + if _, err := clients.SubstrateAPI.SuspendActor(ctx, &ateapipb.SuspendActorRequest{Actor: &ateapipb.ObjectRef{Atespace: probeNamespace, Name: id}}); err != nil { + t.Fatalf("SuspendActor %q: %v", id, err) + } + if _, err := clients.SubstrateAPI.ResumeActor(ctx, &ateapipb.ResumeActorRequest{Actor: &ateapipb.ObjectRef{Atespace: probeNamespace, Name: id}}); err != nil { + t.Fatalf("ResumeActor %q after bundle rotation: %v", id, err) + } + got := whoami(t, ctx, rc, id) + if got.Trust != rotated { + t.Errorf("actor %q after rotation+resume: trust = %q, want the rotated bundle %q (probe read error: %q)", id, got.Trust, rotated, got.Error) + } + // The actor's own identity must survive the extra suspend/resume cycle. + if got.File != id { + t.Errorf("actor %q after rotation+resume: /run/ate/actor-id = %q, want %q", id, got.File, id) + } } func deployProbe(t *testing.T, bucket string) { @@ -127,7 +273,23 @@ func deployProbe(t *testing.T, bucket string) { t.Fatalf("reading probe manifest template: %v", err) } manifest := filepath.Join(t.TempDir(), "probe.yaml") - rendered := strings.ReplaceAll(string(tmpl), "${BUCKET_NAME}", bucket) + poolSandbox, templateSandbox, ateomImage := "", "", "ko://github.com/agent-substrate/substrate/cmd/ateom-gvisor" + if sandboxClass == "microvm" { + poolSandbox = " sandboxClass: microvm\n sandboxConfigName: microvm\n" + templateSandbox = " sandboxClass: microvm\n" + ateomImage = "ko://github.com/agent-substrate/substrate/cmd/ateom-microvm" + } + rendered := string(tmpl) + for key, value := range map[string]string{ + "${BUCKET_NAME}": bucket, + "${PROBE_NAMESPACE}": probeNamespace, + "${TRUST_BUNDLE_NAME}": trustBundleName, + "${ATEOM_IMAGE}": ateomImage, + "${POOL_SANDBOX}": poolSandbox, + "${TEMPLATE_SANDBOX}": templateSandbox, + } { + rendered = strings.ReplaceAll(rendered, key, value) + } if err := os.WriteFile(manifest, []byte(rendered), 0o644); err != nil { t.Fatalf("writing rendered probe manifest: %v", err) } @@ -162,7 +324,17 @@ func deployProbe(t *testing.T, bucket string) { func waitForGolden(t *testing.T, ctx context.Context, clients *e2e.Clients) string { t.Helper() - deadline := time.Now().Add(5 * time.Minute) + // Micro-VM golden boots are slower; CI raises this via + // E2E_PROBE_READY_TIMEOUT, mirroring the demo suite's knob. + readyTimeout := 5 * time.Minute + if v := os.Getenv("E2E_PROBE_READY_TIMEOUT"); v != "" { + parsed, perr := time.ParseDuration(v) + if perr != nil { + t.Fatalf("invalid E2E_PROBE_READY_TIMEOUT %q: %v", v, perr) + } + readyTimeout = parsed + } + deadline := time.Now().Add(readyTimeout) for time.Now().Before(deadline) { at, err := clients.SubstrateK8s.ApiV1alpha1().ActorTemplates(probeNamespace).Get(ctx, probeTemplate, metav1.GetOptions{}) if err == nil { diff --git a/internal/pemutil/pemutil.go b/internal/pemutil/pemutil.go new file mode 100644 index 000000000..4012ab5a2 --- /dev/null +++ b/internal/pemutil/pemutil.go @@ -0,0 +1,54 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package pemutil sanitizes PEM certificate bundles for projection into +// actors, the way kubelet does for clusterTrustBundle projected volumes. +package pemutil + +import ( + "crypto/sha256" + "encoding/pem" + "fmt" +) + +// SanitizeCertificateBundle re-encodes a PEM bundle keeping only CERTIFICATE +// blocks, with block headers stripped and exact duplicates (by DER bytes) +// removed, preserving first-seen order. It returns an error if the input +// contains no CERTIFICATE blocks at all — an empty trust bundle is never +// what a workload should silently receive. +func SanitizeCertificateBundle(in []byte) ([]byte, error) { + var out []byte + seen := map[[sha256.Size]byte]bool{} + rest := in + for { + var block *pem.Block + block, rest = pem.Decode(rest) + if block == nil { + break + } + if block.Type != "CERTIFICATE" { + continue + } + key := sha256.Sum256(block.Bytes) + if seen[key] { + continue + } + seen[key] = true + out = append(out, pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: block.Bytes})...) + } + if len(out) == 0 { + return nil, fmt.Errorf("bundle contains no CERTIFICATE PEM blocks") + } + return out, nil +} diff --git a/internal/pemutil/pemutil_test.go b/internal/pemutil/pemutil_test.go new file mode 100644 index 000000000..612848630 --- /dev/null +++ b/internal/pemutil/pemutil_test.go @@ -0,0 +1,90 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pemutil + +import ( + "bytes" + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "math/big" + "testing" + "time" +) + +// selfSignedCertPEM mints a throwaway self-signed certificate, PEM-encoded. +func selfSignedCertPEM(t *testing.T, cn string) []byte { + t.Helper() + key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + t.Fatal(err) + } + tmpl := &x509.Certificate{ + SerialNumber: big.NewInt(1), + Subject: pkix.Name{CommonName: cn}, + NotBefore: time.Now(), + NotAfter: time.Now().Add(time.Hour), + } + der, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &key.PublicKey, key) + if err != nil { + t.Fatal(err) + } + return pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: der}) +} + +func TestSanitizeCertificateBundle(t *testing.T) { + certA := selfSignedCertPEM(t, "a") + certB := selfSignedCertPEM(t, "b") + + junkKey := pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: []byte("not-a-cert")}) + withHeaders := func(certPEM []byte) []byte { + block, _ := pem.Decode(certPEM) + block.Headers = map[string]string{"Comment": "should be stripped"} + return pem.EncodeToMemory(block) + } + + t.Run("keeps only certificates, strips headers, dedupes", func(t *testing.T) { + in := bytes.Join([][]byte{ + []byte("leading garbage\n"), + withHeaders(certA), + junkKey, + certB, + certA, // duplicate + }, nil) + got, err := SanitizeCertificateBundle(in) + if err != nil { + t.Fatalf("SanitizeCertificateBundle: %v", err) + } + want := append(append([]byte(nil), certA...), certB...) + if !bytes.Equal(got, want) { + t.Errorf("sanitized bundle mismatch:\ngot:\n%s\nwant:\n%s", got, want) + } + }) + + t.Run("errors when no certificates present", func(t *testing.T) { + for name, in := range map[string][]byte{ + "empty": nil, + "junk only": junkKey, + "not pem": []byte("hello"), + } { + if _, err := SanitizeCertificateBundle(in); err == nil { + t.Errorf("%s: SanitizeCertificateBundle = nil error, want error", name) + } + } + }) +} diff --git a/internal/proto/ateletpb/atelet.pb.go b/internal/proto/ateletpb/atelet.pb.go index 2f0250b4c..265e27900 100644 --- a/internal/proto/ateletpb/atelet.pb.go +++ b/internal/proto/ateletpb/atelet.pb.go @@ -884,11 +884,69 @@ func (x *ActorMetadataDataSource) GetItems() []*ActorMetadataItem { return nil } +// ClusterTrustBundleDataSource writes an already-resolved PEM certificate +// bundle to a file at the given path, relative to the root of the enclosing +// system-info volume. ateapi resolves and sanitizes the referenced +// ClusterTrustBundle before sending the spec; atelet only writes the bytes +// and never talks to the Kubernetes API. +type ClusterTrustBundleDataSource struct { + state protoimpl.MessageState `protogen:"open.v1"` + Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + PemBundle []byte `protobuf:"bytes,2,opt,name=pem_bundle,json=pemBundle,proto3" json:"pem_bundle,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ClusterTrustBundleDataSource) Reset() { + *x = ClusterTrustBundleDataSource{} + mi := &file_atelet_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ClusterTrustBundleDataSource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClusterTrustBundleDataSource) ProtoMessage() {} + +func (x *ClusterTrustBundleDataSource) ProtoReflect() protoreflect.Message { + mi := &file_atelet_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClusterTrustBundleDataSource.ProtoReflect.Descriptor instead. +func (*ClusterTrustBundleDataSource) Descriptor() ([]byte, []int) { + return file_atelet_proto_rawDescGZIP(), []int{12} +} + +func (x *ClusterTrustBundleDataSource) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *ClusterTrustBundleDataSource) GetPemBundle() []byte { + if x != nil { + return x.PemBundle + } + return nil +} + type SystemInfoDataSource struct { state protoimpl.MessageState `protogen:"open.v1"` // Types that are valid to be assigned to DataSource: // // *SystemInfoDataSource_ActorMetadata + // *SystemInfoDataSource_ClusterTrustBundle DataSource isSystemInfoDataSource_DataSource `protobuf_oneof:"data_source"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -896,7 +954,7 @@ type SystemInfoDataSource struct { func (x *SystemInfoDataSource) Reset() { *x = SystemInfoDataSource{} - mi := &file_atelet_proto_msgTypes[12] + mi := &file_atelet_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -908,7 +966,7 @@ func (x *SystemInfoDataSource) String() string { func (*SystemInfoDataSource) ProtoMessage() {} func (x *SystemInfoDataSource) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[12] + mi := &file_atelet_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -921,7 +979,7 @@ func (x *SystemInfoDataSource) ProtoReflect() protoreflect.Message { // Deprecated: Use SystemInfoDataSource.ProtoReflect.Descriptor instead. func (*SystemInfoDataSource) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{12} + return file_atelet_proto_rawDescGZIP(), []int{13} } func (x *SystemInfoDataSource) GetDataSource() isSystemInfoDataSource_DataSource { @@ -940,6 +998,15 @@ func (x *SystemInfoDataSource) GetActorMetadata() *ActorMetadataDataSource { return nil } +func (x *SystemInfoDataSource) GetClusterTrustBundle() *ClusterTrustBundleDataSource { + if x != nil { + if x, ok := x.DataSource.(*SystemInfoDataSource_ClusterTrustBundle); ok { + return x.ClusterTrustBundle + } + } + return nil +} + type isSystemInfoDataSource_DataSource interface { isSystemInfoDataSource_DataSource() } @@ -948,8 +1015,14 @@ type SystemInfoDataSource_ActorMetadata struct { ActorMetadata *ActorMetadataDataSource `protobuf:"bytes,1,opt,name=actor_metadata,json=actorMetadata,proto3,oneof"` } +type SystemInfoDataSource_ClusterTrustBundle struct { + ClusterTrustBundle *ClusterTrustBundleDataSource `protobuf:"bytes,2,opt,name=cluster_trust_bundle,json=clusterTrustBundle,proto3,oneof"` +} + func (*SystemInfoDataSource_ActorMetadata) isSystemInfoDataSource_DataSource() {} +func (*SystemInfoDataSource_ClusterTrustBundle) isSystemInfoDataSource_DataSource() {} + // SystemInfoVolume is a read-only volume whose files are generated by atelet // on every Run/Restore, so they carry the values of the actor actually being // started, whatever checkpointed state it boots from. @@ -962,7 +1035,7 @@ type SystemInfoVolume struct { func (x *SystemInfoVolume) Reset() { *x = SystemInfoVolume{} - mi := &file_atelet_proto_msgTypes[13] + mi := &file_atelet_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -974,7 +1047,7 @@ func (x *SystemInfoVolume) String() string { func (*SystemInfoVolume) ProtoMessage() {} func (x *SystemInfoVolume) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[13] + mi := &file_atelet_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -987,7 +1060,7 @@ func (x *SystemInfoVolume) ProtoReflect() protoreflect.Message { // Deprecated: Use SystemInfoVolume.ProtoReflect.Descriptor instead. func (*SystemInfoVolume) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{13} + return file_atelet_proto_rawDescGZIP(), []int{14} } func (x *SystemInfoVolume) GetDataSources() []*SystemInfoDataSource { @@ -1012,7 +1085,7 @@ type Volume struct { func (x *Volume) Reset() { *x = Volume{} - mi := &file_atelet_proto_msgTypes[14] + mi := &file_atelet_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1024,7 +1097,7 @@ func (x *Volume) String() string { func (*Volume) ProtoMessage() {} func (x *Volume) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[14] + mi := &file_atelet_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1037,7 +1110,7 @@ func (x *Volume) ProtoReflect() protoreflect.Message { // Deprecated: Use Volume.ProtoReflect.Descriptor instead. func (*Volume) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{14} + return file_atelet_proto_rawDescGZIP(), []int{15} } func (x *Volume) GetName() string { @@ -1113,7 +1186,7 @@ type VolumeMount struct { func (x *VolumeMount) Reset() { *x = VolumeMount{} - mi := &file_atelet_proto_msgTypes[15] + mi := &file_atelet_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1125,7 +1198,7 @@ func (x *VolumeMount) String() string { func (*VolumeMount) ProtoMessage() {} func (x *VolumeMount) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[15] + mi := &file_atelet_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1138,7 +1211,7 @@ func (x *VolumeMount) ProtoReflect() protoreflect.Message { // Deprecated: Use VolumeMount.ProtoReflect.Descriptor instead. func (*VolumeMount) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{15} + return file_atelet_proto_rawDescGZIP(), []int{16} } func (x *VolumeMount) GetName() string { @@ -1170,7 +1243,7 @@ type Container struct { func (x *Container) Reset() { *x = Container{} - mi := &file_atelet_proto_msgTypes[16] + mi := &file_atelet_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1182,7 +1255,7 @@ func (x *Container) String() string { func (*Container) ProtoMessage() {} func (x *Container) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[16] + mi := &file_atelet_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1195,7 +1268,7 @@ func (x *Container) ProtoReflect() protoreflect.Message { // Deprecated: Use Container.ProtoReflect.Descriptor instead. func (*Container) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{16} + return file_atelet_proto_rawDescGZIP(), []int{17} } func (x *Container) GetName() string { @@ -1257,7 +1330,7 @@ type EnvEntry struct { func (x *EnvEntry) Reset() { *x = EnvEntry{} - mi := &file_atelet_proto_msgTypes[17] + mi := &file_atelet_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1269,7 +1342,7 @@ func (x *EnvEntry) String() string { func (*EnvEntry) ProtoMessage() {} func (x *EnvEntry) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[17] + mi := &file_atelet_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1282,7 +1355,7 @@ func (x *EnvEntry) ProtoReflect() protoreflect.Message { // Deprecated: Use EnvEntry.ProtoReflect.Descriptor instead. func (*EnvEntry) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{17} + return file_atelet_proto_rawDescGZIP(), []int{18} } func (x *EnvEntry) GetName() string { @@ -1313,7 +1386,7 @@ type Readyz struct { func (x *Readyz) Reset() { *x = Readyz{} - mi := &file_atelet_proto_msgTypes[18] + mi := &file_atelet_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1325,7 +1398,7 @@ func (x *Readyz) String() string { func (*Readyz) ProtoMessage() {} func (x *Readyz) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[18] + mi := &file_atelet_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1338,7 +1411,7 @@ func (x *Readyz) ProtoReflect() protoreflect.Message { // Deprecated: Use Readyz.ProtoReflect.Descriptor instead. func (*Readyz) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{18} + return file_atelet_proto_rawDescGZIP(), []int{19} } func (x *Readyz) GetHttpGet() *HTTPGetAction { @@ -1368,7 +1441,7 @@ type HTTPGetAction struct { func (x *HTTPGetAction) Reset() { *x = HTTPGetAction{} - mi := &file_atelet_proto_msgTypes[19] + mi := &file_atelet_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1380,7 +1453,7 @@ func (x *HTTPGetAction) String() string { func (*HTTPGetAction) ProtoMessage() {} func (x *HTTPGetAction) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[19] + mi := &file_atelet_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1393,7 +1466,7 @@ func (x *HTTPGetAction) ProtoReflect() protoreflect.Message { // Deprecated: Use HTTPGetAction.ProtoReflect.Descriptor instead. func (*HTTPGetAction) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{19} + return file_atelet_proto_rawDescGZIP(), []int{20} } func (x *HTTPGetAction) GetPath() string { @@ -1418,7 +1491,7 @@ type RunResponse struct { func (x *RunResponse) Reset() { *x = RunResponse{} - mi := &file_atelet_proto_msgTypes[20] + mi := &file_atelet_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1430,7 +1503,7 @@ func (x *RunResponse) String() string { func (*RunResponse) ProtoMessage() {} func (x *RunResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[20] + mi := &file_atelet_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1443,7 +1516,7 @@ func (x *RunResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RunResponse.ProtoReflect.Descriptor instead. func (*RunResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{20} + return file_atelet_proto_rawDescGZIP(), []int{21} } type LocalCheckpointConfiguration struct { @@ -1459,7 +1532,7 @@ type LocalCheckpointConfiguration struct { func (x *LocalCheckpointConfiguration) Reset() { *x = LocalCheckpointConfiguration{} - mi := &file_atelet_proto_msgTypes[21] + mi := &file_atelet_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1471,7 +1544,7 @@ func (x *LocalCheckpointConfiguration) String() string { func (*LocalCheckpointConfiguration) ProtoMessage() {} func (x *LocalCheckpointConfiguration) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[21] + mi := &file_atelet_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1484,7 +1557,7 @@ func (x *LocalCheckpointConfiguration) ProtoReflect() protoreflect.Message { // Deprecated: Use LocalCheckpointConfiguration.ProtoReflect.Descriptor instead. func (*LocalCheckpointConfiguration) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{21} + return file_atelet_proto_rawDescGZIP(), []int{22} } func (x *LocalCheckpointConfiguration) GetSnapshotName() string { @@ -1505,7 +1578,7 @@ type ExternalCheckpointConfiguration struct { func (x *ExternalCheckpointConfiguration) Reset() { *x = ExternalCheckpointConfiguration{} - mi := &file_atelet_proto_msgTypes[22] + mi := &file_atelet_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1517,7 +1590,7 @@ func (x *ExternalCheckpointConfiguration) String() string { func (*ExternalCheckpointConfiguration) ProtoMessage() {} func (x *ExternalCheckpointConfiguration) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[22] + mi := &file_atelet_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1530,7 +1603,7 @@ func (x *ExternalCheckpointConfiguration) ProtoReflect() protoreflect.Message { // Deprecated: Use ExternalCheckpointConfiguration.ProtoReflect.Descriptor instead. func (*ExternalCheckpointConfiguration) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{22} + return file_atelet_proto_rawDescGZIP(), []int{23} } func (x *ExternalCheckpointConfiguration) GetSnapshotUri() string { @@ -1568,7 +1641,7 @@ type CheckpointRequest struct { func (x *CheckpointRequest) Reset() { *x = CheckpointRequest{} - mi := &file_atelet_proto_msgTypes[23] + mi := &file_atelet_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1580,7 +1653,7 @@ func (x *CheckpointRequest) String() string { func (*CheckpointRequest) ProtoMessage() {} func (x *CheckpointRequest) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[23] + mi := &file_atelet_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1593,7 +1666,7 @@ func (x *CheckpointRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CheckpointRequest.ProtoReflect.Descriptor instead. func (*CheckpointRequest) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{23} + return file_atelet_proto_rawDescGZIP(), []int{24} } func (x *CheckpointRequest) GetTargetAteomUid() string { @@ -1708,7 +1781,7 @@ type CheckpointResponse struct { func (x *CheckpointResponse) Reset() { *x = CheckpointResponse{} - mi := &file_atelet_proto_msgTypes[24] + mi := &file_atelet_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1720,7 +1793,7 @@ func (x *CheckpointResponse) String() string { func (*CheckpointResponse) ProtoMessage() {} func (x *CheckpointResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[24] + mi := &file_atelet_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1733,7 +1806,7 @@ func (x *CheckpointResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CheckpointResponse.ProtoReflect.Descriptor instead. func (*CheckpointResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{24} + return file_atelet_proto_rawDescGZIP(), []int{25} } type UploadPausedCheckpointRequest struct { @@ -1761,7 +1834,7 @@ type UploadPausedCheckpointRequest struct { func (x *UploadPausedCheckpointRequest) Reset() { *x = UploadPausedCheckpointRequest{} - mi := &file_atelet_proto_msgTypes[25] + mi := &file_atelet_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1773,7 +1846,7 @@ func (x *UploadPausedCheckpointRequest) String() string { func (*UploadPausedCheckpointRequest) ProtoMessage() {} func (x *UploadPausedCheckpointRequest) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[25] + mi := &file_atelet_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1786,7 +1859,7 @@ func (x *UploadPausedCheckpointRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UploadPausedCheckpointRequest.ProtoReflect.Descriptor instead. func (*UploadPausedCheckpointRequest) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{25} + return file_atelet_proto_rawDescGZIP(), []int{26} } func (x *UploadPausedCheckpointRequest) GetAtespace() string { @@ -1853,7 +1926,7 @@ type UploadPausedCheckpointResponse struct { func (x *UploadPausedCheckpointResponse) Reset() { *x = UploadPausedCheckpointResponse{} - mi := &file_atelet_proto_msgTypes[26] + mi := &file_atelet_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1865,7 +1938,7 @@ func (x *UploadPausedCheckpointResponse) String() string { func (*UploadPausedCheckpointResponse) ProtoMessage() {} func (x *UploadPausedCheckpointResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[26] + mi := &file_atelet_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1878,7 +1951,7 @@ func (x *UploadPausedCheckpointResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UploadPausedCheckpointResponse.ProtoReflect.Descriptor instead. func (*UploadPausedCheckpointResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{26} + return file_atelet_proto_rawDescGZIP(), []int{27} } type RestoreRequest struct { @@ -1918,7 +1991,7 @@ type RestoreRequest struct { func (x *RestoreRequest) Reset() { *x = RestoreRequest{} - mi := &file_atelet_proto_msgTypes[27] + mi := &file_atelet_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1930,7 +2003,7 @@ func (x *RestoreRequest) String() string { func (*RestoreRequest) ProtoMessage() {} func (x *RestoreRequest) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[27] + mi := &file_atelet_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1943,7 +2016,7 @@ func (x *RestoreRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RestoreRequest.ProtoReflect.Descriptor instead. func (*RestoreRequest) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{27} + return file_atelet_proto_rawDescGZIP(), []int{28} } func (x *RestoreRequest) GetTargetAteomUid() string { @@ -2072,7 +2145,7 @@ type RestoreResponse struct { func (x *RestoreResponse) Reset() { *x = RestoreResponse{} - mi := &file_atelet_proto_msgTypes[28] + mi := &file_atelet_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2084,7 +2157,7 @@ func (x *RestoreResponse) String() string { func (*RestoreResponse) ProtoMessage() {} func (x *RestoreResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[28] + mi := &file_atelet_proto_msgTypes[29] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2097,7 +2170,7 @@ func (x *RestoreResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RestoreResponse.ProtoReflect.Descriptor instead. func (*RestoreResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{28} + return file_atelet_proto_rawDescGZIP(), []int{29} } var File_atelet_proto protoreflect.FileDescriptor @@ -2161,9 +2234,14 @@ const file_atelet_proto_rawDesc = "" + "\x05field\x18\x01 \x01(\x0e2\x1a.atelet.ActorMetadataFieldR\x05field\x12\x12\n" + "\x04path\x18\x02 \x01(\tR\x04path\"J\n" + "\x17ActorMetadataDataSource\x12/\n" + - "\x05items\x18\x01 \x03(\v2\x19.atelet.ActorMetadataItemR\x05items\"o\n" + + "\x05items\x18\x01 \x03(\v2\x19.atelet.ActorMetadataItemR\x05items\"Q\n" + + "\x1cClusterTrustBundleDataSource\x12\x12\n" + + "\x04path\x18\x01 \x01(\tR\x04path\x12\x1d\n" + + "\n" + + "pem_bundle\x18\x02 \x01(\fR\tpemBundle\"\xc9\x01\n" + "\x14SystemInfoDataSource\x12H\n" + - "\x0eactor_metadata\x18\x01 \x01(\v2\x1f.atelet.ActorMetadataDataSourceH\x00R\ractorMetadataB\r\n" + + "\x0eactor_metadata\x18\x01 \x01(\v2\x1f.atelet.ActorMetadataDataSourceH\x00R\ractorMetadata\x12X\n" + + "\x14cluster_trust_bundle\x18\x02 \x01(\v2$.atelet.ClusterTrustBundleDataSourceH\x00R\x12clusterTrustBundleB\r\n" + "\vdata_source\"S\n" + "\x10SystemInfoVolume\x12?\n" + "\fdata_sources\x18\x01 \x03(\v2\x1c.atelet.SystemInfoDataSourceR\vdataSources\"\xdc\x01\n" + @@ -2283,7 +2361,7 @@ func file_atelet_proto_rawDescGZIP() []byte { } var file_atelet_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_atelet_proto_msgTypes = make([]protoimpl.MessageInfo, 32) +var file_atelet_proto_msgTypes = make([]protoimpl.MessageInfo, 33) var file_atelet_proto_goTypes = []any{ (ActorMetadataField)(0), // 0: atelet.ActorMetadataField (CheckpointType)(0), // 1: atelet.CheckpointType @@ -2300,76 +2378,78 @@ var file_atelet_proto_goTypes = []any{ (*ExternalVolumeSource)(nil), // 12: atelet.ExternalVolumeSource (*ActorMetadataItem)(nil), // 13: atelet.ActorMetadataItem (*ActorMetadataDataSource)(nil), // 14: atelet.ActorMetadataDataSource - (*SystemInfoDataSource)(nil), // 15: atelet.SystemInfoDataSource - (*SystemInfoVolume)(nil), // 16: atelet.SystemInfoVolume - (*Volume)(nil), // 17: atelet.Volume - (*VolumeMount)(nil), // 18: atelet.VolumeMount - (*Container)(nil), // 19: atelet.Container - (*EnvEntry)(nil), // 20: atelet.EnvEntry - (*Readyz)(nil), // 21: atelet.Readyz - (*HTTPGetAction)(nil), // 22: atelet.HTTPGetAction - (*RunResponse)(nil), // 23: atelet.RunResponse - (*LocalCheckpointConfiguration)(nil), // 24: atelet.LocalCheckpointConfiguration - (*ExternalCheckpointConfiguration)(nil), // 25: atelet.ExternalCheckpointConfiguration - (*CheckpointRequest)(nil), // 26: atelet.CheckpointRequest - (*CheckpointResponse)(nil), // 27: atelet.CheckpointResponse - (*UploadPausedCheckpointRequest)(nil), // 28: atelet.UploadPausedCheckpointRequest - (*UploadPausedCheckpointResponse)(nil), // 29: atelet.UploadPausedCheckpointResponse - (*RestoreRequest)(nil), // 30: atelet.RestoreRequest - (*RestoreResponse)(nil), // 31: atelet.RestoreResponse - nil, // 32: atelet.ArchAssets.FilesEntry - nil, // 33: atelet.SandboxAssets.AssetsEntry - nil, // 34: atelet.ExternalVolumeSource.VolumeContextEntry + (*ClusterTrustBundleDataSource)(nil), // 15: atelet.ClusterTrustBundleDataSource + (*SystemInfoDataSource)(nil), // 16: atelet.SystemInfoDataSource + (*SystemInfoVolume)(nil), // 17: atelet.SystemInfoVolume + (*Volume)(nil), // 18: atelet.Volume + (*VolumeMount)(nil), // 19: atelet.VolumeMount + (*Container)(nil), // 20: atelet.Container + (*EnvEntry)(nil), // 21: atelet.EnvEntry + (*Readyz)(nil), // 22: atelet.Readyz + (*HTTPGetAction)(nil), // 23: atelet.HTTPGetAction + (*RunResponse)(nil), // 24: atelet.RunResponse + (*LocalCheckpointConfiguration)(nil), // 25: atelet.LocalCheckpointConfiguration + (*ExternalCheckpointConfiguration)(nil), // 26: atelet.ExternalCheckpointConfiguration + (*CheckpointRequest)(nil), // 27: atelet.CheckpointRequest + (*CheckpointResponse)(nil), // 28: atelet.CheckpointResponse + (*UploadPausedCheckpointRequest)(nil), // 29: atelet.UploadPausedCheckpointRequest + (*UploadPausedCheckpointResponse)(nil), // 30: atelet.UploadPausedCheckpointResponse + (*RestoreRequest)(nil), // 31: atelet.RestoreRequest + (*RestoreResponse)(nil), // 32: atelet.RestoreResponse + nil, // 33: atelet.ArchAssets.FilesEntry + nil, // 34: atelet.SandboxAssets.AssetsEntry + nil, // 35: atelet.ExternalVolumeSource.VolumeContextEntry } var file_atelet_proto_depIdxs = []int32{ 10, // 0: atelet.RunRequest.spec:type_name -> atelet.WorkloadSpec 9, // 1: atelet.RunRequest.sandbox_assets:type_name -> atelet.SandboxAssets 6, // 2: atelet.RunRequest.egress_gateway:type_name -> atelet.EgressGateway - 32, // 3: atelet.ArchAssets.files:type_name -> atelet.ArchAssets.FilesEntry - 33, // 4: atelet.SandboxAssets.assets:type_name -> atelet.SandboxAssets.AssetsEntry - 19, // 5: atelet.WorkloadSpec.containers:type_name -> atelet.Container - 17, // 6: atelet.WorkloadSpec.volumes:type_name -> atelet.Volume - 34, // 7: atelet.ExternalVolumeSource.volume_context:type_name -> atelet.ExternalVolumeSource.VolumeContextEntry + 33, // 3: atelet.ArchAssets.files:type_name -> atelet.ArchAssets.FilesEntry + 34, // 4: atelet.SandboxAssets.assets:type_name -> atelet.SandboxAssets.AssetsEntry + 20, // 5: atelet.WorkloadSpec.containers:type_name -> atelet.Container + 18, // 6: atelet.WorkloadSpec.volumes:type_name -> atelet.Volume + 35, // 7: atelet.ExternalVolumeSource.volume_context:type_name -> atelet.ExternalVolumeSource.VolumeContextEntry 0, // 8: atelet.ActorMetadataItem.field:type_name -> atelet.ActorMetadataField 13, // 9: atelet.ActorMetadataDataSource.items:type_name -> atelet.ActorMetadataItem 14, // 10: atelet.SystemInfoDataSource.actor_metadata:type_name -> atelet.ActorMetadataDataSource - 15, // 11: atelet.SystemInfoVolume.data_sources:type_name -> atelet.SystemInfoDataSource - 11, // 12: atelet.Volume.durable_dir:type_name -> atelet.DurableDirVolume - 12, // 13: atelet.Volume.external:type_name -> atelet.ExternalVolumeSource - 16, // 14: atelet.Volume.system_info:type_name -> atelet.SystemInfoVolume - 20, // 15: atelet.Container.env:type_name -> atelet.EnvEntry - 21, // 16: atelet.Container.readyz:type_name -> atelet.Readyz - 18, // 17: atelet.Container.volume_mounts:type_name -> atelet.VolumeMount - 22, // 18: atelet.Readyz.http_get:type_name -> atelet.HTTPGetAction - 10, // 19: atelet.CheckpointRequest.spec:type_name -> atelet.WorkloadSpec - 1, // 20: atelet.CheckpointRequest.type:type_name -> atelet.CheckpointType - 24, // 21: atelet.CheckpointRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration - 25, // 22: atelet.CheckpointRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration - 2, // 23: atelet.CheckpointRequest.scope:type_name -> atelet.SnapshotScope - 2, // 24: atelet.UploadPausedCheckpointRequest.desired_scope:type_name -> atelet.SnapshotScope - 10, // 25: atelet.RestoreRequest.spec:type_name -> atelet.WorkloadSpec - 1, // 26: atelet.RestoreRequest.type:type_name -> atelet.CheckpointType - 24, // 27: atelet.RestoreRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration - 25, // 28: atelet.RestoreRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration - 2, // 29: atelet.RestoreRequest.scope:type_name -> atelet.SnapshotScope - 6, // 30: atelet.RestoreRequest.egress_gateway:type_name -> atelet.EgressGateway - 7, // 31: atelet.ArchAssets.FilesEntry.value:type_name -> atelet.AssetFile - 8, // 32: atelet.SandboxAssets.AssetsEntry.value:type_name -> atelet.ArchAssets - 3, // 33: atelet.CredentialBroker.MintActorCertificate:input_type -> atelet.MintActorCertificateRequest - 5, // 34: atelet.AteomHerder.Run:input_type -> atelet.RunRequest - 26, // 35: atelet.AteomHerder.Checkpoint:input_type -> atelet.CheckpointRequest - 30, // 36: atelet.AteomHerder.Restore:input_type -> atelet.RestoreRequest - 28, // 37: atelet.AteomHerder.UploadPausedCheckpoint:input_type -> atelet.UploadPausedCheckpointRequest - 4, // 38: atelet.CredentialBroker.MintActorCertificate:output_type -> atelet.MintActorCertificateResponse - 23, // 39: atelet.AteomHerder.Run:output_type -> atelet.RunResponse - 27, // 40: atelet.AteomHerder.Checkpoint:output_type -> atelet.CheckpointResponse - 31, // 41: atelet.AteomHerder.Restore:output_type -> atelet.RestoreResponse - 29, // 42: atelet.AteomHerder.UploadPausedCheckpoint:output_type -> atelet.UploadPausedCheckpointResponse - 38, // [38:43] is the sub-list for method output_type - 33, // [33:38] is the sub-list for method input_type - 33, // [33:33] is the sub-list for extension type_name - 33, // [33:33] is the sub-list for extension extendee - 0, // [0:33] is the sub-list for field type_name + 15, // 11: atelet.SystemInfoDataSource.cluster_trust_bundle:type_name -> atelet.ClusterTrustBundleDataSource + 16, // 12: atelet.SystemInfoVolume.data_sources:type_name -> atelet.SystemInfoDataSource + 11, // 13: atelet.Volume.durable_dir:type_name -> atelet.DurableDirVolume + 12, // 14: atelet.Volume.external:type_name -> atelet.ExternalVolumeSource + 17, // 15: atelet.Volume.system_info:type_name -> atelet.SystemInfoVolume + 21, // 16: atelet.Container.env:type_name -> atelet.EnvEntry + 22, // 17: atelet.Container.readyz:type_name -> atelet.Readyz + 19, // 18: atelet.Container.volume_mounts:type_name -> atelet.VolumeMount + 23, // 19: atelet.Readyz.http_get:type_name -> atelet.HTTPGetAction + 10, // 20: atelet.CheckpointRequest.spec:type_name -> atelet.WorkloadSpec + 1, // 21: atelet.CheckpointRequest.type:type_name -> atelet.CheckpointType + 25, // 22: atelet.CheckpointRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration + 26, // 23: atelet.CheckpointRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration + 2, // 24: atelet.CheckpointRequest.scope:type_name -> atelet.SnapshotScope + 2, // 25: atelet.UploadPausedCheckpointRequest.desired_scope:type_name -> atelet.SnapshotScope + 10, // 26: atelet.RestoreRequest.spec:type_name -> atelet.WorkloadSpec + 1, // 27: atelet.RestoreRequest.type:type_name -> atelet.CheckpointType + 25, // 28: atelet.RestoreRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration + 26, // 29: atelet.RestoreRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration + 2, // 30: atelet.RestoreRequest.scope:type_name -> atelet.SnapshotScope + 6, // 31: atelet.RestoreRequest.egress_gateway:type_name -> atelet.EgressGateway + 7, // 32: atelet.ArchAssets.FilesEntry.value:type_name -> atelet.AssetFile + 8, // 33: atelet.SandboxAssets.AssetsEntry.value:type_name -> atelet.ArchAssets + 3, // 34: atelet.CredentialBroker.MintActorCertificate:input_type -> atelet.MintActorCertificateRequest + 5, // 35: atelet.AteomHerder.Run:input_type -> atelet.RunRequest + 27, // 36: atelet.AteomHerder.Checkpoint:input_type -> atelet.CheckpointRequest + 31, // 37: atelet.AteomHerder.Restore:input_type -> atelet.RestoreRequest + 29, // 38: atelet.AteomHerder.UploadPausedCheckpoint:input_type -> atelet.UploadPausedCheckpointRequest + 4, // 39: atelet.CredentialBroker.MintActorCertificate:output_type -> atelet.MintActorCertificateResponse + 24, // 40: atelet.AteomHerder.Run:output_type -> atelet.RunResponse + 28, // 41: atelet.AteomHerder.Checkpoint:output_type -> atelet.CheckpointResponse + 32, // 42: atelet.AteomHerder.Restore:output_type -> atelet.RestoreResponse + 30, // 43: atelet.AteomHerder.UploadPausedCheckpoint:output_type -> atelet.UploadPausedCheckpointResponse + 39, // [39:44] is the sub-list for method output_type + 34, // [34:39] is the sub-list for method input_type + 34, // [34:34] is the sub-list for extension type_name + 34, // [34:34] is the sub-list for extension extendee + 0, // [0:34] is the sub-list for field type_name } func init() { file_atelet_proto_init() } @@ -2378,19 +2458,20 @@ func file_atelet_proto_init() { return } file_atelet_proto_msgTypes[2].OneofWrappers = []any{} - file_atelet_proto_msgTypes[12].OneofWrappers = []any{ + file_atelet_proto_msgTypes[13].OneofWrappers = []any{ (*SystemInfoDataSource_ActorMetadata)(nil), + (*SystemInfoDataSource_ClusterTrustBundle)(nil), } - file_atelet_proto_msgTypes[14].OneofWrappers = []any{ + file_atelet_proto_msgTypes[15].OneofWrappers = []any{ (*Volume_DurableDir)(nil), (*Volume_External)(nil), (*Volume_SystemInfo)(nil), } - file_atelet_proto_msgTypes[23].OneofWrappers = []any{ + file_atelet_proto_msgTypes[24].OneofWrappers = []any{ (*CheckpointRequest_LocalConfig)(nil), (*CheckpointRequest_ExternalConfig)(nil), } - file_atelet_proto_msgTypes[27].OneofWrappers = []any{ + file_atelet_proto_msgTypes[28].OneofWrappers = []any{ (*RestoreRequest_LocalConfig)(nil), (*RestoreRequest_ExternalConfig)(nil), } @@ -2400,7 +2481,7 @@ func file_atelet_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_atelet_proto_rawDesc), len(file_atelet_proto_rawDesc)), NumEnums: 3, - NumMessages: 32, + NumMessages: 33, NumExtensions: 0, NumServices: 2, }, diff --git a/internal/proto/ateletpb/atelet.proto b/internal/proto/ateletpb/atelet.proto index d6524da7f..683d18a32 100644 --- a/internal/proto/ateletpb/atelet.proto +++ b/internal/proto/ateletpb/atelet.proto @@ -156,9 +156,20 @@ message ActorMetadataDataSource { repeated ActorMetadataItem items = 1; } +// ClusterTrustBundleDataSource writes an already-resolved PEM certificate +// bundle to a file at the given path, relative to the root of the enclosing +// system-info volume. ateapi resolves and sanitizes the referenced +// ClusterTrustBundle before sending the spec; atelet only writes the bytes +// and never talks to the Kubernetes API. +message ClusterTrustBundleDataSource { + string path = 1; + bytes pem_bundle = 2; +} + message SystemInfoDataSource { oneof data_source { ActorMetadataDataSource actor_metadata = 1; + ClusterTrustBundleDataSource cluster_trust_bundle = 2; } } diff --git a/internal/testenv/testenv.go b/internal/testenv/testenv.go index 3c0e2c8d6..ed162623f 100644 --- a/internal/testenv/testenv.go +++ b/internal/testenv/testenv.go @@ -62,6 +62,13 @@ func Start() (*rest.Config, func()) { CRDDirectoryPaths: []string{filepath.Join(root, "manifests", "ate-install", "generated")}, BinaryAssetsDirectory: binDir, } + // Serve the ClusterTrustBundle API, matching what hack/create-kind-cluster.sh + // enables on real clusters: ateapi registers a CTB informer at startup, and + // without the API its cache never syncs (see cmd/ateapi/main.go). + apiServer := env.ControlPlane.GetAPIServer() + apiServer.Configure(). + Append("feature-gates", "ClusterTrustBundle=true"). + Append("runtime-config", "certificates.k8s.io/v1beta1=true") cfg, err := env.Start() if err != nil { fatal(fmt.Errorf("envtest start: %w", err)) diff --git a/manifests/ate-install/ate-api-server.yaml b/manifests/ate-install/ate-api-server.yaml index 6d0765819..4efc5a3b1 100644 --- a/manifests/ate-install/ate-api-server.yaml +++ b/manifests/ate-install/ate-api-server.yaml @@ -22,6 +22,11 @@ rules: - apiGroups: [""] resources: ["pods"] verbs: ["get", "watch", "list"] +# ClusterTrustBundles referenced by SystemInfo volume data sources are +# resolved by ateapi and projected into actors as PEM files. +- apiGroups: ["certificates.k8s.io"] + resources: ["clustertrustbundles"] + verbs: ["get", "watch", "list"] - apiGroups: ["ate.dev"] resources: ["actortemplates", "workerpools", "sandboxconfigs", "csidriverconfigs"] verbs: ["get", "watch", "list"] diff --git a/manifests/ate-install/generated/ate.dev_actortemplates.yaml b/manifests/ate-install/generated/ate.dev_actortemplates.yaml index 1b0128c41..57fa0180c 100644 --- a/manifests/ate-install/generated/ate.dev_actortemplates.yaml +++ b/manifests/ate-install/generated/ate.dev_actortemplates.yaml @@ -352,9 +352,9 @@ spec: DataSources is the list of data sources to place within the SystemInfo volume. - At most one actorMetadata entry may appear; this is what keeps file - paths unique across the whole volume (uniqueness within the entry is - enforced on its items). + At most one actorMetadata entry may appear, and file paths must be + unique across all entries (uniqueness within actorMetadata is enforced + on its items). items: description: |- SystemInfoDataSource is a container allowing you to pick a particular @@ -422,18 +422,65 @@ spec: required: - items type: object + clusterTrustBundle: + description: |- + ClusterTrustBundleDataSource is a SystemInfo volume data source that + projects the trust anchors of a named ClusterTrustBundle + (certificates.k8s.io/v1beta1) to a single PEM file — analogous to the + Kubernetes clusterTrustBundle projected volume source. + + The bundle is resolved and sanitized by ateapi when the actor starts (only + CERTIFICATE PEM blocks are kept, deduplicated); the actor never talks to + the Kubernetes API. Starting the actor fails if the referenced bundle is + missing, empty, or unparseable. + properties: + name: + description: Name of the ClusterTrustBundle to + project. + maxLength: 253 + minLength: 1 + type: string + path: + description: |- + Relative path from the root of the SystemInfo volume at which the PEM + bundle is written. Must be a clean relative Unix path: must not start + or end with '/', and contain no ':', '..', '.', '//', or control + characters. + maxLength: 255 + minLength: 1 + type: string + x-kubernetes-validations: + - message: 'path must be a clean relative Unix + path: must not start or end with ''/'', and + contain no '':'', ''..'', ''.'', ''//'', or + control characters' + rule: '!self.startsWith(''/'') && !self.endsWith(''/'') + && !self.contains(''//'') && !self.contains('':'') + && !self.matches(''[\x00-\x1f\x7f]'') && !self.matches(''(^|/)[.][.]?(/|$)'')' + required: + - name + - path + type: object type: object x-kubernetes-validations: - - message: exactly one of the fields in [actorMetadata] - must be set - rule: '[has(self.actorMetadata)].filter(x,x==true).size() + - message: exactly one of the fields in [actorMetadata + clusterTrustBundle] must be set + rule: '[has(self.actorMetadata),has(self.clusterTrustBundle)].filter(x,x==true).size() == 1' - maxItems: 32 + maxItems: 8 type: array x-kubernetes-validations: - message: dataSources must contain at most one actorMetadata entry rule: self.filter(x, has(x.actorMetadata)).size() <= 1 + - message: dataSources must not contain duplicate paths + rule: self.all(x, !has(x.clusterTrustBundle) || self.exists_one(y, + has(y.clusterTrustBundle) && y.clusterTrustBundle.path + == x.clusterTrustBundle.path)) + - message: dataSources must not contain duplicate paths + rule: '!self.exists(x, has(x.clusterTrustBundle) && self.exists(y, + has(y.actorMetadata) && y.actorMetadata.items.exists(i, + i.path == x.clusterTrustBundle.path)))' type: object required: - name diff --git a/pkg/api/v1alpha1/actortemplate_types.go b/pkg/api/v1alpha1/actortemplate_types.go index a0239caaa..588466e0b 100644 --- a/pkg/api/v1alpha1/actortemplate_types.go +++ b/pkg/api/v1alpha1/actortemplate_types.go @@ -98,29 +98,63 @@ type ActorMetadataDataSource struct { Items []ActorMetadataItem `json:"items"` } +// ClusterTrustBundleDataSource is a SystemInfo volume data source that +// projects the trust anchors of a named ClusterTrustBundle +// (certificates.k8s.io/v1beta1) to a single PEM file — analogous to the +// Kubernetes clusterTrustBundle projected volume source. +// +// The bundle is resolved and sanitized by ateapi when the actor starts (only +// CERTIFICATE PEM blocks are kept, deduplicated); the actor never talks to +// the Kubernetes API. Starting the actor fails if the referenced bundle is +// missing, empty, or unparseable. +type ClusterTrustBundleDataSource struct { + // Name of the ClusterTrustBundle to project. + // + // +required + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=253 + Name string `json:"name"` + + // Relative path from the root of the SystemInfo volume at which the PEM + // bundle is written. Must be a clean relative Unix path: must not start + // or end with '/', and contain no ':', '..', '.', '//', or control + // characters. + // + // +required + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=255 + // +kubebuilder:validation:XValidation:rule="!self.startsWith('/') && !self.endsWith('/') && !self.contains('//') && !self.contains(':') && !self.matches('[\\x00-\\x1f\\x7f]') && !self.matches('(^|/)[.][.]?(/|$)')",message="path must be a clean relative Unix path: must not start or end with '/', and contain no ':', '..', '.', '//', or control characters" + Path string `json:"path"` +} + // SystemInfoDataSource is a container allowing you to pick a particular // SystemInfo data source. // // Exactly one member must be set. // -// +kubebuilder:validation:ExactlyOneOf={actorMetadata} +// +kubebuilder:validation:ExactlyOneOf={actorMetadata,clusterTrustBundle} type SystemInfoDataSource struct { ActorMetadata *ActorMetadataDataSource `json:"actorMetadata,omitempty"` + + ClusterTrustBundle *ClusterTrustBundleDataSource `json:"clusterTrustBundle,omitempty"` } // Represents a system information volume, which provides files containing -// substrate-generated per-actor data such as the actor's identity fields -// (and, in the future, identity JWTs and certificates). +// substrate-generated per-actor data such as the actor's identity fields, +// projected cluster trust bundles (and, in the future, identity JWTs and +// certificates). type SystemInfoVolumeSource struct { // DataSources is the list of data sources to place within the SystemInfo // volume. // - // At most one actorMetadata entry may appear; this is what keeps file - // paths unique across the whole volume (uniqueness within the entry is - // enforced on its items). + // At most one actorMetadata entry may appear, and file paths must be + // unique across all entries (uniqueness within actorMetadata is enforced + // on its items). // - // +kubebuilder:validation:MaxItems=32 + // +kubebuilder:validation:MaxItems=8 // +kubebuilder:validation:XValidation:rule="self.filter(x, has(x.actorMetadata)).size() <= 1",message="dataSources must contain at most one actorMetadata entry" + // +kubebuilder:validation:XValidation:rule="self.all(x, !has(x.clusterTrustBundle) || self.exists_one(y, has(y.clusterTrustBundle) && y.clusterTrustBundle.path == x.clusterTrustBundle.path))",message="dataSources must not contain duplicate paths" + // +kubebuilder:validation:XValidation:rule="!self.exists(x, has(x.clusterTrustBundle) && self.exists(y, has(y.actorMetadata) && y.actorMetadata.items.exists(i, i.path == x.clusterTrustBundle.path)))",message="dataSources must not contain duplicate paths" DataSources []SystemInfoDataSource `json:"dataSources,omitempty"` } diff --git a/pkg/api/v1alpha1/actortemplate_validation_test.go b/pkg/api/v1alpha1/actortemplate_validation_test.go index af5d0e07d..e23e21935 100644 --- a/pkg/api/v1alpha1/actortemplate_validation_test.go +++ b/pkg/api/v1alpha1/actortemplate_validation_test.go @@ -742,7 +742,7 @@ func TestActorTemplateValidation(t *testing.T) { } }, wantErr: true, - errMsg: "exactly one of the fields in [actorMetadata] must be set", + errMsg: "exactly one of the fields in [actorMetadata clusterTrustBundle] must be set", }, { name: "Volumes: SystemInfo actorMetadata with no items is invalid", mutate: func(at *ActorTemplate) { @@ -892,6 +892,120 @@ func TestActorTemplateValidation(t *testing.T) { }, wantErr: true, errMsg: "items must not contain duplicate paths", + }, { + name: "Volumes: SystemInfo clusterTrustBundle data source is valid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ClusterTrustBundle: &ClusterTrustBundleDataSource{Name: "egress-trust", Path: "trust/ca.pem"}}, + }, + }, + }, + }, + } + at.Spec.Containers[0].VolumeMounts = []VolumeMount{ + {Name: "system-info", MountPath: "/run/substrate/certs"}, + } + }, + wantErr: false, + }, { + name: "Volumes: SystemInfo clusterTrustBundle with empty name is invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ClusterTrustBundle: &ClusterTrustBundleDataSource{Name: "", Path: "ca.pem"}}, + }, + }, + }, + }, + } + }, + wantErr: true, + }, { + name: "Volumes: SystemInfo clusterTrustBundle with absolute path is invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ClusterTrustBundle: &ClusterTrustBundleDataSource{Name: "egress-trust", Path: "/etc/ca.pem"}}, + }, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "path must be a clean relative Unix path", + }, { + name: "Volumes: SystemInfo data source with both members set is invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + { + ActorMetadata: &ActorMetadataDataSource{Items: []ActorMetadataItem{{Field: ActorMetadataFieldName, Path: "actor-name"}}}, + ClusterTrustBundle: &ClusterTrustBundleDataSource{Name: "egress-trust", Path: "ca.pem"}, + }, + }, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "exactly one of the fields in [actorMetadata clusterTrustBundle] must be set", + }, { + name: "Volumes: SystemInfo clusterTrustBundles with duplicate paths are invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ClusterTrustBundle: &ClusterTrustBundleDataSource{Name: "bundle-a", Path: "ca.pem"}}, + {ClusterTrustBundle: &ClusterTrustBundleDataSource{Name: "bundle-b", Path: "ca.pem"}}, + }, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "dataSources must not contain duplicate paths", + }, { + name: "Volumes: SystemInfo clusterTrustBundle path colliding with an actorMetadata item is invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ActorMetadata: &ActorMetadataDataSource{Items: []ActorMetadataItem{{Field: ActorMetadataFieldName, Path: "shared-path"}}}}, + {ClusterTrustBundle: &ClusterTrustBundleDataSource{Name: "egress-trust", Path: "shared-path"}}, + }, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "dataSources must not contain duplicate paths", }, { name: "Volumes: SystemInfo with two actorMetadata entries is invalid", mutate: func(at *ActorTemplate) { diff --git a/pkg/api/v1alpha1/zz_generated.deepcopy.go b/pkg/api/v1alpha1/zz_generated.deepcopy.go index 9b329e607..ad25c7c6c 100644 --- a/pkg/api/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/api/v1alpha1/zz_generated.deepcopy.go @@ -264,6 +264,21 @@ func (in *CSIDriverConfigSpec) DeepCopy() *CSIDriverConfigSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterTrustBundleDataSource) DeepCopyInto(out *ClusterTrustBundleDataSource) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterTrustBundleDataSource. +func (in *ClusterTrustBundleDataSource) DeepCopy() *ClusterTrustBundleDataSource { + if in == nil { + return nil + } + out := new(ClusterTrustBundleDataSource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Container) DeepCopyInto(out *Container) { *out = *in @@ -515,6 +530,11 @@ func (in *SystemInfoDataSource) DeepCopyInto(out *SystemInfoDataSource) { *out = new(ActorMetadataDataSource) (*in).DeepCopyInto(*out) } + if in.ClusterTrustBundle != nil { + in, out := &in.ClusterTrustBundle, &out.ClusterTrustBundle + *out = new(ClusterTrustBundleDataSource) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SystemInfoDataSource.