Skip to content

Commit

Permalink
Backport GitHub Actions Docker image building to 1.4 series (#2706)
Browse files Browse the repository at this point in the history
* setup ci in github actions

Signed-off-by: Ashish Amarnath <ashisham@vmware.com>

* remove travis config

Signed-off-by: Ashish Amarnath <ashisham@vmware.com>

* Add changelog for v1.4.2

Signed-off-by: Nolan Brubaker <brubakern@vmware.com>

* update build status badge on readme

Signed-off-by: Ashish Amarnath <ashisham@vmware.com>

* don't error during backup when additional items returned by plugin don't exist (#2595)

* log a warning instead of erroring if additional item can't be found

Signed-off-by: Steve Kriss <krisss@vmware.com>

* always show backup warning/error count in get/describe

Signed-off-by: Steve Kriss <krisss@vmware.com>

* changelog

Signed-off-by: Steve Kriss <krisss@vmware.com>

* Update changelogs

Signed-off-by: Nolan Brubaker <brubakern@vmware.com>

Co-authored-by: Ashish Amarnath <ashisham@vmware.com>
Co-authored-by: Steve Kriss <krisss@vmware.com>
  • Loading branch information
3 people committed Jul 13, 2020
1 parent 6e0469e commit 56a08a4
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Pull Request CI Check
on: [push, pull_request]
on: [pull_request]
jobs:

build:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
12 changes: 9 additions & 3 deletions changelogs/CHANGELOG-1.4.md
Original file line number Diff line number Diff line change
@@ -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/
Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion changelogs/unreleased/2683-ashish-amarnath

This file was deleted.

1 change: 0 additions & 1 deletion changelogs/unreleased/2696-nrb

This file was deleted.

30 changes: 18 additions & 12 deletions hack/docker-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
4 changes: 3 additions & 1 deletion pkg/backup/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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",
},
Expand Down
13 changes: 11 additions & 2 deletions pkg/backup/item_backupper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/cmd/util/output/backup_describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 12 additions & 12 deletions pkg/cmd/util/output/backup_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand All @@ -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)
Expand Down Expand Up @@ -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}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/util/output/restore_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
}
Expand Down Expand Up @@ -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),
)
Expand Down
4 changes: 2 additions & 2 deletions site/docs/master/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions site/docs/v1.4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 56a08a4

Please sign in to comment.