Honor remote session authoring updates after publication
This commit is contained in:
@@ -192,23 +192,29 @@ func loadPipelineConfigWithDependencies(pipelineFlag string, opts config.Pipelin
|
||||
}
|
||||
|
||||
func findRemoteSessionConfig(ctx context.Context, store storage.ObjectStore, sessionPrefix, remoteKey, campaign, sessionID string) (storage.ObjectInfo, string, error) {
|
||||
current, err := artifacts.LoadCurrentState(ctx, store, sessionPrefix, artifacts.CurrentStateValidation{ExpectedCampaign: campaign, ExpectedSessionID: sessionID, ValidateRunID: true})
|
||||
authored, err := store.Exists(ctx, remoteKey)
|
||||
if err != nil {
|
||||
return storage.ObjectInfo{}, "", fmt.Errorf("check authored session %q: %w", remoteKey, err)
|
||||
}
|
||||
var selected *artifacts.RemoteArtifact
|
||||
if err == nil {
|
||||
for _, item := range current.Commit.Artifacts {
|
||||
if item.Type == artifacts.RemoteArtifactTypeRunFile && item.Source == "run:prepare/inputs/session.yml" {
|
||||
identity, err := artifacts.ParseImmutableRunObjectKey(sessionPrefix, item.DestinationKey)
|
||||
if err != nil || "run:"+identity.RelativePath != item.Source {
|
||||
return storage.ObjectInfo{}, "", fmt.Errorf("committed session source does not match its object key")
|
||||
if !authored {
|
||||
current, err := artifacts.LoadCurrentState(ctx, store, sessionPrefix, artifacts.CurrentStateValidation{ExpectedCampaign: campaign, ExpectedSessionID: sessionID, ValidateRunID: true})
|
||||
if err == nil {
|
||||
for _, item := range current.Commit.Artifacts {
|
||||
if item.Type == artifacts.RemoteArtifactTypeRunFile && item.Source == "run:prepare/inputs/session.yml" {
|
||||
identity, err := artifacts.ParseImmutableRunObjectKey(sessionPrefix, item.DestinationKey)
|
||||
if err != nil || "run:"+identity.RelativePath != item.Source {
|
||||
return storage.ObjectInfo{}, "", fmt.Errorf("committed session source does not match its object key")
|
||||
}
|
||||
copy := item
|
||||
selected = ©
|
||||
remoteKey = item.DestinationKey
|
||||
break
|
||||
}
|
||||
copy := item
|
||||
selected = ©
|
||||
remoteKey = item.DestinationKey
|
||||
break
|
||||
}
|
||||
} else if !errors.Is(err, artifacts.ErrCurrentCommitPointerMissing) {
|
||||
return storage.ObjectInfo{}, "", fmt.Errorf("load remote session selection: %w", err)
|
||||
}
|
||||
} else if !errors.Is(err, artifacts.ErrCurrentCommitPointerMissing) {
|
||||
return storage.ObjectInfo{}, "", fmt.Errorf("load remote session selection: %w", err)
|
||||
}
|
||||
objects, err := store.List(ctx, sessionPrefix)
|
||||
if err != nil {
|
||||
|
||||
@@ -120,6 +120,29 @@ func TestPreparedSessionPublishAndRemoteLoad(t *testing.T) {
|
||||
if err != nil || string(restored) != string(fake.Objects[key].Data) {
|
||||
t.Fatalf("restored session = %q, %v", restored, err)
|
||||
}
|
||||
committedBytes := string(fake.Objects[key].Data)
|
||||
if err := sessionInitWithDependencies(ctx, []string{m.SessionID, "--config", pipelinePath, "--campaign-file", campaignPath, "--remote", "--force", "--title", "Updated title", "--audio-s3-prefix", "replacement/"}, &output, deps); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
updated, err := loadCommandConfigWithDependencies(ctx, pipelinePath, "", campaignPath, "", config.SessionLoadOptions{SessionID: m.SessionID}, nil, deps)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { _ = updated.Close() }()
|
||||
if updated.Config.Session.Title != "Updated title" || updated.Config.Session.Inputs.AudioS3 == nil || updated.Config.Session.Inputs.AudioS3.Prefix != "replacement/" {
|
||||
t.Fatalf("remote edit ignored: %#v", updated.Config.Session)
|
||||
}
|
||||
if string(fake.Objects[key].Data) != committedBytes {
|
||||
t.Fatal("authoring update changed committed input")
|
||||
}
|
||||
if _, err := discoverRemoteCurrentState(ctx, updated.Config, fake); err != nil {
|
||||
t.Fatalf("committed state after authoring update: %v", err)
|
||||
}
|
||||
// Remove the authored override to exercise committed-snapshot integrity below.
|
||||
rootKey := artifacts.S3SessionConfigKey(prefix)
|
||||
if err := fake.Delete(ctx, rootKey); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
object := fake.Objects[key]
|
||||
modified := append([]byte(nil), object.Data...)
|
||||
modified[0] ^= 1
|
||||
|
||||
Reference in New Issue
Block a user