Skip to content

Commit

Permalink
Remove PowerDNS dependent --dns flang ad related functionality
Browse files Browse the repository at this point in the history
PowerDNS is being removed from the BOSH Director, and as a consequence
the data returned from the `instances` and `vms` commands no longer have
DNS data returned.

This commit removes the `--dns` flag and logic to display the data
returnd when it is sent.

Add a spec to validate that the CLI continues to handle responses from
directors which still have PowerDNS code. Concretely this means the VM
info response has a `"dns"` key in it.

See: cloudfoundry/bosh#2501
  • Loading branch information
aramprice committed Mar 22, 2024
1 parent d33ce3c commit fb08fb4
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 232 deletions.
15 changes: 1 addition & 14 deletions cmd/instance_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ type InstanceTableValues struct {

Stemcell boshtbl.Value

// DNS
DNS boshtbl.Value

// Vitals
Uptime boshtbl.Value // only for Process
Load boshtbl.Value
Expand Down Expand Up @@ -76,9 +73,6 @@ var InstanceTableHeader = InstanceTableValues{

Stemcell: boshtbl.NewValueString("Stemcell"),

// DNS
DNS: boshtbl.NewValueString("DNS A Records"),

// Vitals
Uptime: boshtbl.NewValueString("Uptime"), // only for Process
Load: boshtbl.NewValueString("Load\n(1m, 5m, 15m)"),
Expand All @@ -97,7 +91,7 @@ var InstanceTableHeader = InstanceTableValues{
}

type InstanceTable struct {
Processes, VMDetails, DeploymentDetails, Details, Stemcell, DNS, Vitals, CloudProperties bool
Processes, VMDetails, DeploymentDetails, Details, Stemcell, Vitals, CloudProperties bool
}

func (t InstanceTable) Headers() []boshtbl.Header {
Expand Down Expand Up @@ -155,9 +149,6 @@ func (t InstanceTable) ForVMInfo(i boshdir.VMInfo) InstanceTableValues {

Stemcell: boshtbl.NewValueString(stemcell),

// DNS
DNS: boshtbl.NewValueStrings(i.DNS),

// Vitals
Uptime: ValueUptime{i.Vitals.Uptime.Seconds},
Load: boshtbl.NewValueString(strings.Join(i.Vitals.Load, ", ")),
Expand Down Expand Up @@ -241,10 +232,6 @@ func (t InstanceTable) AsValues(v InstanceTableValues) []boshtbl.Value {
result = append(result, v.CloudProperties)
}

if t.DNS {
result = append(result, v.DNS)
}

if t.Vitals {
result = append(result, []boshtbl.Value{v.VMCreatedAt, v.Uptime, v.Load}...)
result = append(result, []boshtbl.Value{v.CPUTotal, v.CPUUser, v.CPUSys, v.CPUWait}...)
Expand Down
2 changes: 1 addition & 1 deletion cmd/instance_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var _ = Describe("InstanceTable", func() {

BeforeEach(func() {
info = boshdir.VMInfo{}
tbl = InstanceTable{Details: true, DNS: true, Vitals: true, CloudProperties: true}
tbl = InstanceTable{Details: true, Vitals: true, CloudProperties: true}
})

Describe("name, id", func() {
Expand Down
1 change: 0 additions & 1 deletion cmd/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func (c InstancesCmd) Run(opts InstancesOpts) error {
DeploymentDetails: true,
Processes: opts.Processes,
Details: opts.Details,
DNS: opts.DNS,
Vitals: opts.Vitals,
}

Expand Down
69 changes: 0 additions & 69 deletions cmd/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ var _ = Describe("InstancesCmd", func() {

IPs: []string{"in1-ip1", "in1-ip2"},
Deployment: "dep",
DNS: []string{"in1-dns1", "in1-dns2"},

State: "in1-state",
VMID: "in1-cid",
Expand Down Expand Up @@ -115,7 +114,6 @@ var _ = Describe("InstancesCmd", func() {

IPs: []string{"in2-ip1"},
Deployment: "dep",
DNS: []string{"in2-dns1"},

State: "in2-state",
VMID: "in2-cid",
Expand Down Expand Up @@ -547,73 +545,6 @@ var _ = Describe("InstancesCmd", func() {
}))
})

It("lists instances for the deployment including dns", func() {
opts.DNS = true

Expect(act()).ToNot(HaveOccurred())

Expect(ui.Table).To(Equal(boshtbl.Table{
Title: "Deployment 'dep'",
Content: "instances",

Header: []boshtbl.Header{
boshtbl.NewHeader("Instance"),
boshtbl.NewHeader("Process State"),
boshtbl.NewHeader("AZ"),
boshtbl.NewHeader("IPs"),
boshtbl.NewHeader("Deployment"),
boshtbl.NewHeader("DNS A Records"),
},

SortBy: []boshtbl.ColumnSort{
{Column: 0, Asc: true},
{Column: 1, Asc: true},
},

Sections: []boshtbl.Section{
{
FirstColumn: boshtbl.NewValueString("job-name"),
Rows: [][]boshtbl.Value{
{
boshtbl.NewValueString("job-name"),
boshtbl.NewValueFmt(boshtbl.NewValueString("in1-process-state"), true),
boshtbl.ValueString{},
boshtbl.NewValueStrings([]string{"in1-ip1", "in1-ip2"}),
boshtbl.NewValueString("dep"),
boshtbl.NewValueStrings([]string{"in1-dns1", "in1-dns2"}),
},
},
},
{
FirstColumn: boshtbl.NewValueString("job-name"),
Rows: [][]boshtbl.Value{
{
boshtbl.NewValueString("job-name"),
boshtbl.NewValueFmt(boshtbl.NewValueString("in2-process-state"), true),
boshtbl.NewValueString("in2-az"),
boshtbl.NewValueStrings([]string{"in2-ip1"}),
boshtbl.NewValueString("dep"),
boshtbl.NewValueStrings([]string{"in2-dns1"}),
},
},
},
{
FirstColumn: boshtbl.NewValueString("?"),
Rows: [][]boshtbl.Value{
{
boshtbl.NewValueString("?"),
boshtbl.NewValueFmt(boshtbl.NewValueString("unresponsive agent"), true),
boshtbl.ValueString{},
boshtbl.ValueStrings{},
boshtbl.NewValueString("dep"),
boshtbl.ValueStrings{},
},
},
},
},
}))
})

It("lists instances for the deployment including vitals and processes", func() {
opts.Vitals = true
opts.Processes = true
Expand Down
2 changes: 0 additions & 2 deletions cmd/opts/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,6 @@ type InstanceSlugArgs struct {

type InstancesOpts struct {
Details bool `long:"details" short:"i" description:"Show details including VM CID, persistent disk CID, etc."`
DNS bool `long:"dns" description:"Show DNS A records"`
Vitals bool `long:"vitals" description:"Show vitals"`
Processes bool `long:"ps" short:"p" description:"Show processes"`
Failing bool `long:"failing" short:"f" description:"Only show failing instances"`
Expand All @@ -810,7 +809,6 @@ type InstancesOpts struct {
}

type VMsOpts struct {
DNS bool `long:"dns" description:"Show DNS A records"`
Vitals bool `long:"vitals" description:"Show vitals"`
CloudProperties bool `long:"cloud-properties" description:"Show cloud properties"`
Deployment string
Expand Down
16 changes: 0 additions & 16 deletions cmd/opts/opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2366,14 +2366,6 @@ var _ = Describe("Opts", func() {
})
})

Describe("DNS", func() {
It("contains desired values", func() {
Expect(getStructTagForName("DNS", opts)).To(Equal(
`long:"dns" description:"Show DNS A records"`,
))
})
})

Describe("Vitals", func() {
It("contains desired values", func() {
Expect(getStructTagForName("Vitals", opts)).To(Equal(
Expand Down Expand Up @@ -2406,14 +2398,6 @@ var _ = Describe("Opts", func() {
opts = &VMsOpts{}
})

Describe("DNS", func() {
It("contains desired values", func() {
Expect(getStructTagForName("DNS", opts)).To(Equal(
`long:"dns" description:"Show DNS A records"`,
))
})
})

Describe("Vitals", func() {
It("contains desired values", func() {
Expect(getStructTagForName("Vitals", opts)).To(Equal(
Expand Down
1 change: 0 additions & 1 deletion cmd/vms.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func (c VMsCmd) Run(opts VMsOpts) error {
DeploymentDetails: false,
Details: false,
Stemcell: true,
DNS: opts.DNS,
Vitals: opts.Vitals,
CloudProperties: opts.CloudProperties,
}
Expand Down
67 changes: 1 addition & 66 deletions cmd/vms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package cmd_test

import (
"errors"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"time"

. "github.com/cloudfoundry/bosh-cli/v7/cmd"
. "github.com/cloudfoundry/bosh-cli/v7/cmd/opts"
boshdir "github.com/cloudfoundry/bosh-cli/v7/director"
Expand Down Expand Up @@ -61,7 +60,6 @@ var _ = Describe("VMsCmd", func() {

IPs: []string{"in1-ip1", "in1-ip2"},
Deployment: "dep",
DNS: []string{"in1-dns1", "in1-dns2"},

VMID: "in1-cid",
AgentID: "in1-agent-id",
Expand Down Expand Up @@ -96,7 +94,6 @@ var _ = Describe("VMsCmd", func() {

IPs: []string{"in2-ip1"},
Deployment: "dep",
DNS: []string{"in2-dns1"},

VMID: "in2-cid",
AgentID: "in2-agent-id",
Expand Down Expand Up @@ -200,68 +197,6 @@ var _ = Describe("VMsCmd", func() {
}))
})

It("lists VMs for the deployment including dns", func() {
opts.DNS = true

Expect(act()).ToNot(HaveOccurred())

Expect(ui.Table).To(Equal(boshtbl.Table{
Title: "Deployment 'dep1'",

Content: "vms",

Header: []boshtbl.Header{
boshtbl.NewHeader("Instance"),
boshtbl.NewHeader("Process State"),
boshtbl.NewHeader("AZ"),
boshtbl.NewHeader("IPs"),
boshtbl.NewHeader("VM CID"),
boshtbl.NewHeader("VM Type"),
boshtbl.NewHeader("Active"),
boshtbl.NewHeader("Stemcell"),
boshtbl.NewHeader("DNS A Records"),
},

SortBy: []boshtbl.ColumnSort{{Column: 0, Asc: true}},

Rows: [][]boshtbl.Value{
{
boshtbl.NewValueString("job-name"),
boshtbl.NewValueFmt(boshtbl.NewValueString("in1-process-state"), true),
boshtbl.ValueString{},
boshtbl.NewValueStrings([]string{"in1-ip1", "in1-ip2"}),
boshtbl.NewValueString("in1-cid"),
boshtbl.NewValueString("in1-rp"),
boshtbl.NewValueString("true"),
boshtbl.NewValueString("stemcell/version"),
boshtbl.NewValueStrings([]string{"in1-dns1", "in1-dns2"}),
},
{
boshtbl.NewValueString("job-name"),
boshtbl.NewValueFmt(boshtbl.NewValueString("in2-process-state"), true),
boshtbl.NewValueString("in2-az"),
boshtbl.NewValueStrings([]string{"in2-ip1"}),
boshtbl.NewValueString("in2-cid"),
boshtbl.NewValueString("in2-rp"),
boshtbl.NewValueString("false"),
boshtbl.NewValueString("stemcell/version"),
boshtbl.NewValueStrings([]string{"in2-dns1"}),
},
{
boshtbl.NewValueString("?"),
boshtbl.NewValueFmt(boshtbl.NewValueString("unresponsive agent"), true),
boshtbl.ValueString{},
boshtbl.ValueStrings{},
boshtbl.ValueString{},
boshtbl.ValueString{},
boshtbl.ValueString{S: "-"},
boshtbl.ValueString{S: "-"},
boshtbl.ValueStrings{},
},
},
}))
})

It("lists VMs for the deployment including vitals", func() {
opts.Vitals = true

Expand Down
4 changes: 1 addition & 3 deletions director/instances_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package director_test

import (
"net/http"
"strings"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"

"net/http"

. "github.com/cloudfoundry/bosh-cli/v7/director"
)

Expand Down Expand Up @@ -99,7 +98,6 @@ var _ = Describe("Instances", func() {

IPs: []string{"ip"},
Deployment: "dep",
DNS: []string{"dns"},

AZ: "az",
VMID: "vm-cid",
Expand Down
1 change: 0 additions & 1 deletion director/vms.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type VMInfo struct {

IPs []string `json:"ips"`
Deployment string `json:"deployment_name"`
DNS []string `json:"dns"`

AZ string `json:"az"`
State string `json:"state"`
Expand Down
Loading

0 comments on commit fb08fb4

Please sign in to comment.