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

cst/inv: Create helpers to conditionally create inventory config #16636

Merged
merged 2 commits into from
Feb 23, 2024

Conversation

abhijat
Copy link
Contributor

@abhijat abhijat commented Feb 19, 2024

Introduces helpers to check if inventory configuration exists, and to conditionally create one. Maps the result of the individual calls to inventory_creation_result states:

  • success
  • failure
  • already_exists

The creation of config is expected to be performed by any node in cluster at startup. Instead of simply attempting to create and relying on the server side validation to prevent duplicates, we first do a check before creating the config. One node creates the config and the others see that the config is present and move on.

Handling races while creation

It is possible that multiple nodes try to create the config after they observe that the config is missing, since the calls to check and create are separate. In this case all but one nodes will fail to create the config. The failing nodes should return the status as already_exists rather than failed. To achieve this, on failure the nodes once again check if the config exists and they lost the race to create it.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x
  • v23.1.x

Release Notes

  • None

@abhijat abhijat force-pushed the feat/inv-scrub/check-config-exists branch 4 times, most recently from 1560e8d to 81b58f6 Compare February 20, 2024 05:57
@abhijat abhijat marked this pull request as draft February 20, 2024 05:59
A helper is added to check if an inventor configuration exists already.
This is expected to be used as a check before creating the inventory
configuration.

While the GET call used for the check returns the inventory config
details, we do not use these other than the HTTP status code. For the
AWS implementation added here the details are not needed. For GCP we
will need to extract the server assigned UUID for future calls.
@abhijat abhijat force-pushed the feat/inv-scrub/check-config-exists branch from 81b58f6 to 2fd8d25 Compare February 21, 2024 05:44
A top level method is added to conditionally create inventory config if
it does not already exist. This involves two operations, one download
(to check if the config exists) and one upload (to create). The results
of the two are merged into a success/failure enum class.

This top level method is expected to be used by callers to create the
config.
@abhijat abhijat force-pushed the feat/inv-scrub/check-config-exists branch from 2fd8d25 to 695e569 Compare February 22, 2024 03:43
@abhijat abhijat changed the title cst/inv: Create helpers to check if inventory config exists and conditionally create it cst/inv: Create helpers to conditionally create inventory config Feb 22, 2024
@abhijat abhijat marked this pull request as ready for review February 22, 2024 09:15
@abhijat
Copy link
Contributor Author

abhijat commented Feb 22, 2024

CI failure #15679

Comment on lines +107 to +112
auto dl_res = co_await remote.download_object(
{.transfer_details
= {.bucket = _bucket, .key = _inventory_key, .parent_rtc = parent_rtc},
.payload = buf});
co_return dl_res == download_result::success;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

i imagine HEAD does not work for inventory files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an object in the REST API sense, there is no file backing the config, so a GET request is the only option (https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketInventoryConfiguration.html)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be clearer, this is not the inventory file itself but the inventory schedule, IE a server side entity

@abhijat abhijat merged commit 6a4d49b into redpanda-data:dev Feb 23, 2024
17 checks passed
Comment on lines +101 to +105
// This buffer is thrown away after the GET call returns, we might introduce
// some sort of struct (or reuse the aws_report_configuration used for
// serialization), but for AWS we generally do not need the actual report
// config, the HTTP status for the GET call is sufficient to tell us if the
// config exists.
Copy link
Member

Choose a reason for hiding this comment

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

thank you for this comment

Comment on lines +107 to +110
auto dl_res = co_await remote.download_object(
{.transfer_details
= {.bucket = _bucket, .key = _inventory_key, .parent_rtc = parent_rtc},
.payload = buf});
Copy link
Member

Choose a reason for hiding this comment

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

is it slightly odd to use download_object here? seems like some sort of more raw/low-level GET verb used directly would be clearer? (btw no need to chagne this , just trying to understand)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a little off, but remote currently doesn't have a pure GET operation, download_object was also added recently. The right thing to do would probably be to add a GET operation and make download_object a wrapper for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants