diff --git a/cmd/ateapi/internal/controlapi/workload_spec.go b/cmd/ateapi/internal/controlapi/workload_spec.go index 6e1b12d0d..c86586472 100644 --- a/cmd/ateapi/internal/controlapi/workload_spec.go +++ b/cmd/ateapi/internal/controlapi/workload_spec.go @@ -41,17 +41,48 @@ func workloadSpecFromActorTemplate(actorTemplate *atev1alpha1.ActorTemplate, act PauseImage: actorTemplate.Spec.PauseImage, } - // 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, - Type: ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR, 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.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_ActorMetadata{ + ActorMetadata: actorMetadata, + }, + }) + 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. } } @@ -142,7 +173,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, @@ -170,6 +200,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 0de964056..ab7a1ad89 100644 --- a/cmd/ateapi/internal/controlapi/workload_spec_test.go +++ b/cmd/ateapi/internal/controlapi/workload_spec_test.go @@ -64,7 +64,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{}}, }, }, @@ -80,6 +79,74 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) { }, }, }, + { + 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{ + {ActorMetadata: &atev1alpha1.ActorMetadataDataSource{ + Items: []atev1alpha1.ActorMetadataItem{ + {Field: atev1alpha1.ActorMetadataFieldName, Path: "actor-name"}, + {Field: atev1alpha1.ActorMetadataFieldAtespace, Path: "atespace"}, + {Field: atev1alpha1.ActorMetadataFieldUID, Path: "identity/actor-uid"}, + }, + }}, + }, + }, + }, + }, + }, + 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_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"}, + }, + }, + }}, + }, + }, + }, + }, + }, + Containers: []*ateletpb.Container{ + { + Name: "main", + Image: "main", + VolumeMounts: []*ateletpb.VolumeMount{ + {Name: "system-info", MountPath: "/run/ate"}, + }, + }, + }, + }, + }, { name: "skips non-DurableDir volumes", template: &atev1alpha1.ActorTemplate{ @@ -104,7 +171,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{}}, }, }, @@ -136,7 +202,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{}}, }, }, @@ -535,7 +600,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/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 99844673b..1f8e8927d 100644 --- a/cmd/atelet/main.go +++ b/cmd/atelet/main.go @@ -35,6 +35,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" @@ -419,7 +420,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(), req.GetTargetAteomUid(), ); err != nil { return nil, ateerrors.CrashIfReason(ctx, err, ateerrors.ReasonInvalidContainerConfig) @@ -905,7 +906,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(), req.GetTargetAteomUid()) + err = s.prepareOCIBundles(gctx, actorUID, actorRef, req.GetSpec(), req.GetTargetAteomUid()) dBundles = time.Since(t) if err != nil { prepFailedPhase = ateattr.SnapshotPhaseOCIUnpack @@ -1205,27 +1206,24 @@ 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, 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.GetType() == ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR { + 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: + volRootHostPath := ateompath.SystemInfoVolumeRoot(actorUID, vol.GetName()) + if err := writeSystemInfoVolume(ctx, volRootHostPath, actorRef, actorUID, volSrc.SystemInfo); err != nil { + return fmt.Errorf("while populating system-info volume %q: %w", vol.GetName(), err) + } } } @@ -1240,7 +1238,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()) @@ -1258,8 +1256,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) @@ -1290,7 +1287,6 @@ func (s *AteomHerder) prepareOCIBundles( "io.kubernetes.cri.container-name": ctr.GetName(), }, ateompath.AteomNetNSPath(targetAteomUid), - identityDir, spec.GetVolumes(), ctr.GetVolumeMounts(), ); err != nil { @@ -1303,6 +1299,54 @@ func (s *AteomHerder) prepareOCIBundles( return g.Wait() } +// writeSystemInfoVolume populates the root directory of a system-info volume +// 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) + } + + 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_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, + } + } + } + } + + 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) { @@ -1317,26 +1361,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() { - if vol.GetType() == ateletpb.VolumeType_VOLUME_TYPE_DURABLE_DIR { + 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()), }) } @@ -1636,16 +1692,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) @@ -1654,6 +1700,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/main_test.go b/cmd/atelet/main_test.go index ffe0f9d06..0c2bf5452 100644 --- a/cmd/atelet/main_test.go +++ b/cmd/atelet/main_test.go @@ -35,6 +35,7 @@ import ( "github.com/agent-substrate/substrate/internal/ateompath" "github.com/agent-substrate/substrate/internal/proto/ateletpb" "github.com/agent-substrate/substrate/internal/proto/ateompb" + "github.com/agent-substrate/substrate/internal/resources" "github.com/agent-substrate/substrate/internal/serverboot" "github.com/google/go-cmp/cmp" "github.com/klauspost/compress/zstd" @@ -88,6 +89,61 @@ func TestSnapshotManifestScopeAbsent(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_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"}, + }, + }, + }}, + }, + } + + 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, 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) + } + + // 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) + } + if string(got) != want { + t.Errorf("content = %q, want %q", got, want) + } + 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") @@ -672,9 +728,10 @@ 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{}}}, + {Name: "system-info", Source: &ateletpb.Volume_SystemInfo{SystemInfo: &ateletpb.SystemInfoVolume{}}}, }, Containers: []*ateletpb.Container{ { @@ -682,9 +739,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"}, }, }, { @@ -706,6 +764,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/atelet/oci.go b/cmd/atelet/oci.go index e1476610c..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{ @@ -295,18 +262,24 @@ 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: + options := []string{"bind", "rw"} + 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()) + 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 433c082c3..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) { @@ -211,14 +212,13 @@ 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, []string{"/app"}, nil, nil, "/run/netns/x", - "", volumes, durableDirs, ) 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/cmd/ateom-microvm/checkpoint.go b/cmd/ateom-microvm/checkpoint.go index f55dfe2f9..b4df42b27 100644 --- a/cmd/ateom-microvm/checkpoint.go +++ b/cmd/ateom-microvm/checkpoint.go @@ -282,9 +282,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 f17f7da72..46db5bf57 100644 --- a/cmd/ateom-microvm/durable.go +++ b/cmd/ateom-microvm/durable.go @@ -86,16 +86,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 abf0995df..ad17821f7 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 { @@ -191,9 +208,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, @@ -208,6 +226,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 93d6518a9..f662a0de5 100644 --- a/cmd/ateom-microvm/restore.go +++ b/cmd/ateom-microvm/restore.go @@ -212,6 +212,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{ @@ -297,7 +314,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, } @@ -371,6 +388,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 eb4b34740..f685df9a7 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 @@ -133,6 +137,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 @@ -403,6 +410,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{ @@ -426,7 +450,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) } @@ -480,7 +504,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 } @@ -489,7 +513,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, logAgent: ac} + ra := &runningActor{chCmd: chCmd, vfsdCmd: vfsdCmd, durableVfsdCmd: durableVfsdCmd, systemInfoVfsdCmd: systemInfoVfsdCmd, apiSocket: apiSocket, baseID: actorUID, logAgent: ac} if err := s.activateActorNetworking(p.actorRef.Atespace, p.actorRef.Name, egress); err != nil { return err } @@ -540,10 +564,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 @@ -602,7 +627,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" @@ -620,7 +645,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}, @@ -629,9 +654,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, @@ -642,6 +668,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 } @@ -651,13 +683,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 7962bc5aa..a5b7d80da 100644 --- a/cmd/ateom-microvm/spec.go +++ b/cmd/ateom-microvm/spec.go @@ -88,12 +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 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. + // 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/docs/api-guide.md b/docs/api-guide.md index 2ef434710..1b54d7a94 100644 --- a/docs/api-guide.md +++ b/docs/api-guide.md @@ -145,7 +145,7 @@ The `ActorTemplate` defines the code, environment, and state-management policies | `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). | | `pauseImage` | `string` | **Required.** The image used for the sandbox root (e.g. `gcr.io/gke-release/pause`). | -| `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 binaries (e.g. the gVisor `runsc` binary) are **no longer configured on the `ActorTemplate`**. They are resolved from the referenced `WorkerPool`'s [`SandboxConfig`](#3-sandboxconfig-sandbox-binaries) — by name (`workerPool.spec.sandboxConfigName`) or, by default, the cluster default `SandboxConfig` for the pool's `sandboxClass`. @@ -158,10 +158,38 @@ 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: + +#### 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: + volumes: + - name: system-info + systemInfo: + dataSources: + - 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 e.g. /run/ate/actor-name +``` + +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 @@ -372,7 +400,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/ateompath/ateompath.go b/internal/ateompath/ateompath.go index 680e329c1..aacce601c 100644 --- a/internal/ateompath/ateompath.go +++ b/internal/ateompath/ateompath.go @@ -87,18 +87,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 @@ -172,6 +160,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/e2e/fixtures/probe/main.go b/internal/e2e/fixtures/probe/main.go index 6927a1d04..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 actor-id file inside the identity directory atelet -// bind-mounts at IdentityMountPath. -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 f79e0cdfe..0dea1fc83 100644 --- a/internal/e2e/fixtures/probe/probe.yaml.tmpl +++ b/internal/e2e/fixtures/probe/probe.yaml.tmpl @@ -39,10 +39,25 @@ metadata: namespace: ate-e2e-probe spec: pauseImage: "registry.k8s.io/pause:3.10.2@sha256:f548e0e8e3dc1896ca956272154dde3314e8cc4fde0a57577ee9fa1c63f5baf4" + volumes: + - name: system-info + systemInfo: + dataSources: + - 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 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/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 cc5a3f693..ce0d4e0af 100644 --- a/internal/proto/ateletpb/atelet.pb.go +++ b/internal/proto/ateletpb/atelet.pb.go @@ -35,52 +35,56 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type VolumeType int32 +// ActorMetadataField selects one identity field of the actor. +type ActorMetadataField int32 const ( - VolumeType_VOLUME_TYPE_UNSPECIFIED VolumeType = 0 - VolumeType_VOLUME_TYPE_DURABLE_DIR VolumeType = 1 - VolumeType_VOLUME_TYPE_EXTERNAL VolumeType = 2 + 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 VolumeType. +// Enum value maps for ActorMetadataField. 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, + 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 VolumeType) Enum() *VolumeType { - p := new(VolumeType) +func (x ActorMetadataField) Enum() *ActorMetadataField { + p := new(ActorMetadataField) *p = x return p } -func (x VolumeType) String() string { +func (x ActorMetadataField) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (VolumeType) Descriptor() protoreflect.EnumDescriptor { +func (ActorMetadataField) Descriptor() protoreflect.EnumDescriptor { return file_atelet_proto_enumTypes[0].Descriptor() } -func (VolumeType) Type() protoreflect.EnumType { +func (ActorMetadataField) Type() protoreflect.EnumType { return &file_atelet_proto_enumTypes[0] } -func (x VolumeType) Number() protoreflect.EnumNumber { +func (x ActorMetadataField) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } -// Deprecated: Use VolumeType.Descriptor instead. -func (VolumeType) EnumDescriptor() ([]byte, []int) { +// Deprecated: Use ActorMetadataField.Descriptor instead. +func (ActorMetadataField) EnumDescriptor() ([]byte, []int) { return file_atelet_proto_rawDescGZIP(), []int{0} } @@ -776,14 +780,227 @@ func (x *ExternalVolumeSource) GetVolumeContext() map[string]string { return nil } +// 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"` + 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 *ActorMetadataItem) Reset() { + *x = ActorMetadataItem{} + mi := &file_atelet_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ActorMetadataItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ActorMetadataItem) ProtoMessage() {} + +func (x *ActorMetadataItem) 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 ActorMetadataItem.ProtoReflect.Descriptor instead. +func (*ActorMetadataItem) Descriptor() ([]byte, []int) { + return file_atelet_proto_rawDescGZIP(), []int{10} +} + +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_ActorMetadata + DataSource isSystemInfoDataSource_DataSource `protobuf_oneof:"data_source"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SystemInfoDataSource) Reset() { + *x = SystemInfoDataSource{} + mi := &file_atelet_proto_msgTypes[12] + 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[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 SystemInfoDataSource.ProtoReflect.Descriptor instead. +func (*SystemInfoDataSource) Descriptor() ([]byte, []int) { + return file_atelet_proto_rawDescGZIP(), []int{12} +} + +func (x *SystemInfoDataSource) GetDataSource() isSystemInfoDataSource_DataSource { + if x != nil { + return x.DataSource + } + return nil +} + +func (x *SystemInfoDataSource) GetActorMetadata() *ActorMetadataDataSource { + if x != nil { + if x, ok := x.DataSource.(*SystemInfoDataSource_ActorMetadata); ok { + return x.ActorMetadata + } + } + return nil +} + +type isSystemInfoDataSource_DataSource interface { + isSystemInfoDataSource_DataSource() +} + +type SystemInfoDataSource_ActorMetadata struct { + ActorMetadata *ActorMetadataDataSource `protobuf:"bytes,1,opt,name=actor_metadata,json=actorMetadata,proto3,oneof"` +} + +func (*SystemInfoDataSource_ActorMetadata) 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. +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[13] + 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[13] + 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{13} +} + +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"` - 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 // *Volume_External + // *Volume_SystemInfo Source isVolume_Source `protobuf_oneof:"source"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -791,7 +1008,7 @@ type Volume struct { func (x *Volume) Reset() { *x = Volume{} - mi := &file_atelet_proto_msgTypes[10] + mi := &file_atelet_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -803,7 +1020,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[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -816,7 +1033,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{14} } func (x *Volume) GetName() string { @@ -826,13 +1043,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 @@ -858,22 +1068,37 @@ 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() } 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"` +} + +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"` @@ -884,7 +1109,7 @@ type VolumeMount struct { func (x *VolumeMount) Reset() { *x = VolumeMount{} - mi := &file_atelet_proto_msgTypes[11] + mi := &file_atelet_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -896,7 +1121,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[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -909,7 +1134,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{15} } func (x *VolumeMount) GetName() string { @@ -941,7 +1166,7 @@ type Container struct { func (x *Container) Reset() { *x = Container{} - mi := &file_atelet_proto_msgTypes[12] + mi := &file_atelet_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -953,7 +1178,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[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -966,7 +1191,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{16} } func (x *Container) GetName() string { @@ -1028,7 +1253,7 @@ type EnvEntry struct { func (x *EnvEntry) Reset() { *x = EnvEntry{} - mi := &file_atelet_proto_msgTypes[13] + mi := &file_atelet_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1040,7 +1265,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[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1053,7 +1278,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{17} } func (x *EnvEntry) GetName() string { @@ -1084,7 +1309,7 @@ type Readyz struct { func (x *Readyz) Reset() { *x = Readyz{} - mi := &file_atelet_proto_msgTypes[14] + mi := &file_atelet_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1096,7 +1321,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[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1109,7 +1334,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{18} } func (x *Readyz) GetHttpGet() *HTTPGetAction { @@ -1139,7 +1364,7 @@ type HTTPGetAction struct { func (x *HTTPGetAction) Reset() { *x = HTTPGetAction{} - mi := &file_atelet_proto_msgTypes[15] + mi := &file_atelet_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1151,7 +1376,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[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1164,7 +1389,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{19} } func (x *HTTPGetAction) GetPath() string { @@ -1189,7 +1414,7 @@ type RunResponse struct { func (x *RunResponse) Reset() { *x = RunResponse{} - mi := &file_atelet_proto_msgTypes[16] + mi := &file_atelet_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1201,7 +1426,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[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1214,7 +1439,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{20} } type LocalCheckpointConfiguration struct { @@ -1230,7 +1455,7 @@ type LocalCheckpointConfiguration struct { func (x *LocalCheckpointConfiguration) Reset() { *x = LocalCheckpointConfiguration{} - mi := &file_atelet_proto_msgTypes[17] + mi := &file_atelet_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1242,7 +1467,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[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1255,7 +1480,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{21} } func (x *LocalCheckpointConfiguration) GetSnapshotName() string { @@ -1276,7 +1501,7 @@ type ExternalCheckpointConfiguration struct { func (x *ExternalCheckpointConfiguration) Reset() { *x = ExternalCheckpointConfiguration{} - mi := &file_atelet_proto_msgTypes[18] + mi := &file_atelet_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1288,7 +1513,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[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1301,7 +1526,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{22} } func (x *ExternalCheckpointConfiguration) GetSnapshotUri() string { @@ -1339,7 +1564,7 @@ type CheckpointRequest struct { func (x *CheckpointRequest) Reset() { *x = CheckpointRequest{} - mi := &file_atelet_proto_msgTypes[19] + mi := &file_atelet_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1351,7 +1576,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[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1364,7 +1589,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{23} } func (x *CheckpointRequest) GetTargetAteomUid() string { @@ -1479,7 +1704,7 @@ type CheckpointResponse struct { func (x *CheckpointResponse) Reset() { *x = CheckpointResponse{} - mi := &file_atelet_proto_msgTypes[20] + mi := &file_atelet_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1491,7 +1716,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[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1504,7 +1729,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{24} } type RestoreRequest struct { @@ -1544,7 +1769,7 @@ type RestoreRequest struct { func (x *RestoreRequest) Reset() { *x = RestoreRequest{} - mi := &file_atelet_proto_msgTypes[21] + mi := &file_atelet_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1556,7 +1781,7 @@ func (x *RestoreRequest) String() string { func (*RestoreRequest) ProtoMessage() {} func (x *RestoreRequest) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[21] + mi := &file_atelet_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1569,7 +1794,7 @@ func (x *RestoreRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RestoreRequest.ProtoReflect.Descriptor instead. func (*RestoreRequest) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{21} + return file_atelet_proto_rawDescGZIP(), []int{25} } func (x *RestoreRequest) GetTargetAteomUid() string { @@ -1698,7 +1923,7 @@ type RestoreResponse struct { func (x *RestoreResponse) Reset() { *x = RestoreResponse{} - mi := &file_atelet_proto_msgTypes[22] + mi := &file_atelet_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1710,7 +1935,7 @@ func (x *RestoreResponse) String() string { func (*RestoreResponse) ProtoMessage() {} func (x *RestoreResponse) ProtoReflect() protoreflect.Message { - mi := &file_atelet_proto_msgTypes[22] + mi := &file_atelet_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1723,7 +1948,7 @@ func (x *RestoreResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RestoreResponse.ProtoReflect.Descriptor instead. func (*RestoreResponse) Descriptor() ([]byte, []int) { - return file_atelet_proto_rawDescGZIP(), []int{22} + return file_atelet_proto_rawDescGZIP(), []int{26} } var File_atelet_proto protoreflect.FileDescriptor @@ -1782,13 +2007,24 @@ 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\"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_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" + "\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\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" + @@ -1850,12 +2086,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*`\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*\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" + @@ -1886,9 +2122,9 @@ func file_atelet_proto_rawDescGZIP() []byte { } var file_atelet_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_atelet_proto_msgTypes = make([]protoimpl.MessageInfo, 26) +var file_atelet_proto_msgTypes = make([]protoimpl.MessageInfo, 30) var file_atelet_proto_goTypes = []any{ - (VolumeType)(0), // 0: atelet.VolumeType + (ActorMetadataField)(0), // 0: atelet.ActorMetadataField (CheckpointType)(0), // 1: atelet.CheckpointType (SnapshotScope)(0), // 2: atelet.SnapshotScope (*MintActorCertificateRequest)(nil), // 3: atelet.MintActorCertificateRequest @@ -1901,65 +2137,73 @@ var file_atelet_proto_goTypes = []any{ (*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 - (*RestoreRequest)(nil), // 24: atelet.RestoreRequest - (*RestoreResponse)(nil), // 25: atelet.RestoreResponse - nil, // 26: atelet.ArchAssets.FilesEntry - nil, // 27: atelet.SandboxAssets.AssetsEntry - nil, // 28: atelet.ExternalVolumeSource.VolumeContextEntry + (*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 + (*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{ 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 - 26, // 3: atelet.ArchAssets.files:type_name -> atelet.ArchAssets.FilesEntry - 27, // 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 - 28, // 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 - 10, // 20: atelet.RestoreRequest.spec:type_name -> atelet.WorkloadSpec - 1, // 21: atelet.RestoreRequest.type:type_name -> atelet.CheckpointType - 20, // 22: atelet.RestoreRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration - 21, // 23: atelet.RestoreRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration - 2, // 24: atelet.RestoreRequest.scope:type_name -> atelet.SnapshotScope - 6, // 25: atelet.RestoreRequest.egress_gateway:type_name -> atelet.EgressGateway - 7, // 26: atelet.ArchAssets.FilesEntry.value:type_name -> atelet.AssetFile - 8, // 27: atelet.SandboxAssets.AssetsEntry.value:type_name -> atelet.ArchAssets - 3, // 28: atelet.CredentialBroker.MintActorCertificate:input_type -> atelet.MintActorCertificateRequest - 5, // 29: atelet.AteomHerder.Run:input_type -> atelet.RunRequest - 22, // 30: atelet.AteomHerder.Checkpoint:input_type -> atelet.CheckpointRequest - 24, // 31: atelet.AteomHerder.Restore:input_type -> atelet.RestoreRequest - 4, // 32: atelet.CredentialBroker.MintActorCertificate:output_type -> atelet.MintActorCertificateResponse - 19, // 33: atelet.AteomHerder.Run:output_type -> atelet.RunResponse - 23, // 34: atelet.AteomHerder.Checkpoint:output_type -> atelet.CheckpointResponse - 25, // 35: atelet.AteomHerder.Restore:output_type -> atelet.RestoreResponse - 32, // [32:36] is the sub-list for method output_type - 28, // [28:32] 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 + 19, // 5: atelet.WorkloadSpec.containers:type_name -> atelet.Container + 17, // 6: atelet.WorkloadSpec.volumes:type_name -> atelet.Volume + 32, // 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 + 10, // 24: atelet.RestoreRequest.spec:type_name -> atelet.WorkloadSpec + 1, // 25: atelet.RestoreRequest.type:type_name -> atelet.CheckpointType + 24, // 26: atelet.RestoreRequest.local_config:type_name -> atelet.LocalCheckpointConfiguration + 25, // 27: atelet.RestoreRequest.external_config:type_name -> atelet.ExternalCheckpointConfiguration + 2, // 28: atelet.RestoreRequest.scope:type_name -> atelet.SnapshotScope + 6, // 29: atelet.RestoreRequest.egress_gateway:type_name -> atelet.EgressGateway + 7, // 30: atelet.ArchAssets.FilesEntry.value:type_name -> atelet.AssetFile + 8, // 31: atelet.SandboxAssets.AssetsEntry.value:type_name -> atelet.ArchAssets + 3, // 32: atelet.CredentialBroker.MintActorCertificate:input_type -> atelet.MintActorCertificateRequest + 5, // 33: atelet.AteomHerder.Run:input_type -> atelet.RunRequest + 26, // 34: atelet.AteomHerder.Checkpoint:input_type -> atelet.CheckpointRequest + 28, // 35: atelet.AteomHerder.Restore:input_type -> atelet.RestoreRequest + 4, // 36: atelet.CredentialBroker.MintActorCertificate:output_type -> atelet.MintActorCertificateResponse + 23, // 37: atelet.AteomHerder.Run:output_type -> atelet.RunResponse + 27, // 38: atelet.AteomHerder.Checkpoint:output_type -> atelet.CheckpointResponse + 29, // 39: atelet.AteomHerder.Restore:output_type -> atelet.RestoreResponse + 36, // [36:40] is the sub-list for method output_type + 32, // [32:36] is the sub-list for method input_type + 32, // [32:32] is the sub-list for extension type_name + 32, // [32:32] is the sub-list for extension extendee + 0, // [0:32] is the sub-list for field type_name } func init() { file_atelet_proto_init() } @@ -1968,15 +2212,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[12].OneofWrappers = []any{ + (*SystemInfoDataSource_ActorMetadata)(nil), + } + file_atelet_proto_msgTypes[14].OneofWrappers = []any{ (*Volume_DurableDir)(nil), (*Volume_External)(nil), + (*Volume_SystemInfo)(nil), } - file_atelet_proto_msgTypes[19].OneofWrappers = []any{ + file_atelet_proto_msgTypes[23].OneofWrappers = []any{ (*CheckpointRequest_LocalConfig)(nil), (*CheckpointRequest_ExternalConfig)(nil), } - file_atelet_proto_msgTypes[21].OneofWrappers = []any{ + file_atelet_proto_msgTypes[25].OneofWrappers = []any{ (*RestoreRequest_LocalConfig)(nil), (*RestoreRequest_ExternalConfig)(nil), } @@ -1986,7 +2234,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: 26, + NumMessages: 30, NumExtensions: 0, NumServices: 2, }, diff --git a/internal/proto/ateletpb/atelet.proto b/internal/proto/ateletpb/atelet.proto index 771db8e10..cc3a5006a 100644 --- a/internal/proto/ateletpb/atelet.proto +++ b/internal/proto/ateletpb/atelet.proto @@ -112,12 +112,6 @@ message WorkloadSpec { repeated Volume volumes = 3; } -enum VolumeType { - VOLUME_TYPE_UNSPECIFIED = 0; - VOLUME_TYPE_DURABLE_DIR = 1; - VOLUME_TYPE_EXTERNAL = 2; -} - message DurableDirVolume { } @@ -127,14 +121,47 @@ message ExternalVolumeSource { map volume_context = 3; } +// 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 { + ActorMetadataDataSource actor_metadata = 1; + } +} + +// 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. +message SystemInfoVolume { + repeated SystemInfoDataSource data_sources = 1; +} + message Volume { string name = 1; - VolumeType type = 2; - oneof source { - DurableDirVolume durable_dir = 3; - ExternalVolumeSource external = 4; + DurableDirVolume durable_dir = 2; + ExternalVolumeSource external = 3; + SystemInfoVolume system_info = 4; } } diff --git a/internal/proto/ateompb/ateom.pb.go b/internal/proto/ateompb/ateom.pb.go index cfe6b3ed5..26b33fc00 100644 --- a/internal/proto/ateompb/ateom.pb.go +++ b/internal/proto/ateompb/ateom.pb.go @@ -419,6 +419,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 } @@ -474,6 +478,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"` @@ -530,6 +541,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 { @@ -544,7 +613,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) } @@ -556,7 +625,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 { @@ -569,7 +638,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 { @@ -599,7 +668,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) } @@ -611,7 +680,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 { @@ -624,7 +693,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 { @@ -649,7 +718,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) } @@ -661,7 +730,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 { @@ -674,7 +743,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 { @@ -708,7 +777,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) } @@ -720,7 +789,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 { @@ -733,7 +802,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 { @@ -818,7 +887,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) } @@ -830,7 +899,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 { @@ -843,7 +912,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 { @@ -882,7 +951,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) } @@ -894,7 +963,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 { @@ -907,7 +976,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 { @@ -1002,7 +1071,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) } @@ -1014,7 +1083,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 { @@ -1027,7 +1096,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 { @@ -1043,7 +1112,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) } @@ -1055,7 +1124,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 { @@ -1068,7 +1137,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 { @@ -1129,7 +1198,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) } @@ -1141,7 +1210,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 { @@ -1154,7 +1223,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 { @@ -1268,15 +1337,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" + @@ -1374,7 +1449,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 @@ -1384,49 +1459,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() } @@ -1435,14 +1512,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 2d6a8d8be..eb561e6e1 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 { diff --git a/manifests/ate-install/generated/ate.dev_actortemplates.yaml b/manifests/ate-install/generated/ate.dev_actortemplates.yaml index 1dff97416..c7036903d 100644 --- a/manifests/ate-install/generated/ate.dev_actortemplates.yaml +++ b/manifests/ate-install/generated/ate.dev_actortemplates.yaml @@ -394,13 +394,104 @@ 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. + + 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 + SystemInfo data source. + + Exactly one member must be set. + properties: + actorMetadata: + description: |- + 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: + items: + description: |- + 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: 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: + - items + 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() + == 1' + maxItems: 32 + type: array + x-kubernetes-validations: + - message: dataSources must contain at most one actorMetadata + entry + rule: self.filter(x, has(x.actorMetadata)).size() <= 1 + 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 1a2480a33..930bd6841 100644 --- a/pkg/api/v1alpha1/actortemplate_types.go +++ b/pkg/api/v1alpha1/actortemplate_types.go @@ -45,12 +45,91 @@ type ExternalVolumeTemplate struct { StorageClassName string `json:"storageClassName"` } +// 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 + // +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"` +} + +// 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={actorMetadata} +type SystemInfoDataSource struct { + ActorMetadata *ActorMetadataDataSource `json:"actorMetadata,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). +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.filter(x, has(x.actorMetadata)).size() <= 1",message="dataSources must contain at most one actorMetadata entry" + 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 +141,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 4b0a5d54c..e5ab49e3d 100644 --- a/pkg/api/v1alpha1/actortemplate_validation_test.go +++ b/pkg/api/v1alpha1/actortemplate_validation_test.go @@ -807,7 +807,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) { @@ -816,7 +816,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) { @@ -830,7 +830,221 @@ 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: SystemInfo volume projecting all actor metadata fields is valid", + 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: ActorMetadataFieldAtespace, Path: "atespace"}, + {Field: ActorMetadataFieldUID, Path: "identity/actor-uid"}, + }, + }}, + }, + }, + }, + }, + } + 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 [actorMetadata] must be set", + }, { + name: "Volumes: SystemInfo actorMetadata with no items is invalid", + mutate: func(at *ActorTemplate) { + at.Spec.Volumes = []Volume{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ActorMetadata: &ActorMetadataDataSource{Items: []ActorMetadataItem{}}}, + }, + }, + }, + }, + } + }, + wantErr: true, + }, { + 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{ + {ActorMetadata: &ActorMetadataDataSource{ + Items: []ActorMetadataItem{ + {Field: ActorMetadataField("hostname"), Path: "hostname"}, + }, + }}, + }, + }, + }, + }, + } + }, + wantErr: true, + }, { + name: "Volumes: SystemInfo item with empty path 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: ""}, + }, + }}, + }, + }, + }, + }, + } + }, + wantErr: true, + }, { + name: "Volumes: SystemInfo item with absolute path 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: "/etc/actor-name"}, + }, + }}, + }, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "path must be a clean relative Unix path", + }, { + name: "Volumes: SystemInfo item with path traversal 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: "../escape"}, + }, + }}, + }, + }, + }, + }, + } + }, + wantErr: true, + errMsg: "path must be a clean relative Unix path", + }, { + 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{ + { + Name: "system-info", + VolumeSource: VolumeSource{ + SystemInfo: &SystemInfoVolumeSource{ + DataSources: []SystemInfoDataSource{ + {ActorMetadata: &ActorMetadataDataSource{ + Items: []ActorMetadataItem{{Field: ActorMetadataFieldName, Path: "actor-name"}}, + }}, + {ActorMetadata: &ActorMetadataDataSource{ + Items: []ActorMetadataItem{{Field: ActorMetadataFieldUID, Path: "actor-uid"}}, + }}, + }, + }, + }, + }, + } + }, + wantErr: true, + 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 bdcf3505c..e4a83d444 100644 --- a/pkg/api/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/api/v1alpha1/zz_generated.deepcopy.go @@ -24,6 +24,41 @@ 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 *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 ActorMetadataDataSource. +func (in *ActorMetadataDataSource) DeepCopy() *ActorMetadataDataSource { + if in == nil { + return nil + } + 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 +} + // 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 @@ -524,6 +559,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.ActorMetadata != nil { + in, out := &in.ActorMetadata, &out.ActorMetadata + *out = new(ActorMetadataDataSource) + (*in).DeepCopyInto(*out) + } +} + +// 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 @@ -568,6 +645,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.