Skip to content

Commit 655c27e

Browse files
Alphasiteselzoc
andcommitted
Working test
Co-authored-by: Chris Selzo <chris.selzo@broadcom.com>
1 parent 53c1c4a commit 655c27e

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

cmd/deploy.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package cmd
22

33
import (
4+
"fmt"
5+
"time"
6+
47
bosherr "github.com/cloudfoundry/bosh-utils/errors"
58
"gopkg.in/yaml.v3"
69

@@ -101,9 +104,18 @@ func (c DeployCmd) Run(opts DeployOpts) error {
101104
return err
102105
}
103106

107+
var recreateOlderThan time.Time
108+
if len(opts.RecreateOlderThan) > 0 {
109+
recreateOlderThan, err = time.Parse(time.RFC3339, opts.RecreateOlderThan)
110+
if err != nil {
111+
return fmt.Errorf("could not parse recreate timestamp: %v", err)
112+
}
113+
}
114+
104115
updateOpts := boshdir.UpdateOpts{
105116
RecreatePersistentDisks: opts.RecreatePersistentDisks,
106117
Recreate: opts.Recreate,
118+
RecreateOlderThan: recreateOlderThan,
107119
Fix: opts.Fix,
108120
SkipDrain: opts.SkipDrain,
109121
DryRun: opts.DryRun,

cmd/opts/opts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ type DeployOpts struct {
504504
NoRedact bool `long:"no-redact" description:"Show non-redacted manifest diff"`
505505

506506
Recreate bool `long:"recreate" description:"Recreate all VMs in deployment"`
507+
RecreateOlderThan string `long:"recreate-older-than" description:"Recreate all VMs in deployment older than the specified time"`
507508
RecreatePersistentDisks bool `long:"recreate-persistent-disks" description:"Recreate all persistent disks in deployment"`
508509
Fix bool `long:"fix" description:"Recreate an instance with an unresponsive agent instead of erroring"`
509510
FixReleases bool `long:"fix-releases" description:"Reupload releases in manifest and replace corrupt or missing jobs/packages"`

director/deployment.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http"
77
"net/url"
88
"strings"
9+
"time"
910

1011
bosherr "github.com/cloudfoundry/bosh-utils/errors"
1112
)
@@ -521,6 +522,10 @@ func (c Client) UpdateDeployment(manifest []byte, opts UpdateOpts) error {
521522
query.Add("recreate", "true")
522523
}
523524

525+
if !opts.RecreateOlderThan.IsZero() {
526+
query.Add("recreate_older_than", opts.RecreateOlderThan.Format(time.RFC3339))
527+
}
528+
524529
if opts.RecreatePersistentDisks {
525530
query.Add("recreate_persistent_disks", "true")
526531
}

director/interfaces.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ type RecreateOpts struct {
219219

220220
type UpdateOpts struct {
221221
Recreate bool
222+
RecreateOlderThan time.Time
222223
RecreatePersistentDisks bool
223224
Fix bool
224225
SkipDrain SkipDrains

0 commit comments

Comments
 (0)