From 70020ea7137e884fa4ffa5777682667160d93c43 Mon Sep 17 00:00:00 2001 From: Piotr Andruszkiewicz Date: Wed, 15 Nov 2023 11:53:29 +0100 Subject: [PATCH 1/3] #201 Report lack of disk space more nicely --- pkg/package_manager.go | 11 ++++++-- pkg/package_manager_test.go | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 pkg/package_manager_test.go diff --git a/pkg/package_manager.go b/pkg/package_manager.go index d83cebca..cf56f7ac 100644 --- a/pkg/package_manager.go +++ b/pkg/package_manager.go @@ -401,7 +401,7 @@ func (pm *PackageManager) uploadOptimized(localPath string) (string, error) { return "", fmt.Errorf("%s > cannot upload package '%s'; cannot parse response: %w", pm.instance.ID(), localPath, err) } if !status.Success { - return "", fmt.Errorf("%s > cannot upload package '%s'; unexpected status: %s", pm.instance.ID(), localPath, status.Message) + return "", fmt.Errorf("%s > cannot upload package '%s'; %s", pm.instance.ID(), localPath, pm.interpretFail(status.Message)) } log.Infof("%s > uploaded package '%s'", pm.instance.ID(), localPath) return status.Path, nil @@ -423,12 +423,19 @@ func (pm *PackageManager) uploadBuffered(localPath string) (string, error) { return "", fmt.Errorf("%s > cannot upload package '%s'; cannot parse response: %w", pm.instance.ID(), localPath, err) } if !status.Success { - return "", fmt.Errorf("%s > cannot upload package '%s'; unexpected status: %s", pm.instance.ID(), localPath, status.Message) + return "", fmt.Errorf("%s > cannot upload package '%s'; %s", pm.instance.ID(), localPath, pm.interpretFail(status.Message)) } log.Infof("%s > uploaded package '%s'", pm.instance.ID(), localPath) return status.Path, nil } +func (pm *PackageManager) interpretFail(message string) string { + if strings.EqualFold(message, "Inaccessible value") { + return fmt.Sprintf("probably no disk space left (server respond with '%s')", message) // https://forums.adobe.com/thread/2338290 + } + return fmt.Sprintf("unexpected status: %s", message) +} + func (pm *PackageManager) Install(remotePath string) error { if pm.InstallHTMLEnabled { return pm.installHTML(remotePath) diff --git a/pkg/package_manager_test.go b/pkg/package_manager_test.go new file mode 100644 index 00000000..2519e550 --- /dev/null +++ b/pkg/package_manager_test.go @@ -0,0 +1,51 @@ +package pkg + +import ( + "github.com/stretchr/testify/assert" + "testing" +) + +func TestPackageManager_interpretFail(t *testing.T) { + type fields struct { + instance *Instance + UploadOptimized bool + InstallRecursive bool + InstallHTMLEnabled bool + InstallHTMLConsole bool + InstallHTMLStrict bool + SnapshotDeploySkipping bool + SnapshotIgnored bool + SnapshotPatterns []string + ToggledWorkflows []string + } + type args struct { + message string + } + tests := []struct { + name string + fields fields + args args + want string + }{ + {"no message", fields{}, args{}, "unexpected status: "}, + {"generic message", fields{}, args{"generic message"}, "unexpected status: generic message"}, + {"inaccessible value", fields{}, args{"Inaccessible value"}, "probably no disk space left (server respond with 'Inaccessible value')"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + pm := &PackageManager{ + instance: tt.fields.instance, + UploadOptimized: tt.fields.UploadOptimized, + InstallRecursive: tt.fields.InstallRecursive, + InstallHTMLEnabled: tt.fields.InstallHTMLEnabled, + InstallHTMLConsole: tt.fields.InstallHTMLConsole, + InstallHTMLStrict: tt.fields.InstallHTMLStrict, + SnapshotDeploySkipping: tt.fields.SnapshotDeploySkipping, + SnapshotIgnored: tt.fields.SnapshotIgnored, + SnapshotPatterns: tt.fields.SnapshotPatterns, + ToggledWorkflows: tt.fields.ToggledWorkflows, + } + assert.Equalf(t, tt.want, pm.interpretFail(tt.args.message), "interpretFail(%v)", tt.args.message) + }) + } +} From d4450cdfe5745947fc8b8e37923ce2284e60768d Mon Sep 17 00:00:00 2001 From: Piotr Andruszkiewicz Date: Wed, 15 Nov 2023 12:57:56 +0100 Subject: [PATCH 2/3] #201 When interpreting fail message, use Contains and ToLower --- pkg/package_manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/package_manager.go b/pkg/package_manager.go index cf56f7ac..df9a2659 100644 --- a/pkg/package_manager.go +++ b/pkg/package_manager.go @@ -430,7 +430,7 @@ func (pm *PackageManager) uploadBuffered(localPath string) (string, error) { } func (pm *PackageManager) interpretFail(message string) string { - if strings.EqualFold(message, "Inaccessible value") { + if strings.Contains(strings.ToLower(message), "inaccessible value") { return fmt.Sprintf("probably no disk space left (server respond with '%s')", message) // https://forums.adobe.com/thread/2338290 } return fmt.Sprintf("unexpected status: %s", message) From 60f760e87972ead10f7fd41504caa2a96ee91b93 Mon Sep 17 00:00:00 2001 From: Piotr Andruszkiewicz Date: Wed, 22 Nov 2023 11:50:14 +0100 Subject: [PATCH 3/3] #201 New message on disk space issues --- pkg/package_manager.go | 3 +++ pkg/package_manager_test.go | 51 ------------------------------------- 2 files changed, 3 insertions(+), 51 deletions(-) delete mode 100644 pkg/package_manager_test.go diff --git a/pkg/package_manager.go b/pkg/package_manager.go index df9a2659..dced5b05 100644 --- a/pkg/package_manager.go +++ b/pkg/package_manager.go @@ -433,6 +433,9 @@ func (pm *PackageManager) interpretFail(message string) string { if strings.Contains(strings.ToLower(message), "inaccessible value") { return fmt.Sprintf("probably no disk space left (server respond with '%s')", message) // https://forums.adobe.com/thread/2338290 } + if strings.Contains(strings.ToLower(message), "package file parameter missing") { + return fmt.Sprintf("probably no disk space left (server respond with '%s')", message) + } return fmt.Sprintf("unexpected status: %s", message) } diff --git a/pkg/package_manager_test.go b/pkg/package_manager_test.go deleted file mode 100644 index 2519e550..00000000 --- a/pkg/package_manager_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package pkg - -import ( - "github.com/stretchr/testify/assert" - "testing" -) - -func TestPackageManager_interpretFail(t *testing.T) { - type fields struct { - instance *Instance - UploadOptimized bool - InstallRecursive bool - InstallHTMLEnabled bool - InstallHTMLConsole bool - InstallHTMLStrict bool - SnapshotDeploySkipping bool - SnapshotIgnored bool - SnapshotPatterns []string - ToggledWorkflows []string - } - type args struct { - message string - } - tests := []struct { - name string - fields fields - args args - want string - }{ - {"no message", fields{}, args{}, "unexpected status: "}, - {"generic message", fields{}, args{"generic message"}, "unexpected status: generic message"}, - {"inaccessible value", fields{}, args{"Inaccessible value"}, "probably no disk space left (server respond with 'Inaccessible value')"}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - pm := &PackageManager{ - instance: tt.fields.instance, - UploadOptimized: tt.fields.UploadOptimized, - InstallRecursive: tt.fields.InstallRecursive, - InstallHTMLEnabled: tt.fields.InstallHTMLEnabled, - InstallHTMLConsole: tt.fields.InstallHTMLConsole, - InstallHTMLStrict: tt.fields.InstallHTMLStrict, - SnapshotDeploySkipping: tt.fields.SnapshotDeploySkipping, - SnapshotIgnored: tt.fields.SnapshotIgnored, - SnapshotPatterns: tt.fields.SnapshotPatterns, - ToggledWorkflows: tt.fields.ToggledWorkflows, - } - assert.Equalf(t, tt.want, pm.interpretFail(tt.args.message), "interpretFail(%v)", tt.args.message) - }) - } -}