Skip to content

Commit

Permalink
merge: #9002 #9007
Browse files Browse the repository at this point in the history
9002: [Backport release-8.0.0] Mark DeployProcessCommand as deprecated for Go client r=npepinpe a=github-actions[bot]

# Description
Backport of #8997 to `release-8.0.0`.

relates to #8995

9007: [Backport release-8.0.0] Fix notification of snapshot replication listeners about missed events r=oleschoenburg a=oleschoenburg

## Description

Manual backport of #8994 for the `8.0`release branch

Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
Co-authored-by: Ole Schönburg <ole.schoenburg@gmail.com>
  • Loading branch information
3 people authored Mar 28, 2022
3 parents 0eb8ac2 + 4df946d + 14be7ea commit 6a7fc0c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,15 @@ public void addSnapshotReplicationListener(
snapshotReplicationListeners.add(snapshotReplicationListener);
// Notify listener immediately if it registered during an ongoing replication.
// This is to prevent missing necessary state transitions.
switch (missedSnapshotReplicationEvents) {
case STARTED -> snapshotReplicationListener.onSnapshotReplicationStarted();
case COMPLETED -> {
snapshotReplicationListener.onSnapshotReplicationStarted();
snapshotReplicationListener.onSnapshotReplicationCompleted(term);
if (role.role() == Role.FOLLOWER) {
switch (missedSnapshotReplicationEvents) {
case STARTED -> snapshotReplicationListener.onSnapshotReplicationStarted();
case COMPLETED -> {
snapshotReplicationListener.onSnapshotReplicationStarted();
snapshotReplicationListener.onSnapshotReplicationCompleted(term);
}
default -> {}
}
default -> {}
}
});
}
Expand Down Expand Up @@ -676,6 +678,7 @@ private void startTransition() {
}

private void completeTransition() {
missedSnapshotReplicationEvents = MissedSnapshotReplicationEvents.NONE;
ongoingTransition = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,18 @@ public void shouldNotCallListenerOnRegister() {
verify(snapshotReplicationListener, times(0))
.onSnapshotReplicationCompleted(follower.getTerm());
}

@Test
public void shouldNotCallListenerOnRegisterIfLeader() {
// given
final var snapshotReplicationListener = mock(SnapshotReplicationListener.class);
final var leader = raftRule.getLeader().orElseThrow();
// when
leader.getContext().notifySnapshotReplicationStarted();
leader.getContext().notifySnapshotReplicationCompleted();
leader.getContext().addSnapshotReplicationListener(snapshotReplicationListener);
// then
verify(snapshotReplicationListener, times(0)).onSnapshotReplicationStarted();
verify(snapshotReplicationListener, times(0)).onSnapshotReplicationCompleted(leader.getTerm());
}
}
1 change: 1 addition & 0 deletions clients/go/cmd/zbctl/internal/commands/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
var deployCmd = &cobra.Command{
Use: "deploy <processPath>...",
Short: "Deploys new resources for each file provided",
Long: "Deploys new resources for each file provided. The `deploy <processPath>...` usage is deprecated, to be removed in 8.1. Please use the `deploy resource` subcommand.",
Args: cobra.MinimumNArgs(1),
PreRunE: initClient,
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion clients/go/cmd/zbctl/internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var rootCmd = &cobra.Command{
Short: "zeebe command line interface",
Long: `zbctl is a command line interface designed to create and read resources inside zeebe broker.
It is designed for regular maintenance jobs such as:
* deploying processes,
* deploying resources,
* creating jobs and process instances
* activating, completing or failing jobs
* update variables and retries
Expand Down
2 changes: 1 addition & 1 deletion clients/go/cmd/zbctl/testdata/help.golden
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
zbctl is a command line interface designed to create and read resources inside zeebe broker.
It is designed for regular maintenance jobs such as:
* deploying processes,
* deploying resources,
* creating jobs and process instances
* activating, completing or failing jobs
* update variables and retries
Expand Down
1 change: 1 addition & 0 deletions clients/go/pkg/commands/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (cmd *DeployCommand) Send(ctx context.Context) (*pb.DeployProcessResponse,
return response, err
}

// Deprecated: Use NewDeployResourceCommand instead. To be removed in 8.1.0.
func NewDeployCommand(gateway pb.GatewayClient, pred retryPredicate) *DeployCommand {
return &DeployCommand{
Command: Command{
Expand Down
1 change: 1 addition & 0 deletions clients/go/pkg/zbc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

type Client interface {
NewTopologyCommand() *commands.TopologyCommand
// Deprecated: Use NewDeployResourceCommand instead. To be removed in 8.1.0.
NewDeployProcessCommand() *commands.DeployCommand
NewDeployResourceCommand() *commands.DeployResourceCommand

Expand Down
2 changes: 1 addition & 1 deletion clients/go/pkg/zbc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (c *ClientImpl) NewTopologyCommand() *commands.TopologyCommand {
}

func (c *ClientImpl) NewDeployProcessCommand() *commands.DeployCommand {
return commands.NewDeployCommand(c.gateway, c.credentialsProvider.ShouldRetryRequest)
return commands.NewDeployCommand(c.gateway, c.credentialsProvider.ShouldRetryRequest) // nolint
}

func (c *ClientImpl) NewDeployResourceCommand() *commands.DeployResourceCommand {
Expand Down

0 comments on commit 6a7fc0c

Please # to comment.