Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
132753: roachprod: support deploying local binaries r=srosenberg a=DarrylWong

Users can now use roachprod deploy to deploy a
locally built cockroach binary.

Release note: none
Epic: none
Fixes: none

132844: schemachanger: cleanup unused indexID r=rafiss a=annrpom

We don't use the indexID in `scop.AddIndexZoneConfig`; we can remove it.

Epic: None

Release note: None

Co-authored-by: DarrylWong <darryl@cockroachlabs.com>
Co-authored-by: Annie Pompa <annie@cockroachlabs.com>
  • Loading branch information
3 people committed Oct 17, 2024
3 parents 9a5c5a6 + 22c20c2 + e196b68 commit 8ef2e0f
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
│ ├── 1 element transitioning toward PUBLIC
│ │ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 1}
│ └── 1 Mutation operation
│ └── AddIndexZoneConfig {"IndexID":2,"TableID":104}
│ └── AddIndexZoneConfig {"TableID":104}
└── PreCommitPhase
├── Stage 1 of 2 in PreCommitPhase
│ ├── 1 element transitioning toward PUBLIC
Expand All @@ -22,4 +22,4 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
├── 1 element transitioning toward PUBLIC
│ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 1}
└── 1 Mutation operation
└── AddIndexZoneConfig {"IndexID":2,"TableID":104}
└── AddIndexZoneConfig {"TableID":104}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
│ ├── 1 element transitioning toward PUBLIC
│ │ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 1}
│ └── 1 Mutation operation
│ └── AddIndexZoneConfig {"IndexID":2,"TableID":104}
│ └── AddIndexZoneConfig {"TableID":104}
└── PreCommitPhase
├── Stage 1 of 2 in PreCommitPhase
│ ├── 1 element transitioning toward PUBLIC
Expand All @@ -22,4 +22,4 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
├── 1 element transitioning toward PUBLIC
│ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 1}
└── 1 Mutation operation
└── AddIndexZoneConfig {"IndexID":2,"TableID":104}
└── AddIndexZoneConfig {"TableID":104}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
│ ├── 1 element transitioning toward PUBLIC
│ │ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 2}
│ └── 1 Mutation operation
│ └── AddIndexZoneConfig {"IndexID":2,"TableID":104}
│ └── AddIndexZoneConfig {"TableID":104}
└── PreCommitPhase
├── Stage 1 of 2 in PreCommitPhase
│ ├── 2 elements transitioning toward PUBLIC
Expand All @@ -25,5 +25,5 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
│ ├── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 1}
│ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 2}
└── 2 Mutation operations
├── AddIndexZoneConfig {"IndexID":2,"TableID":104}
└── AddIndexZoneConfig {"IndexID":2,"TableID":104}
├── AddIndexZoneConfig {"TableID":104}
└── AddIndexZoneConfig {"TableID":104}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
│ ├── 1 element transitioning toward PUBLIC
│ │ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 3}
│ └── 1 Mutation operation
│ └── AddIndexZoneConfig {"IndexID":2,"TableID":104}
│ └── AddIndexZoneConfig {"TableID":104}
└── PreCommitPhase
├── Stage 1 of 2 in PreCommitPhase
│ ├── 3 elements transitioning toward PUBLIC
Expand All @@ -28,6 +28,6 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
│ ├── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 2}
│ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 3}
└── 3 Mutation operations
├── AddIndexZoneConfig {"IndexID":2,"TableID":104}
├── AddIndexZoneConfig {"IndexID":2,"TableID":104}
└── AddIndexZoneConfig {"IndexID":2,"TableID":104}
├── AddIndexZoneConfig {"TableID":104}
├── AddIndexZoneConfig {"TableID":104}
└── AddIndexZoneConfig {"TableID":104}
16 changes: 12 additions & 4 deletions pkg/cmd/roachprod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,12 +778,14 @@ const (
customizedApp = `
customized - Cockroach customized builds, usually generated by running
./scripts/tag-custom-build.sh. Must provide a specific tag.`
localApp = `
local - Use a provided local binary, must provide the path to the binary.`
workloadApp = `
workload - Cockroach workload application.`
)

var deployCmd = &cobra.Command{
Use: "deploy <cluster> <application> <version>",
Use: "deploy <cluster> <application> <version>|<pathToBinary>",
Short: "deploy a new version of cockroach",
Long: fmt.Sprintf(`Performs a rolling upgrade of cockroach.
Expand All @@ -794,15 +796,21 @@ stage it on the cluster. It will then perform a rolling upgrade of the cluster,
one node at a time, to the new version.
Currently available application options are:
%s`, strings.TrimSpace(cockroachApp+releaseApp+customizedApp)),
%s`, strings.TrimSpace(cockroachApp+releaseApp+customizedApp+localApp)),
Args: cobra.RangeArgs(2, 3),
Run: wrap(func(cmd *cobra.Command, args []string) error {
versionArg := ""
if len(args) == 3 {
pathToBinary := ""
if args[1] == "local" {
if len(args) < 3 {
return errors.New("local application requires a path to the binary: deploy <cluster> local <pathToBinary>")
}
pathToBinary = args[2]
} else if len(args) == 3 {
versionArg = args[2]
}
return roachprod.Deploy(context.Background(), config.Logger, args[0], args[1],
versionArg, pause, deploySig, deployWaitFlag, deployGracePeriod, secure)
versionArg, pathToBinary, pause, deploySig, deployWaitFlag, deployGracePeriod, secure)
}),
}

Expand Down
15 changes: 12 additions & 3 deletions pkg/roachprod/roachprod.go
Original file line number Diff line number Diff line change
Expand Up @@ -2802,7 +2802,7 @@ func LoadBalancerIP(
func Deploy(
ctx context.Context,
l *logger.Logger,
clusterName, applicationName, version string,
clusterName, applicationName, version, pathToBinary string,
pauseDuration time.Duration,
sig int,
wait bool,
Expand All @@ -2811,7 +2811,7 @@ func Deploy(
) error {
// Stage supports `workload` as well, so it needs to be excluded here. This
// list contains a subset that only pulls the cockroach binary.
supportedApplicationNames := []string{"cockroach", "release", "customized"}
supportedApplicationNames := []string{"cockroach", "release", "customized", "local"}
if !slices.Contains(supportedApplicationNames, applicationName) {
return errors.Errorf("unsupported application name %s, supported names are %v", applicationName, supportedApplicationNames)
}
Expand All @@ -2826,7 +2826,16 @@ func Deploy(
if err != nil {
return err
}
err = Stage(ctx, l, clusterName, "", "", stageDir, applicationName, version)

if applicationName == "local" {
if pathToBinary == "" {
return errors.Errorf("%s application requires a path to the binary", applicationName)
}
err = c.Put(ctx, l, c.TargetNodes(), pathToBinary, filepath.Join(stageDir, "cockroach"))
} else {
err = Stage(ctx, l, clusterName, "", "", stageDir, applicationName, version)
}

if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion pkg/sql/schemachanger/scop/immediate_mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,6 @@ type AddTableZoneConfig struct {
type AddIndexZoneConfig struct {
immediateMutationOp
TableID descpb.ID
IndexID descpb.IndexID
Subzone zonepb.Subzone
SubzoneSpans []zonepb.SubzoneSpan
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func init() {

return &scop.AddIndexZoneConfig{
TableID: this.TableID,
IndexID: this.IndexID,
Subzone: this.Subzone,
SubzoneSpans: this.SubzoneSpans,
}
Expand Down

0 comments on commit 8ef2e0f

Please sign in to comment.