Skip to content

Commit

Permalink
Merge pull request #24178 from a-robinson/nullzone
Browse files Browse the repository at this point in the history
cli: Don't fail `zone ls` on zones from deleted tables/partitions
  • Loading branch information
a-robinson authored Mar 23, 2018
2 parents d5cfede + deb891c commit 458498e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
40 changes: 40 additions & 0 deletions pkg/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,13 @@ func Example_zone() {
c.Run("zone rm .timeseries")
c.Run("zone set system.jobs@primary --file=./testdata/zone_attrs.yaml")
c.Run("zone set system --file=./testdata/zone_attrs_advanced.yaml")
c.RunWithArgs([]string{"sql", "-e", "create database t; create table t.f (x int, y int)"})
c.Run("zone set t --file=./testdata/zone_range_max_bytes.yaml")
c.Run("zone ls")
c.Run("zone set t.f --file=./testdata/zone_range_max_bytes.yaml")
c.Run("zone ls")
c.RunWithArgs([]string{"sql", "-e", "drop database t cascade"})
c.Run("zone ls")

// Output:
// zone ls
Expand Down Expand Up @@ -643,6 +650,39 @@ func Example_zone() {
// num_replicas: 3
// constraints: {'+us-east-1a,+ssd': 1, +us-east-1b: 1}
// experimental_lease_preferences: [[+us-east1b], [+us-east-1a]]
// sql -e create database t; create table t.f (x int, y int)
// CREATE TABLE
// zone set t --file=./testdata/zone_range_max_bytes.yaml
// range_min_bytes: 1048576
// range_max_bytes: 134217728
// gc:
// ttlseconds: 90000
// num_replicas: 3
// constraints: []
// zone ls
// .default
// system
// system.jobs
// t
// zone set t.f --file=./testdata/zone_range_max_bytes.yaml
// range_min_bytes: 1048576
// range_max_bytes: 134217728
// gc:
// ttlseconds: 90000
// num_replicas: 3
// constraints: []
// zone ls
// .default
// system
// system.jobs
// t
// t.f
// sql -e drop database t cascade
// DROP DATABASE
// zone ls
// .default
// system
// system.jobs
}

func Example_sql() {
Expand Down
8 changes: 8 additions & 0 deletions pkg/cli/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ func queryZoneSpecifiers(conn *sqlConn) ([]string, error) {
return nil, err
}

if vals[0] == nil {
// Zone configs for deleted tables and partitions are left around until
// their table descriptors are deleted, which happens after the
// configured GC TTL duration. Such zones have no cli_specifier and
// shouldn't be displayed.
continue
}

s, ok := vals[0].(string)
if !ok {
return nil, fmt.Errorf("unexpected value: %T", vals[0])
Expand Down

0 comments on commit 458498e

Please sign in to comment.