Skip to content

Commit

Permalink
add retry logic 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef Karasek committed Mar 15, 2023
1 parent 908e9a0 commit ca20cb3
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions pkg/config/manager_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,30 +100,35 @@ func (m *RemotePersistenceManager) PersistSourceBindings(ctx context.Context, co
if err != nil {
return ErrUnsupportedPlatform
}
var mutation struct {
Success bool `graphql:"patchDeploymentConfig(id: $id, input: $input)"`
}
variables := map[string]interface{}{
"id": graphql.ID(m.gql.DeploymentID()),
"input": remoteapi.PatchDeploymentConfigInput{
ResourceVersion: m.getResourceVersion(),
SourceBinding: &remoteapi.SourceBindingPatchDeploymentConfigInput{
CommunicationGroupName: commGroupName,
Platform: p,
ChannelAlias: channelAlias,
SourceBindings: sourceBindings,
err = m.withRetry(ctx, logger, func() error {
var mutation struct {
Success bool `graphql:"patchDeploymentConfig(id: $id, input: $input)"`
}
variables := map[string]interface{}{
"id": graphql.ID(m.gql.DeploymentID()),
"input": remoteapi.PatchDeploymentConfigInput{
ResourceVersion: m.getResourceVersion(),
SourceBinding: &remoteapi.SourceBindingPatchDeploymentConfigInput{
CommunicationGroupName: commGroupName,
Platform: p,
ChannelAlias: channelAlias,
SourceBindings: sourceBindings,
},
},
},
}
}

if err = m.gql.Client().Mutate(ctx, &mutation, variables); err != nil {
return err
}
if err = m.gql.Client().Mutate(ctx, &mutation, variables); err != nil {
return err
}

if !mutation.Success {
return fmt.Errorf("failed to persist source bindings config sources=[%s] for channel %s", strings.Join(sourceBindings, ", "), channelAlias)
if !mutation.Success {
return fmt.Errorf("failed to persist source bindings config sources=[%s] for channel %s", strings.Join(sourceBindings, ", "), channelAlias)
}
return nil
})
if err != nil {
return errors.Wrap(err, "while persisting source bindings config")
}

return nil
}

Expand Down

0 comments on commit ca20cb3

Please sign in to comment.