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

Upgrade kubernetes dependencies to 1.15.3 #1808

Merged
merged 4 commits into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 34 additions & 17 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@

[[constraint]]
name = "k8s.io/kubernetes"
version = "~1.14"
version = "~1.15"

[[constraint]]
name = "k8s.io/client-go"
version = "kubernetes-1.14.0"
version = "kubernetes-1.15.3"

[[constraint]]
name = "k8s.io/apimachinery"
version = "kubernetes-1.14.0"
version = "kubernetes-1.15.3"

[[constraint]]
name = "k8s.io/api"
version = "kubernetes-1.14.0"
version = "kubernetes-1.15.3"

[[constraint]]
name = "k8s.io/apiextensions-apiserver"
version = "kubernetes-1.14.0"
version = "kubernetes-1.15.3"

# k8s.io/client-go kubernetes-1.14.0 uses v1.1.4
# k8s.io/client-go kubernetes-1.15.3 uses v1.1.4
[[override]]
name = "github.com/json-iterator/go"
version = "=1.1.4"
Expand All @@ -65,7 +65,7 @@
name = "github.com/Azure/azure-sdk-for-go"
version = "~21.4.0"

# k8s.io/client-go kubernetes-1.14.0 uses v11.1.2
# k8s.io/client-go kubernetes-1.15.3 uses v11.1.2
[[constraint]]
name = "github.com/Azure/go-autorest"
version = "11.1.2"
Expand Down
6 changes: 4 additions & 2 deletions hack/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ FROM golang:1.12
RUN mkdir -p /go/src/k8s.io && \
cd /go/src/k8s.io && \
git config --global advice.detachedHead false && \
git clone -b kubernetes-1.14.0 https://github.com/kubernetes/code-generator && \
git clone -b kubernetes-1.14.0 https://github.com/kubernetes/apimachinery && \
git clone -b kubernetes-1.15.3 https://github.com/kubernetes/code-generator && \
git clone -b kubernetes-1.15.3 https://github.com/kubernetes/apimachinery && \
# vendor code-generator go modules to be compatible with pre-1.15
cd /go/src/k8s.io/code-generator && GO111MODULE=on go mod vendor && \
go get golang.org/x/tools/cmd/goimports && \
cd /go/src/golang.org/x/tools && \
git checkout 40a48ad93fbe707101afb2099b738471f70594ec && \
Expand Down
22 changes: 11 additions & 11 deletions pkg/apis/velero/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 23 additions & 22 deletions pkg/cmd/util/output/backup_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,43 @@ package output

import (
"fmt"
"io"
"regexp"
"sort"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/duration"
"k8s.io/kubernetes/pkg/printers"

velerov1api "github.com/heptio/velero/pkg/apis/velero/v1"
)

var (
backupColumns = []string{"NAME", "STATUS", "CREATED", "EXPIRES", "STORAGE LOCATION", "SELECTOR"}
backupColumns = []metav1.TableColumnDefinition{
// name needs Type and Format defined for the decorator to identify it:
// https://github.com/kubernetes/kubernetes/blob/v1.15.3/pkg/printers/tableprinter.go#L204
{Name: "Name", Type: "string", Format: "name"},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I'm using capitalisation for the Name field as this is what upstream is doing for core resources: https://github.com/kubernetes/kubernetes/blob/d2e2337744072553ae7756ba972607ffb6532a85/pkg/printers/internalversion/printers.go#L80

{Name: "Status"},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've decided to omit the type/format/description for all the other columns, I can't seem to find where they are used and we didn't have them before.

{Name: "Created"},
{Name: "Expires"},
{Name: "Storage Location"},
{Name: "Selector"},
}
)

func printBackupList(list *velerov1api.BackupList, w io.Writer, options printers.PrintOptions) error {
func printBackupList(list *velerov1api.BackupList, options printers.PrintOptions) ([]metav1.TableRow, error) {
sortBackupsByPrefixAndTimestamp(list)
rows := make([]metav1.TableRow, 0, len(list.Items))

for i := range list.Items {
if err := printBackup(&list.Items[i], w, options); err != nil {
return err
r, err := printBackup(&list.Items[i], options)
if err != nil {
return nil, err
}
rows = append(rows, r...)
}
return nil
return rows, nil
}

// sort by default alphabetically, but if backups stem from a common schedule
Expand Down Expand Up @@ -71,13 +83,9 @@ func sortBackupsByPrefixAndTimestamp(list *velerov1api.BackupList) {
})
}

func printBackup(backup *velerov1api.Backup, w io.Writer, options printers.PrintOptions) error {
name := printers.FormatResourceName(options.Kind, backup.Name, options.WithKind)

if options.WithNamespace {
if _, err := fmt.Fprintf(w, "%s\t", backup.Namespace); err != nil {
return err
}
func printBackup(backup *velerov1api.Backup, options printers.PrintOptions) ([]metav1.TableRow, error) {
row := metav1.TableRow{
Object: runtime.RawExtension{Object: backup},
}

expiration := backup.Status.Expiration.Time
Expand All @@ -103,16 +111,9 @@ func printBackup(backup *velerov1api.Backup, w io.Writer, options printers.Print

location := backup.Spec.StorageLocation

if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s", name, status, backup.Status.StartTimestamp.Time, humanReadableTimeFromNow(expiration), location, metav1.FormatLabelSelector(backup.Spec.LabelSelector)); err != nil {
return err
}

if _, err := fmt.Fprint(w, printers.AppendLabels(backup.Labels, options.ColumnLabels)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where L110-115 are getting carried over - is this handled for us, or do we need to retain some custom code? Same question for the other printers as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to support the --show-labels and --label-columns flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, should have made that more clear. It's now handled for us in https://github.com/kubernetes/kubernetes/blob/v1.15.3/pkg/printers/tableprinter.go#L190, see the logic around options.ShowLabels and options.ColumnLabels which we set when we initialise the printer: https://github.com/heptio/velero/blob/772459a8b40fd3d26e98397e27302d235b4d1584/pkg/cmd/util/output/output.go#L174-L177.

I've also manually tested each command and variations of show-labels/label-columns to ensure it matches the output from before.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, awesome! I figured you were on top of this, just didn't see it myself :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it took me a while to figure out too, it was pretty hidden there. Overall I think the improvements to the printer package are really great, it's so much simpler to use now :)

return err
}
row.Cells = append(row.Cells, backup.Name, status, backup.Status.StartTimestamp.Time, humanReadableTimeFromNow(expiration), location, metav1.FormatLabelSelector(backup.Spec.LabelSelector))

_, err := fmt.Fprint(w, printers.AppendAllLabels(options.ShowLabels, backup.Labels))
return err
return []metav1.TableRow{row}, nil
}

func humanReadableTimeFromNow(when time.Time) string {
Expand Down
Loading