Skip to content

Commit

Permalink
Add --recreate-persistent-disks bosh deploy flag
Browse files Browse the repository at this point in the history
[#158014878](https://www.pivotaltracker.com/story/show/158014878)

Signed-off-by: Joshua Aresty <joshua.aresty@emc.com>
  • Loading branch information
jrussett authored and Joshua Aresty committed Jul 18, 2018
1 parent be79615 commit 2432e5e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 26 deletions.
15 changes: 8 additions & 7 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ func (c DeployCmd) Run(opts DeployOpts) error {
}

updateOpts := boshdir.UpdateOpts{
Recreate: opts.Recreate,
Fix: opts.Fix,
SkipDrain: opts.SkipDrain,
DryRun: opts.DryRun,
Canaries: opts.Canaries,
MaxInFlight: opts.MaxInFlight,
Diff: deploymentDiff,
RecreatePersistentDisks: opts.RecreatePersistentDisks,
Recreate: opts.Recreate,
Fix: opts.Fix,
SkipDrain: opts.SkipDrain,
DryRun: opts.DryRun,
Canaries: opts.Canaries,
MaxInFlight: opts.MaxInFlight,
Diff: deploymentDiff,
}

return c.deployment.Update(bytes, updateOpts)
Expand Down
10 changes: 6 additions & 4 deletions cmd/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ var _ = Describe("DeployCmd", func() {
Expect(updateOpts).To(Equal(boshdir.UpdateOpts{}))
})

It("deploys manifest allowing to recreate, fix, and skip drain", func() {
It("deploys manifest allowing to recreate, recreate persistent disks, fix, and skip drain", func() {
opts.RecreatePersistentDisks = true
opts.Recreate = true
opts.Fix = true
opts.SkipDrain = boshdir.SkipDrains{boshdir.SkipDrain{All: true}}
Expand All @@ -75,9 +76,10 @@ var _ = Describe("DeployCmd", func() {
bytes, updateOpts := deployment.UpdateArgsForCall(0)
Expect(bytes).To(Equal([]byte("name: dep\n")))
Expect(updateOpts).To(Equal(boshdir.UpdateOpts{
Recreate: true,
Fix: true,
SkipDrain: boshdir.SkipDrains{boshdir.SkipDrain{All: true}},
RecreatePersistentDisks: true,
Recreate: true,
Fix: true,
SkipDrain: boshdir.SkipDrains{boshdir.SkipDrain{All: true}},
}))
})

Expand Down
7 changes: 4 additions & 3 deletions cmd/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,10 @@ type DeployOpts struct {

NoRedact bool `long:"no-redact" description:"Show non-redacted manifest diff"`

Recreate bool `long:"recreate" description:"Recreate all VMs in deployment"`
Fix bool `long:"fix" description:"Recreate unresponsive instances"`
SkipDrain []boshdir.SkipDrain `long:"skip-drain" value-name:"INSTANCE-GROUP" description:"Skip running drain scripts for specific instance groups" optional:"true" optional-value:"*"`
Recreate bool `long:"recreate" description:"Recreate all VMs in deployment"`
RecreatePersistentDisks bool `long:"recreate-persistent-disks" description:"Recreate all persistent disks in deployment"`
Fix bool `long:"fix" description:"Recreate unresponsive instances"`
SkipDrain []boshdir.SkipDrain `long:"skip-drain" value-name:"INSTANCE-GROUP" description:"Skip running drain scripts for specific instance groups" optional:"true" optional-value:"*"`

Canaries string `long:"canaries" description:"Override manifest values for canaries"`
MaxInFlight string `long:"max-in-flight" description:"Override manifest values for max_in_flight"`
Expand Down
8 changes: 8 additions & 0 deletions cmd/opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,14 @@ var _ = Describe("Opts", func() {
})
})

Describe("RecreatePersistentDisks", func() {
It("contains desired values", func() {
Expect(getStructTagForName("RecreatePersistentDisks", opts)).To(Equal(
`long:"recreate-persistent-disks" description:"Recreate all persistent disks in deployment"`,
))
})
})

Describe("NoRedact", func() {
It("contains desired values", func() {
Expect(getStructTagForName("NoRedact", opts)).To(Equal(
Expand Down
4 changes: 4 additions & 0 deletions director/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ func (c Client) UpdateDeployment(manifest []byte, opts UpdateOpts) error {
query.Add("recreate", "true")
}

if opts.RecreatePersistentDisks {
query.Add("recreate_persistent_disks", "true")
}

if opts.Fix {
query.Add("fix", "true")
}
Expand Down
11 changes: 6 additions & 5 deletions director/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,10 +676,10 @@ var _ = Describe("Deployment", func() {
Expect(err).ToNot(HaveOccurred())
})

It("succeeds updating deployment with recreate, fix and skip drain flags", func() {
It("succeeds updating deployment with recreate, recreate_persistent_disks, fix and skip drain flags", func() {
ConfigureTaskResult(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/deployments", "recreate=true&fix=true&skip_drain=*"),
ghttp.VerifyRequest("POST", "/deployments", "recreate=true&recreate_persistent_disks=true&fix=true&skip_drain=*"),
ghttp.VerifyBasicAuth("username", "password"),
ghttp.VerifyHeader(http.Header{
"Content-Type": []string{"text/yaml"},
Expand All @@ -691,9 +691,10 @@ var _ = Describe("Deployment", func() {
)

updateOpts := UpdateOpts{
Recreate: true,
Fix: true,
SkipDrain: SkipDrains{SkipDrain{All: true}},
RecreatePersistentDisks: true,
Recreate: true,
Fix: true,
SkipDrain: SkipDrains{SkipDrain{All: true}},
}
err := deployment.Update([]byte("manifest"), updateOpts)
Expect(err).ToNot(HaveOccurred())
Expand Down
15 changes: 8 additions & 7 deletions director/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,14 @@ type RecreateOpts struct {
}

type UpdateOpts struct {
Recreate bool
Fix bool
SkipDrain SkipDrains
Canaries string
MaxInFlight string
DryRun bool
Diff DeploymentDiff
Recreate bool
RecreatePersistentDisks bool
Fix bool
SkipDrain SkipDrains
Canaries string
MaxInFlight string
DryRun bool
Diff DeploymentDiff
}

//go:generate counterfeiter . ReleaseSeries
Expand Down

0 comments on commit 2432e5e

Please sign in to comment.