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

OADP-4640: Downstream only to allow override kopia default algorithms #334

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

mpryc
Copy link

@mpryc mpryc commented Aug 2, 2024

Introduction of downstream only option to override Kopia default:

  • hashing algorithm
  • splitting algorithm
  • encryption algorithm

With introduction of 3 environment variables it is possible to override Kopia algorithms used by Velero:

KOPIA_HASHING_ALGORITHM
KOPIA_SPLITTER_ALGORITHM
KOPIA_ENCRYPTION_ALGORITHM

If the env algorithms are not set or they are not within Kopia SupportedAlgorithms, the default algorithm will be used. This behavior is consistent with current behavior without this change.

Does your change fix a particular issue?

Fixes #OADP-4640

The change introduces new test file to easy rebases. Also the changes to the original file are minimal and split into one function to reduce risk of further rebase headaches.

Testing

$ pkg/repository/udmrepo/kopialib/backend/
$ go test -v .

@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 2, 2024

@mpryc: This pull request references OADP-4640 which is a valid jira issue.

In response to this:

Introduction of downstream only option to override Kopia default:

  • hashing algorithm
  • splitting algorithm
  • encryption algorithm

With introduction of 3 environment variables it is possible to override Kopia algorithms used by Velero:

KOPIA_HASHING_ALGORITHM
KOPIA_SPLITTER_ALGORITHM
KOPIA_ENCRYPTION_ALGORITHM

If the env algorithms are not set or they are not within Kopia SupportedAlgorithms, the default algorithm will be used. This behavior is consistent with current behavior without this change.

Does your change fix a particular issue?

Fixes #OADP-4640

The change introduces new test file to easy rebases. Also the changes to the original file are minimal and split into one function to reduce risk of further rebase headaches.

Testing

$ pkg/repository/udmrepo/kopialib/backend/
$ go test -v .

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 2, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 2, 2024

@mpryc: This pull request references OADP-4640 which is a valid jira issue.

In response to this:

Introduction of downstream only option to override Kopia default:

  • hashing algorithm
  • splitting algorithm
  • encryption algorithm

With introduction of 3 environment variables it is possible to override Kopia algorithms used by Velero:

KOPIA_HASHING_ALGORITHM
KOPIA_SPLITTER_ALGORITHM
KOPIA_ENCRYPTION_ALGORITHM

If the env algorithms are not set or they are not within Kopia SupportedAlgorithms, the default algorithm will be used. This behavior is consistent with current behavior without this change.

Does your change fix a particular issue?

Fixes #OADP-4640

The change introduces new test file to easy rebases. Also the changes to the original file are minimal and split into one function to reduce risk of further rebase headaches.

Testing

$ pkg/repository/udmrepo/kopialib/backend/
$ go test -v .

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

},
},
{
name: "with hash algo in flags, env var ignored",

Choose a reason for hiding this comment

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

this test is not doing what is expected, no?

value from env var appears in expected

Copy link
Author

Choose a reason for hiding this comment

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

Yes but I wanted to test that udmrepo does not change the algorhtm note the SHA3-256 is different then SHA3-224 so different ones are set with env and different with udmrepo.

Copy link
Author

Choose a reason for hiding this comment

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

I didn't change this code as I think it's correct.

Choose a reason for hiding this comment

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

the test name makes no sense, the environment variable is not being ignored

Copy link
Author

Choose a reason for hiding this comment

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

Updated

Introduction of downstream only option to override Kopia default:
 - hashing algorithm
 - splitting algorithm
 - encryption algorithm

With introduction of 3 environment variables it is possible to override
Kopia algorithms used by Velero:

KOPIA_HASHING_ALGORITHM
KOPIA_SPLITTER_ALGORITHM
KOPIA_ENCRYPTION_ALGORITHM

If the env algorithms are not set or they are not within
Kopia SupportedAlgorithms, the default algorithm will be used.
This behavior is consistent with current behavior without this
change.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
@mpryc mpryc force-pushed the issue-oadp-4640 branch from 8480ac4 to 2fd82cf Compare August 9, 2024 20:09
Copy link

openshift-ci bot commented Aug 9, 2024

@mpryc: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@weshayutin
Copy link

From https://github.com/openshift/velero
 * [new ref]             refs/pull/334/head -> issue-oadp-4640
Switched to branch 'issue-oadp-4640'
whayutin@thinkdoe:~/OPENSHIFT/git/OADP/velero$ cd pkg/repository/udmrepo/kopialib/backend/
whayutin@thinkdoe:~/OPENSHIFT/git/OADP/velero/pkg/repository/udmrepo/kopialib/backend$ ls
azure          backend.go                       common_test.go       gcs.go       s3.go       utils_test.go
azure.go       common.go                        file_system.go       gcs_test.go  s3_test.go
azure_test.go  common_kopia_algorithms_test.go  file_system_test.go  mocks        utils.go
whayutin@thinkdoe:~/OPENSHIFT/git/OADP/velero/pkg/repository/udmrepo/kopialib/backend$ go test -v .
=== RUN   TestAzureSetup
--- PASS: TestAzureSetup (0.00s)
=== RUN   TestSetupNewRepoAlgorithms
=== RUN   TestSetupNewRepoAlgorithms/with_valid_non-default_hash_algo_from_env
=== RUN   TestSetupNewRepoAlgorithms/with_valid_non-default_encryption_algo_from_env
=== RUN   TestSetupNewRepoAlgorithms/with_valid_non-default_splitter_algo_from_env
=== RUN   TestSetupNewRepoAlgorithms/with_valid_non-default_splitter_and_hashing_algo_from_env,_invalid_encryption_from_env
=== RUN   TestSetupNewRepoAlgorithms/with_unsupported_hash_algo_in_env,_fallback_to_default
=== RUN   TestSetupNewRepoAlgorithms/hash_in_StoreOptionGenHashAlgo_and_env,_env_wins
--- PASS: TestSetupNewRepoAlgorithms (0.00s)
    --- PASS: TestSetupNewRepoAlgorithms/with_valid_non-default_hash_algo_from_env (0.00s)
    --- PASS: TestSetupNewRepoAlgorithms/with_valid_non-default_encryption_algo_from_env (0.00s)
    --- PASS: TestSetupNewRepoAlgorithms/with_valid_non-default_splitter_algo_from_env (0.00s)
    --- PASS: TestSetupNewRepoAlgorithms/with_valid_non-default_splitter_and_hashing_algo_from_env,_invalid_encryption_from_env (0.00s)
    --- PASS: TestSetupNewRepoAlgorithms/with_unsupported_hash_algo_in_env,_fallback_to_default (0.00s)
    --- PASS: TestSetupNewRepoAlgorithms/hash_in_StoreOptionGenHashAlgo_and_env,_env_wins (0.00s)
=== RUN   TestSetupNewRepositoryOptions
=== RUN   TestSetupNewRepositoryOptions/with_hash_algo
=== RUN   TestSetupNewRepositoryOptions/with_encrypt_algo
=== RUN   TestSetupNewRepositoryOptions/with_splitter_algo
=== RUN   TestSetupNewRepositoryOptions/with_retention_algo
--- PASS: TestSetupNewRepositoryOptions (0.00s)
    --- PASS: TestSetupNewRepositoryOptions/with_hash_algo (0.00s)
    --- PASS: TestSetupNewRepositoryOptions/with_encrypt_algo (0.00s)
    --- PASS: TestSetupNewRepositoryOptions/with_splitter_algo (0.00s)
    --- PASS: TestSetupNewRepositoryOptions/with_retention_algo (0.00s)
=== RUN   TestSetupConnectOptions
=== RUN   TestSetupConnectOptions/with_domain
=== RUN   TestSetupConnectOptions/with_username
=== RUN   TestSetupConnectOptions/with_wrong_readonly
=== RUN   TestSetupConnectOptions/with_correct_readonly
=== RUN   TestSetupConnectOptions/with_description
--- PASS: TestSetupConnectOptions (0.00s)
    --- PASS: TestSetupConnectOptions/with_domain (0.00s)
    --- PASS: TestSetupConnectOptions/with_username (0.00s)
    --- PASS: TestSetupConnectOptions/with_wrong_readonly (0.00s)
    --- PASS: TestSetupConnectOptions/with_correct_readonly (0.00s)
    --- PASS: TestSetupConnectOptions/with_description (0.00s)
=== RUN   TestFSSetup
=== RUN   TestFSSetup/must_have_fs_path
=== RUN   TestFSSetup/with_fs_path_only
=== RUN   TestFSSetup/with_prefix
--- PASS: TestFSSetup (0.00s)
    --- PASS: TestFSSetup/must_have_fs_path (0.00s)
    --- PASS: TestFSSetup/with_fs_path_only (0.00s)
    --- PASS: TestFSSetup/with_prefix (0.00s)
=== RUN   TestGcsSetup
=== RUN   TestGcsSetup/must_have_bucket_name
=== RUN   TestGcsSetup/must_have_credential_file
=== RUN   TestGcsSetup/with_prefix
=== RUN   TestGcsSetup/with_wrong_readonly
=== RUN   TestGcsSetup/with_correct_readonly
--- PASS: TestGcsSetup (0.00s)
    --- PASS: TestGcsSetup/must_have_bucket_name (0.00s)
    --- PASS: TestGcsSetup/must_have_credential_file (0.00s)
    --- PASS: TestGcsSetup/with_prefix (0.00s)
    --- PASS: TestGcsSetup/with_wrong_readonly (0.00s)
    --- PASS: TestGcsSetup/with_correct_readonly (0.00s)
=== RUN   TestS3Setup
=== RUN   TestS3Setup/must_have_bucket_name
=== RUN   TestS3Setup/with_bucket_only
=== RUN   TestS3Setup/with_others
=== RUN   TestS3Setup/with_wrong_tls
=== RUN   TestS3Setup/with_correct_tls
=== RUN   TestS3Setup/with_wrong_ca
=== RUN   TestS3Setup/with_correct_ca
--- PASS: TestS3Setup (0.00s)
    --- PASS: TestS3Setup/must_have_bucket_name (0.00s)
    --- PASS: TestS3Setup/with_bucket_only (0.00s)
    --- PASS: TestS3Setup/with_others (0.00s)
    --- PASS: TestS3Setup/with_wrong_tls (0.00s)
    --- PASS: TestS3Setup/with_correct_tls (0.00s)
    --- PASS: TestS3Setup/with_wrong_ca (0.00s)
    --- PASS: TestS3Setup/with_correct_ca (0.00s)
=== RUN   TestOptionalHaveBool
=== RUN   TestOptionalHaveBool/key_not_exist
=== RUN   TestOptionalHaveBool/value_valid
=== RUN   TestOptionalHaveBool/value_invalid
--- PASS: TestOptionalHaveBool (0.00s)
    --- PASS: TestOptionalHaveBool/key_not_exist (0.00s)
    --- PASS: TestOptionalHaveBool/value_valid (0.00s)
    --- PASS: TestOptionalHaveBool/value_invalid (0.00s)
PASS
ok  	github.com/vmware-tanzu/velero/pkg/repository/udmrepo/kopialib/backend	0.008s

Copy link

@weshayutin weshayutin left a comment

Choose a reason for hiding this comment

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

/LGTM

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 9, 2024
},
},
},
{
Copy link
Member

@shubham-pampattiwar shubham-pampattiwar Aug 13, 2024

Choose a reason for hiding this comment

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

@mpryc IMO we should add another testcase when StoreOptionGenHashAlgos has a valid algo value but the env var has an invalid algo value. Then in such a scenario default would not be used but the one present in StoreOptionGenHashAlgos would be used, right ?

Copy link

Choose a reason for hiding this comment

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

@shubham-pampattiwar right. there are 2 levels of fallback here:

  1. use env var if it's set and value is supported, if not, fall back to...
  2. value in StoreOptionGenHashAlgo, if not fall back to...
  3. default

@shubham-pampattiwar
Copy link
Member

/approved

@shubham-pampattiwar shubham-pampattiwar added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 13, 2024
Copy link

openshift-ci bot commented Aug 13, 2024

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: mpryc, shubham-pampattiwar, sseago, weshayutin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 48b7ec0 into openshift:oadp-1.4 Aug 13, 2024
3 checks passed
mpryc added a commit to mpryc/velero that referenced this pull request Aug 16, 2024
…openshift#334)

           add missing unit test for kopia hashing algo (openshift#337)

Introduction of downstream only option to override Kopia default:
 - hashing algorithm
 - splitting algorithm
 - encryption algorithm

With introduction of 3 environment variables it is possible to override
Kopia algorithms used by Velero:

KOPIA_HASHING_ALGORITHM
KOPIA_SPLITTER_ALGORITHM
KOPIA_ENCRYPTION_ALGORITHM

If the env algorithms are not set or they are not within
Kopia SupportedAlgorithms, the default algorithm will be used.
This behavior is consistent with current behavior without this
change.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
Signed-off-by: Shubham Pampattiwar <shubhampampattiwar7@gmail.com>
openshift-merge-bot bot pushed a commit that referenced this pull request Aug 16, 2024
…#334) (#338)

add missing unit test for kopia hashing algo (#337)

Introduction of downstream only option to override Kopia default:
 - hashing algorithm
 - splitting algorithm
 - encryption algorithm

With introduction of 3 environment variables it is possible to override
Kopia algorithms used by Velero:

KOPIA_HASHING_ALGORITHM
KOPIA_SPLITTER_ALGORITHM
KOPIA_ENCRYPTION_ALGORITHM

If the env algorithms are not set or they are not within
Kopia SupportedAlgorithms, the default algorithm will be used.
This behavior is consistent with current behavior without this
change.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
Signed-off-by: Shubham Pampattiwar <shubhampampattiwar7@gmail.com>
sseago pushed a commit to sseago/velero that referenced this pull request Aug 22, 2024
…openshift#334)

Introduction of downstream only option to override Kopia default:
 - hashing algorithm
 - splitting algorithm
 - encryption algorithm

With introduction of 3 environment variables it is possible to override
Kopia algorithms used by Velero:

KOPIA_HASHING_ALGORITHM
KOPIA_SPLITTER_ALGORITHM
KOPIA_ENCRYPTION_ALGORITHM

If the env algorithms are not set or they are not within
Kopia SupportedAlgorithms, the default algorithm will be used.
This behavior is consistent with current behavior without this
change.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
shubham-pampattiwar pushed a commit that referenced this pull request Aug 22, 2024
…#334) (#338)

add missing unit test for kopia hashing algo (#337)

Introduction of downstream only option to override Kopia default:
 - hashing algorithm
 - splitting algorithm
 - encryption algorithm

With introduction of 3 environment variables it is possible to override
Kopia algorithms used by Velero:

KOPIA_HASHING_ALGORITHM
KOPIA_SPLITTER_ALGORITHM
KOPIA_ENCRYPTION_ALGORITHM

If the env algorithms are not set or they are not within
Kopia SupportedAlgorithms, the default algorithm will be used.
This behavior is consistent with current behavior without this
change.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
Signed-off-by: Shubham Pampattiwar <shubhampampattiwar7@gmail.com>
mpryc added a commit to mpryc/velero that referenced this pull request Sep 5, 2024
This fixes the PR openshift#334 where one additional line was
in the code. This was not exposed previously as we
did not had downstream CI Lint jobs.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
@mpryc mpryc mentioned this pull request Sep 5, 2024
mpryc added a commit to mpryc/velero that referenced this pull request Sep 5, 2024
This fixes the PR openshift#334 where one additional line was
in the code. This was not exposed previously as we
did not had downstream CI Lint jobs.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
openshift-merge-bot bot pushed a commit that referenced this pull request Sep 5, 2024
This fixes the PR #334 where one additional line was
in the code. This was not exposed previously as we
did not had downstream CI Lint jobs.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/velero that referenced this pull request Sep 5, 2024
This fixes the PR openshift#334 where one additional line was
in the code. This was not exposed previously as we
did not had downstream CI Lint jobs.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
openshift-merge-bot bot pushed a commit that referenced this pull request Sep 5, 2024
This fixes the PR #334 where one additional line was
in the code. This was not exposed previously as we
did not had downstream CI Lint jobs.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
Co-authored-by: Michal Pryc <mpryc@redhat.com>
sseago pushed a commit to sseago/velero that referenced this pull request Sep 19, 2024
…openshift#334) (openshift#338)

add missing unit test for kopia hashing algo (openshift#337)

Introduction of downstream only option to override Kopia default:
 - hashing algorithm
 - splitting algorithm
 - encryption algorithm

With introduction of 3 environment variables it is possible to override
Kopia algorithms used by Velero:

KOPIA_HASHING_ALGORITHM
KOPIA_SPLITTER_ALGORITHM
KOPIA_ENCRYPTION_ALGORITHM

If the env algorithms are not set or they are not within
Kopia SupportedAlgorithms, the default algorithm will be used.
This behavior is consistent with current behavior without this
change.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
Signed-off-by: Shubham Pampattiwar <shubhampampattiwar7@gmail.com>
sseago pushed a commit to sseago/velero that referenced this pull request Sep 19, 2024
This fixes the PR openshift#334 where one additional line was
in the code. This was not exposed previously as we
did not had downstream CI Lint jobs.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
sseago pushed a commit to sseago/velero that referenced this pull request Dec 11, 2024
…openshift#334) (openshift#338)

add missing unit test for kopia hashing algo (openshift#337)

Introduction of downstream only option to override Kopia default:
 - hashing algorithm
 - splitting algorithm
 - encryption algorithm

With introduction of 3 environment variables it is possible to override
Kopia algorithms used by Velero:

KOPIA_HASHING_ALGORITHM
KOPIA_SPLITTER_ALGORITHM
KOPIA_ENCRYPTION_ALGORITHM

If the env algorithms are not set or they are not within
Kopia SupportedAlgorithms, the default algorithm will be used.
This behavior is consistent with current behavior without this
change.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
Signed-off-by: Shubham Pampattiwar <shubhampampattiwar7@gmail.com>
sseago pushed a commit to sseago/velero that referenced this pull request Dec 11, 2024
This fixes the PR openshift#334 where one additional line was
in the code. This was not exposed previously as we
did not had downstream CI Lint jobs.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants