Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
115424: roachtest: WipeForReuse clears DNS entries r=srosenberg,DaryllWong,renatolabs a=herkolategan

Previously, after wiping a cluster, the DNS entries for the services created, during a test, would remain tied to the cluster causing the next test to re-use the entries instead of having the chance to specify its own ports or services.

This PR ensures the DNS entries are wiped if the cluster is intended for reuse.

In addition the `destroy-dns` command is exposed on the `roachprod` CLI if a user wants to manually clear DNS entries for any cluster.

Epic: None
Release Note: None

Co-authored-by: Herko Lategan <herko@cockroachlabs.com>
  • Loading branch information
craig[bot] and herkolategan committed Dec 6, 2023
2 parents 6032f68 + e9a2fcb commit 7a85aa8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/cmd/roachprod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,15 @@ var jaegerURLCmd = &cobra.Command{
}),
}

var destroyDNSCmd = &cobra.Command{
Use: `destroy-dns <cluster>`,
Short: `cleans up DNS entries for the cluster`,
Args: cobra.ExactArgs(1),
Run: wrap(func(cmd *cobra.Command, args []string) error {
return roachprod.DestroyDNS(context.Background(), config.Logger, args[0])
}),
}

var snapshotCmd = &cobra.Command{
Use: `snapshot`,
Short: "snapshot enables creating/listing/deleting/applying cluster snapshots",
Expand Down Expand Up @@ -1453,6 +1462,7 @@ func main() {
runCmd,
signalCmd,
wipeCmd,
destroyDNSCmd,
reformatCmd,
installCmd,
distributeCertsCmd,
Expand Down
9 changes: 9 additions & 0 deletions pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2687,13 +2687,22 @@ func (c *clusterImpl) WipeForReuse(
}
c.localCertsDir = ""
}
// Clear DNS records for the cluster.
if err := c.DestroyDNS(ctx, l); err != nil {
return err
}
// Overwrite the spec of the cluster with the one coming from the test. In
// particular, this overwrites the reuse policy to reflect what the test
// intends to do with it.
c.spec = newClusterSpec
return nil
}

// DestroyDNS destroys the DNS records for the cluster.
func (c *clusterImpl) DestroyDNS(ctx context.Context, l *logger.Logger) error {
return roachprod.DestroyDNS(ctx, l, c.name)
}

// MaybeExtendCluster checks if the cluster has enough life left for the
// test plus enough headroom after the test finishes so that the next test
// can be selected. If it doesn't, extend it.
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/roachtest/cluster/cluster_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ type Cluster interface {
WipeE(ctx context.Context, l *logger.Logger, preserveCerts bool, opts ...option.Option) error
Wipe(ctx context.Context, preserveCerts bool, opts ...option.Option)

// DNS

DestroyDNS(ctx context.Context, l *logger.Logger) error

// Internal niche tools.

Reformat(ctx context.Context, l *logger.Logger, node option.NodeListOption, filesystem string) error
Expand Down
14 changes: 14 additions & 0 deletions pkg/roachprod/roachprod.go
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,20 @@ func JaegerURL(
return urls[0], nil
}

// DestroyDNS destroys the DNS records for the given cluster.
func DestroyDNS(ctx context.Context, l *logger.Logger, clusterName string) error {
if err := LoadClusters(); err != nil {
return err
}
c, err := newCluster(l, clusterName)
if err != nil {
return err
}
return vm.FanOutDNS(c.VMs, func(p vm.DNSProvider, vms vm.List) error {
return p.DeleteRecordsBySubdomain(ctx, c.Name)
})
}

// StorageCollectionPerformAction either starts or stops workload collection on
// a target cluster.
//
Expand Down

0 comments on commit 7a85aa8

Please sign in to comment.