Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed jobs clean broken command #2850

Merged
merged 10 commits into from
Nov 19, 2024
8 changes: 6 additions & 2 deletions cmd/jobsClean.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (
"github.com/Azure/azure-storage-azcopy/v10/common"
)

var JobsCleanupSuccessMsg = "Successfully removed all jobs."

func init() {
type JobsCleanReq struct {
withStatus string
Expand Down Expand Up @@ -122,10 +124,12 @@ func blindDeleteAllJobFiles() (int, error) {
if err != nil {
return numPlanFilesRemoved, err
}

// get rid of the logs
numLogFilesRemoved, err := removeFilesWithPredicate(azcopyLogPathFolder, func(s string) bool {
if strings.HasSuffix(s, ".log") {
// Do not remove the current job's log file this will cause the cleanup job to fail.
if strings.Contains(s, azcopyCurrentJobID.String()) {
return false
} else if strings.HasSuffix(s, ".log") {
return true
}
return false
Expand Down
20 changes: 11 additions & 9 deletions e2etest/newe2e_task_runazcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package e2etest
import (
"bytes"
"fmt"
"github.com/Azure/azure-storage-azcopy/v10/common"
"github.com/google/uuid"
"io"
"io/fs"
"os"
Expand All @@ -13,6 +11,9 @@ import (
"reflect"
"runtime/debug"
"strings"

"github.com/Azure/azure-storage-azcopy/v10/common"
"github.com/google/uuid"
)

// AzCopyJobPlan todo probably load the job plan directly? WI#26418256
Expand Down Expand Up @@ -52,13 +53,14 @@ var _ AzCopyStdout = &AzCopyRawStdout{}
type AzCopyVerb string

const ( // initially supporting a limited set of verbs
AzCopyVerbCopy AzCopyVerb = "copy"
AzCopyVerbSync AzCopyVerb = "sync"
AzCopyVerbRemove AzCopyVerb = "remove"
AzCopyVerbList AzCopyVerb = "list"
AzCopyVerbLogin AzCopyVerb = "login"
AzCopyVerbLogout AzCopyVerb = "logout"
AzCopyVerbJobsList AzCopyVerb = "jobs"
AzCopyVerbCopy AzCopyVerb = "copy"
AzCopyVerbSync AzCopyVerb = "sync"
AzCopyVerbRemove AzCopyVerb = "remove"
AzCopyVerbList AzCopyVerb = "list"
AzCopyVerbLogin AzCopyVerb = "login"
AzCopyVerbLogout AzCopyVerb = "logout"
AzCopyVerbJobsList AzCopyVerb = "jobs"
AzCopyVerbJobsCleanup AzCopyVerb = "jobs"
gapra-msft marked this conversation as resolved.
Show resolved Hide resolved
)

type AzCopyTarget struct {
Expand Down
23 changes: 23 additions & 0 deletions e2etest/zt_newe2e_jobs_clean_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package e2etest

import "github.com/Azure/azure-storage-azcopy/v10/cmd"

func init() {
suiteManager.RegisterSuite(&JobsCleanSuite{})
}

type JobsCleanSuite struct{}

func (s *JobsCleanSuite) Scenario_JobsCleanBasic(svm *ScenarioVariationManager) {

jobsCleanOutput, _ := RunAzCopy(
svm,
AzCopyCommand{
Verb: AzCopyVerbJobsCleanup,
PositionalArgs: []string{"clean"},
Flags: ListFlags{},
ShouldFail: false,
})

ValidateMessageOutput(svm, jobsCleanOutput, cmd.JobsCleanupSuccessMsg)
gapra-msft marked this conversation as resolved.
Show resolved Hide resolved
}
Loading