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

feat: add state storage implementation: local, oss, s3, mysql #902

Merged
merged 1 commit into from Mar 12, 2024

Conversation

healthjyk
Copy link
Contributor

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?


Additional documentation e.g., design docs, usage docs, etc.:


@coveralls
Copy link

coveralls commented Mar 11, 2024

Pull Request Test Coverage Report for Build 8242994385

Details

  • 101 of 212 (47.64%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.5%) to 73.386%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/engine/operation/models/operation_context.go 0 1 0.0%
pkg/engine/state/storages/local.go 15 24 62.5%
pkg/engine/state/storages/util.go 0 9 0.0%
pkg/engine/state/storages/s3.go 30 52 57.69%
pkg/engine/state/storages/oss.go 22 45 48.89%
pkg/engine/state/storages/mysql.go 34 81 41.98%
Totals Coverage Status
Change from base Build 8232147897: -0.5%
Covered Lines: 7649
Relevant Lines: 10423

💛 - Coveralls

@healthjyk
Copy link
Contributor Author

healthjyk commented Mar 12, 2024

Unify the behaviors across multiple state storages. Compared to the old state storage, there are bug fixes and functional escalation:

  • Delete otiose function Delete() of interface StateStorage;
  • unify the behavior of function Apply(), only store the state to backend. While the old local storage updates modifiedTime, while others not.
  • Unify the storage requirements for all state storage, which asks for no repetitive project name. While for old state storages, only the default local storage allows repetitive project name (state file under stack directory), while others not, even the local storage with specified path does not support. To support projects with the same name, there will be another issue to track it.
  • Refactor the default local state storage to ~/.kusion/states/{projectName}/{stackName}/{workspaceName}/state. yaml
  • Upgrade mysql table to (project, stack, workspace, content), where the content is the yaml.Marshal of state. This table structure is to fit in the changeable the state structure, take ref of Terraform. While for old mysql storage, do not update id field, which is not correct, cause not all mysql db has auto-increasing id.
  • Unify the behavior of oss and s3 when state file not exist, return nil with no error, keep the same with others. While the old oss/s3 storage return error. And delete useless list operation.
  • Do not support http state storage for now.
  • StateStorage works for a specified project-stack-workspace, not for multiple.
  • Update the State model, delete field "Tenant", replace "Cluster" with "Workspace", ref: feat: remove state model to pkg apis/core/v1 and stateStorage interface to pkg state #897
    @adohe @liu-hm19 @SparkYuan

Copy link
Contributor

@liu-hm19 liu-hm19 left a comment

Choose a reason for hiding this comment

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

lgtm

@healthjyk healthjyk merged commit 5639792 into KusionStack:main Mar 12, 2024
6 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants