diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2c5964175..e94d41499 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,5 +1,5 @@ name: Pull Request CI Check -on: [push, pull_request] +on: [pull_request] jobs: build: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 000000000..996c9780e --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,34 @@ +name: Master CI + +on: + push: + branches: [ master ] + tags: + - '*' + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.14 + uses: actions/setup-go@v2 + with: + go-version: 1.14 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build + run: make local + + - name: Test + run: make test + + - name: Publish container image + run: | + docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }} + ./hack/docker-push.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index dab15d2bb..000000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -dist: xenial -language: go -go: -- 1.14.x -sudo: required -services: -- docker -script: -- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; - else echo $TRAVIS_PULL_REQUEST_BRANCH; fi) -- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$TRAVIS_PULL_REQUEST, BRANCH=$BRANCH" -- hack/ci-check.sh -deploy: -- provider: script - skip_cleanup: true - script: hack/docker-push.sh - on: - repo: vmware-tanzu/velero - all_branches: true -env: - global: - # generated using `travis encrypt`: https://docs.travis-ci.com/user/environment-variables#encrypting-environment-variables - - secure: Sa0R7bhOvrybIWvURjEpOLQ3/v1IqiSM2uwYTSMhLtwHunkiYXpbXi/wVPkujM7kgnFeJzGfNTZI6blkl3Vnz6Ca48avxiv+KRk7bNlTn/e2LkJaqOh/NcwqrVyWG8cZpWTHAzwJkHrV6xcWRTWFqx/UhUHH4PdmXd0pj3/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S3uqb4UlvLBqXDPVWBBIgmPrSgvHXxbjsajFuyWTULm60nj/JUuh7BC9HF9pil3g4/2E9cpLZCFQxVYu6+30eEv4dCO7Ptq3XIINDWbbS6Pmw62/ZsE8ABU= diff --git a/README.md b/README.md index d5ef05bd0..bfc1b9391 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,8 @@ If you are ready to jump in and test, add code, or help with documentation, foll See [the list of releases][6] to find out about feature changes. -[1]: https://travis-ci.org/vmware-tanzu/velero.svg?branch=master -[2]: https://travis-ci.org/vmware-tanzu/velero +[1]: https://github.com/vmware-tanzu/velero/workflows/Master%20CI/badge.svg +[2]: https://github.com/vmware-tanzu/velero/actions?query=workflow%3A"Master+CI" [4]: https://github.com/vmware-tanzu/velero/issues [6]: https://github.com/vmware-tanzu/velero/releases [9]: https://kubernetes.io/docs/setup/ diff --git a/changelogs/CHANGELOG-1.4.md b/changelogs/CHANGELOG-1.4.md index fb7881213..354e68514 100644 --- a/changelogs/CHANGELOG-1.4.md +++ b/changelogs/CHANGELOG-1.4.md @@ -1,11 +1,11 @@ -## v1.4.1 +## v1.4.2 ### 2020-07-13 ### Download -https://github.com/vmware-tanzu/velero/releases/tag/v1.4.1 +https://github.com/vmware-tanzu/velero/releases/tag/v1.4.2 ### Container Image -`velero/velero:v1.4.1` +`velero/velero:v1.4.2` ### Documentation https://velero.io/docs/v1.4/ @@ -14,9 +14,15 @@ https://velero.io/docs/v1.4/ https://velero.io/docs/v1.4/upgrade-to-1.4/ ### All Changes + * log a warning instead of erroring if an additional item returned from a plugin can't be found in the Kubernetes API (#2595, @skriss) * Adjust restic default time out to 4 hours and base pod resource requests to 500m CPU/512Mi memory. (#2696, @nrb) * capture version of the CRD prior before invoking the remap_crd_version backup item action (#2683, @ashish-amarnath) + +## v1.4.1 + +This tag was created in code, but has no associated docker image due to misconfigured building infrastructure. v1.4.2 fixes this. + ## v1.4.0 ### 2020-05-26 diff --git a/changelogs/unreleased/2683-ashish-amarnath b/changelogs/unreleased/2683-ashish-amarnath deleted file mode 100644 index 014606d7e..000000000 --- a/changelogs/unreleased/2683-ashish-amarnath +++ /dev/null @@ -1 +0,0 @@ -capture version of the CRD prior before invoking the remap_crd_version backup item action diff --git a/changelogs/unreleased/2696-nrb b/changelogs/unreleased/2696-nrb deleted file mode 100644 index 5e91e5994..000000000 --- a/changelogs/unreleased/2696-nrb +++ /dev/null @@ -1 +0,0 @@ -Adjust restic default time out to 4 hours and base pod resource requests to 500m CPU/512Mi memory. diff --git a/hack/docker-push.sh b/hack/docker-push.sh index 6096be14f..4001bc369 100755 --- a/hack/docker-push.sh +++ b/hack/docker-push.sh @@ -20,8 +20,8 @@ set +x -if [[ -z "$TRAVIS" ]]; then - echo "This script is intended to be run only on Travis." >&2 +if [[ -z "$CI" ]]; then + echo "This script is intended to be run only on Github Actions." >&2 exit 1 fi @@ -47,37 +47,43 @@ function highest_release() { done } +triggeredBy=$(echo $GITHUB_REF | cut -d / -f 2) +if [[ "$triggeredBy" == "heads" ]]; then + BRANCH=$(echo $GITHUB_REF | cut -d / -f 3) + TAG= +elif [[ "$triggeredBy" == "tags" ]]; then + BRANCH= + TAG=$(echo $GITHUB_REF | cut -d / -f 3) +fi + if [[ "$BRANCH" == "master" ]]; then VERSION="$BRANCH" -elif [[ ! -z "$TRAVIS_TAG" ]]; then - # Tags aren't fetched by Travis on checkout, and we don't need them for master +elif [[ ! -z "$TAG" ]]; then + # Explicitly checkout tags when building from a git tag. + # This is not needed when building from master git fetch --tags # Calculate the latest release if there's a tag. highest_release - VERSION="$TRAVIS_TAG" + VERSION="$TAG" else - # If we're not on master and we're not building a tag, exit early. + echo "We're not on master and we're not building a tag, exit early." exit 0 fi - # Assume we're not tagging `latest` by default, and never on master. TAG_LATEST=false if [[ "$BRANCH" == "master" ]]; then echo "Building master, not tagging latest." -elif [[ "$TRAVIS_TAG" == "$HIGHEST" ]]; then +elif [[ "$TAG" == "$HIGHEST" ]]; then TAG_LATEST=true fi # Debugging info echo "Highest tag found: $HIGHEST" echo "BRANCH: $BRANCH" -echo "TRAVIS_TAG: $TRAVIS_TAG" +echo "TAG: $TAG" echo "TAG_LATEST: $TAG_LATEST" -echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin -unset GIT_HTTP_USER_AGENT - echo "Building and pushing container images." VERSION="$VERSION" TAG_LATEST="$TAG_LATEST" make all-containers all-push all-manifests diff --git a/pkg/backup/backup_test.go b/pkg/backup/backup_test.go index 2ad8079a3..5d9f5c8b2 100644 --- a/pkg/backup/backup_test.go +++ b/pkg/backup/backup_test.go @@ -1723,7 +1723,7 @@ func TestBackupActionAdditionalItems(t *testing.T) { }, { - name: "if there's an error backing up additional items, the item the action was run for isn't backed up", + name: "if additional items aren't found in the API, they're skipped and the original item is still backed up", backup: defaultBackup().Result(), apiResources: []*test.APIResource{ test.Pods( @@ -1746,8 +1746,10 @@ func TestBackupActionAdditionalItems(t *testing.T) { }, }, want: []string{ + "resources/pods/namespaces/ns-1/pod-1.json", "resources/pods/namespaces/ns-2/pod-2.json", "resources/pods/namespaces/ns-3/pod-3.json", + "resources/pods/v1-preferredversion/namespaces/ns-1/pod-1.json", "resources/pods/v1-preferredversion/namespaces/ns-2/pod-2.json", "resources/pods/v1-preferredversion/namespaces/ns-3/pod-3.json", }, diff --git a/pkg/backup/item_backupper.go b/pkg/backup/item_backupper.go index 4ee4920b5..e666084fa 100644 --- a/pkg/backup/item_backupper.go +++ b/pkg/backup/item_backupper.go @@ -26,6 +26,7 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" corev1api "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" @@ -341,12 +342,20 @@ func (ib *itemBackupper) executeActions( return nil, err } - additionalItem, err := client.Get(additionalItem.Name, metav1.GetOptions{}) + item, err := client.Get(additionalItem.Name, metav1.GetOptions{}) + if apierrors.IsNotFound(err) { + log.WithFields(logrus.Fields{ + "groupResource": additionalItem.GroupResource, + "namespace": additionalItem.Namespace, + "name": additionalItem.Name, + }).Warnf("Additional item was not found in Kubernetes API, can't back it up") + continue + } if err != nil { return nil, errors.WithStack(err) } - if _, err = ib.backupItem(log, additionalItem, gvr.GroupResource(), gvr); err != nil { + if _, err = ib.backupItem(log, item, gvr.GroupResource(), gvr); err != nil { return nil, err } } diff --git a/pkg/cmd/util/output/backup_describer.go b/pkg/cmd/util/output/backup_describer.go index 3334b87c2..a6893bbf1 100644 --- a/pkg/cmd/util/output/backup_describer.go +++ b/pkg/cmd/util/output/backup_describer.go @@ -70,11 +70,9 @@ func DescribeBackup( } } - if status.Phase == velerov1api.BackupPhasePartiallyFailed { - d.Println() - d.Printf("Errors:\t%d\n", status.Errors) - d.Printf("Warnings:\t%d\n", status.Warnings) - } + d.Println() + d.Printf("Errors:\t%d\n", status.Errors) + d.Printf("Warnings:\t%d\n", status.Warnings) d.Println() DescribeBackupSpec(d, backup.Spec) diff --git a/pkg/cmd/util/output/backup_printer.go b/pkg/cmd/util/output/backup_printer.go index fa889c591..bae077a29 100644 --- a/pkg/cmd/util/output/backup_printer.go +++ b/pkg/cmd/util/output/backup_printer.go @@ -35,6 +35,8 @@ var ( // https://github.com/kubernetes/kubernetes/blob/v1.15.3/pkg/printers/tableprinter.go#L204 {Name: "Name", Type: "string", Format: "name"}, {Name: "Status"}, + {Name: "Errors"}, + {Name: "Warnings"}, {Name: "Created"}, {Name: "Expires"}, {Name: "Storage Location"}, @@ -58,7 +60,6 @@ func printBackupList(list *velerov1api.BackupList) []metav1.TableRow { var timestampSuffix = regexp.MustCompile("-[0-9]{14}$") func sortBackupsByPrefixAndTimestamp(list *velerov1api.BackupList) { - sort.Slice(list.Items, func(i, j int) bool { iSuffixIndex := timestampSuffix.FindStringIndex(list.Items[i].Name) jSuffixIndex := timestampSuffix.FindStringIndex(list.Items[j].Name) @@ -98,18 +99,17 @@ func printBackup(backup *velerov1api.Backup) []metav1.TableRow { if backup.DeletionTimestamp != nil && !backup.DeletionTimestamp.Time.IsZero() { status = "Deleting" } - if status == string(velerov1api.BackupPhasePartiallyFailed) { - if backup.Status.Errors == 1 { - status = fmt.Sprintf("%s (1 error)", status) - } else { - status = fmt.Sprintf("%s (%d errors)", status, backup.Status.Errors) - } - } - - location := backup.Spec.StorageLocation - - row.Cells = append(row.Cells, backup.Name, status, backup.Status.StartTimestamp, humanReadableTimeFromNow(expiration), location, metav1.FormatLabelSelector(backup.Spec.LabelSelector)) + row.Cells = append(row.Cells, + backup.Name, + status, + backup.Status.Errors, + backup.Status.Warnings, + backup.Status.StartTimestamp, + humanReadableTimeFromNow(expiration), + backup.Spec.StorageLocation, + metav1.FormatLabelSelector(backup.Spec.LabelSelector), + ) return []metav1.TableRow{row} } diff --git a/pkg/cmd/util/output/restore_printer.go b/pkg/cmd/util/output/restore_printer.go index 86900b721..4ab557ff0 100644 --- a/pkg/cmd/util/output/restore_printer.go +++ b/pkg/cmd/util/output/restore_printer.go @@ -30,8 +30,8 @@ var ( {Name: "Name", Type: "string", Format: "name"}, {Name: "Backup"}, {Name: "Status"}, - {Name: "Warnings"}, {Name: "Errors"}, + {Name: "Warnings"}, {Name: "Created"}, {Name: "Selector"}, } @@ -60,8 +60,8 @@ func printRestore(restore *v1.Restore) []metav1.TableRow { restore.Name, restore.Spec.BackupName, status, - restore.Status.Warnings, restore.Status.Errors, + restore.Status.Warnings, restore.CreationTimestamp.Time, metav1.FormatLabelSelector(restore.Spec.LabelSelector), ) diff --git a/site/docs/master/README.md b/site/docs/master/README.md index cacf4289e..747cc079e 100644 --- a/site/docs/master/README.md +++ b/site/docs/master/README.md @@ -33,8 +33,8 @@ If you are ready to jump in and test, add code, or help with documentation, foll See [the list of releases][6] to find out about feature changes. -[1]: https://travis-ci.org/vmware-tanzu/velero.svg?branch=master -[2]: https://travis-ci.org/vmware-tanzu/velero +[1]: https://github.com/vmware-tanzu/velero/workflows/Master%20CI/badge.svg +[2]: https://github.com/vmware-tanzu/velero/actions?query=workflow%3A"Master+CI" [4]: https://github.com/vmware-tanzu/velero/issues [6]: https://github.com/vmware-tanzu/velero/releases diff --git a/site/docs/v1.4/README.md b/site/docs/v1.4/README.md index a4b2c8ec7..74b5aeefa 100644 --- a/site/docs/v1.4/README.md +++ b/site/docs/v1.4/README.md @@ -33,8 +33,8 @@ If you are ready to jump in and test, add code, or help with documentation, foll See [the list of releases][6] to find out about feature changes. -[1]: https://travis-ci.org/vmware-tanzu/velero.svg?branch=master -[2]: https://travis-ci.org/vmware-tanzu/velero +[1]: https://github.com/vmware-tanzu/velero/workflows/Master%20CI/badge.svg +[2]: https://github.com/vmware-tanzu/velero/actions?query=workflow%3A"Master+CI" [4]: https://github.com/vmware-tanzu/velero/issues [6]: https://github.com/vmware-tanzu/velero/releases