Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not truncate local state file when pulling remote changes #382

Merged
merged 3 commits into from
May 16, 2023

Conversation

andrewnester
Copy link
Contributor

@andrewnester andrewnester commented May 15, 2023

Changes

When local state file exists it won't be override by remote state file

Tests

Running bricks bundle deploy after state push failed does not override local state file

Use cases verified:

  1. Local state file is newer than remote
  2. Local state file is older than remote
  3. Local state file does not exist
  4. Local state file corrupted

@andrewnester andrewnester requested a review from pietern May 15, 2023 11:40
Copy link
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is OK to overwrite if the sequence number encoded in the state file is higher in the remote version than it is in the local version. To make this work both state files need to be parsed so that the sequence number can be extracted and compared.

@andrewnester andrewnester requested a review from pietern May 15, 2023 14:35
Copy link
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor issues. Thanks for working on this!

bundle/deploy/terraform/state_pull.go Show resolved Hide resolved
bundle/deploy/terraform/util_test.go Show resolved Hide resolved
@andrewnester andrewnester requested a review from pietern May 16, 2023 08:22
content := []byte(r.content)
n = copy(p, content)
return n, io.EOF
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implemented by https://pkg.go.dev/strings#NewReader, FWIW. Feel free to address async.

@andrewnester andrewnester merged commit 33fb0b3 into main May 16, 2023
4 checks passed
@andrewnester andrewnester deleted the remote-local-state branch May 16, 2023 15:02
@pietern pietern mentioned this pull request May 16, 2023
pietern added a commit that referenced this pull request May 16, 2023
## Changes

This release bumps the minor version to 100 to disambiguate between
Databricks CLI "v1" (the Python version)
and this version, Databricks CLI "v2". This release is a major rewrite
of the CLI, and is not backwards compatible.

CLI:
* Rename bricks -> databricks
([#389](#389)).

Bundles:
* Added ability for deferred mutator execution
([#380](#380)).
* Do not truncate local state file when pulling remote changes
([#382](#382)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants