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

ft: BKTCLT-18 bootstrap go client #256

Merged
merged 4 commits into from
Sep 20, 2024

Conversation

jonathan-gramain
Copy link
Contributor

  • Initialize a new Go module with "bucketclient" package
  • BucketClient and BucketClientError types
  • Add a generic Request() function to query bucketd and retrieve the raw response

@bert-e
Copy link
Contributor

bert-e commented Sep 11, 2024

Hello jonathan-gramain,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request TBA
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@bert-e
Copy link
Contributor

bert-e commented Sep 11, 2024

Incorrect fix version

The Fix Version/s in issue BKTCLT-18 contains:

  • 7.10.8

Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:

  • 7.10.8

  • 8.1.11

Please check the Fix Version/s of BKTCLT-18, or the target
branch of this pull request.

@bert-e
Copy link
Contributor

bert-e commented Sep 11, 2024

Request integration branches

Waiting for integration branch creation to be requested by the user.

To request integration branches, please comment on this pull request with the following command:

/create_integration_branches

Alternatively, the /approve and /create_pull_requests commands will automatically
create the integration branches.

Copy link
Contributor

Choose a reason for hiding this comment

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

should this be in the same git repo (→ better locallity), or if we should use a new repo/project (→ simpler, mono-language repo ; better integration with golang package management or other tooling, ...) ?

@rachedbenmustapha what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not against a new repository if that helps with what you mentioned, no strong opinion on my side.

The same suggestion may apply for the migration tools (https://github.com/scality/MetaData/pull/2250) which could have their own repository as well, as there is no code dependency with the Metadata JS code (they depend on bucketd to be available on the same machine but that doesn't preclude using a different repository). Beside the better integration with golang package management, it would also avoid running all Metadata tests when pushing to it (and vice-versa). We may still integrate the built binaries into the Metadata image, or create a new migration image to run it inside a new container (running along with the scality-bucketd-migration containers).

Copy link

@BourgoisMickael BourgoisMickael Sep 17, 2024

Choose a reason for hiding this comment

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

I'm also down for another repo or a mono repo for go and js packages.

Otherwise it could be nice to filter out the go files for js package with a files property in package.json or .npmignore (but I'm not sure it works when installing from url instead of a registry) and same for go

run: make lint

- name: Run unit tests
run: make test-coverage
Copy link
Contributor

Choose a reason for hiding this comment

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

we probably want to take the change to activate codecov already, so we don't accumulate debt while building up the project (c.f. https://github.com/scality/sorbet/blob/HEAD/codecov.yml and https://github.com/scality/sorbet/blob/HEAD/.github/workflows/tests.yaml#L119-L126 for exemple)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do next week, separately from this PR (https://scality.atlassian.net/browse/BKTCLT-20). I made a PR for metadata-migration: https://github.com/scality/metadata-migration/pull/8

@jonathan-gramain jonathan-gramain force-pushed the feature/BKTCLT-18-go-bindings branch 3 times, most recently from af78c7e to 5a8e27b Compare September 12, 2024 22:19
@jonathan-gramain jonathan-gramain force-pushed the feature/BKTCLT-18-go-bindings branch 2 times, most recently from d5b0131 to c356dea Compare September 17, 2024 00:32
@jonathan-gramain jonathan-gramain force-pushed the feature/BKTCLT-18-go-bindings branch from c356dea to 962ceb4 Compare September 17, 2024 18:36
defer cancel()

_, err := client.Request(timeoutCtx, "GetObject", "GET", "/foo/bar")
Expect(err).To(MatchError(ContainSubstring("context deadline exceeded")))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Expect(err).To(MatchError(ContainSubstring("context deadline exceeded")))
Expect(err).To(MatchError(context.DeadlineExceeded))

idempotent IdempotentOpt
}

func parseRequestOptions(opts ...any) (requestOptionsSet, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A common pattern to avoid untyped apis for variable options is to use functions:

type RequestOption func(*requestOptionSet)

func RequestBodyOption(body RequestBodyOpt) RequestOption {
    return func(ros *requestOptionSet) {
        ros.requestBody = body
    }
}

func Idempotent(ros *requestOptionSet) {
    ros. idempotent = true
}

func parseRequestOptions(opts ...RequestOption) (requestOptionsSet, error) {
    for _, o := range opts {
        o(&parsedOpts)
    }
}

...
parseRequestOptions(RequestBodyOption(body), Idempotent)
...

This way it's impossible to pass an unknown/invalid option.

Also instead of parsing and returning a struct to be consumed by the Request function, the options (functions) could be directly applied by Request if they took an http request as an argument to mutate.

Add a generic Request() function to query bucketd and retrieve the raw response
Updates to Go client only
@jonathan-gramain jonathan-gramain force-pushed the feature/BKTCLT-18-go-bindings branch from 0b3e7f2 to 871d3ac Compare September 20, 2024 04:09
@jonathan-gramain
Copy link
Contributor Author

/approve

@bert-e
Copy link
Contributor

bert-e commented Sep 20, 2024

Conflict

A conflict has been raised during the creation of
integration branch w/8.1/feature/BKTCLT-18-go-bindings with contents from feature/BKTCLT-18-go-bindings
and development/8.1.

I have not created the integration branch.

Here are the steps to resolve this conflict:

 $ git fetch
 $ git checkout -B w/8.1/feature/BKTCLT-18-go-bindings origin/development/8.1
 $ git merge origin/feature/BKTCLT-18-go-bindings
 $ # <intense conflict resolution>
 $ git commit
 $ git push -u origin w/8.1/feature/BKTCLT-18-go-bindings

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Sep 20, 2024

I have successfully merged the changeset of this pull request
into targetted development branches:

  • ✔️ development/7.10

  • ✔️ development/8.1

The following branches have NOT changed:

  • development/6.4
  • development/7.4

Please check the status of the associated issue BKTCLT-18.

Goodbye jonathan-gramain.

The following options are set: approve

@bert-e bert-e merged commit 871d3ac into development/7.10 Sep 20, 2024
2 checks passed
@jonathan-gramain jonathan-gramain deleted the feature/BKTCLT-18-go-bindings branch October 4, 2024 11:24
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.

5 participants