Skip to content

Conversation

phlogistonjohn
Copy link
Collaborator

@phlogistonjohn phlogistonjohn commented Apr 7, 2025

Add a new smb admin api.
This should be compatible with the recently added smb mgr module in ceph.

Note that the smb module on the ceph side supports a declarative style api where resource specs are the full power interface to use. There are some imperative style apis but we don't need to implement those in this library.

Checklist

  • Added tests for features and functional changes
  • Public functions and types are documented
  • Standard formatting is applied to Go code
  • Is this a new API? Added a new file that begins with //go:build ceph_preview
  • Ran make api-update to record new APIs

New or infrequent contributors may want to review the go-ceph Developer's Guide including the section on how we track API Status and the API Stability Plan.

The go-ceph project uses mergify. View the mergify command guide for information on how to interact with mergify. Add a comment with @Mergifyio rebase to rebase your PR when github indicates that the PR is out of date with the base branch.

@phlogistonjohn phlogistonjohn changed the title [DNM] Add a new smb admin API sub-package [DNM][post-v033] Add a new smb admin API sub-package Apr 7, 2025
@phlogistonjohn phlogistonjohn added the API This PR includes a change to the public API of a go-ceph package label Apr 8, 2025
@phlogistonjohn
Copy link
Collaborator Author

I was trying to remember why I did not check off the Ran make api-update checklist item. After a minute of thought I remembered that the ceph_main build tag prevents the api from being added normally. What I mean to do is leave this in draft until there's at least a pre-tentacle test job available and then rework the build tags so that this code will apply on tentacle.

@phlogistonjohn phlogistonjohn changed the title [DNM][post-v033] Add a new smb admin API sub-package [DNM] Add a new smb admin API sub-package Apr 16, 2025
@phlogistonjohn phlogistonjohn marked this pull request as ready for review April 30, 2025 17:53
@phlogistonjohn
Copy link
Collaborator Author

@anoopcs9 @ansiwen now that Anoop has added a pre-tentacle job I figured it would be finally time to finish this up. Please review. While it's no rush I know that at least one cloud vendor is interested.

@phlogistonjohn phlogistonjohn changed the title [DNM] Add a new smb admin API sub-package Add a new smb admin API sub-package Apr 30, 2025
Copy link
Collaborator

@anoopcs9 anoopcs9 left a comment

Choose a reason for hiding this comment

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

This looks really good and well structured, thanks.

I only have few minor comments with a suggestion to place the commit admin/smb: add resources.go containing resource management funcs before admin/smb: add result.go for the apply result types as I had to jump to check for resourceEntry from a further commit.

Comment on lines +61 to +69
IntentValue Intent `json:"intent"`
ClusterID string `json:"cluster_id"`
AuthMode ClusterAuthMode `json:"auth_mode"`
DomainSettings *DomainSettings `json:"domain_settings,omitempty"`
UserGroupSettings []UserGroupSource `json:"user_group_settings,omitempty"`
CustomDNS []string `json:"custom_dns,omitempty"`
Placement Placement `json:"placement,omitempty"`
Clustering Clustering `json:"clustering,omitempty"`
PublicAddrs []PublicAddress `json:"public_addrs,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

DomainSettings  *DomainSettings
. . .
Placement       Placement
Clustering      Clustering

I hope we don't have any generic guideline to not use the same name for field and its type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, I think this is fairly common in Go, but if you think I'm mistaken about that or it just bothers you a lot, let me know.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you happen to update the patch set again I would like to suggest a change to name it slightly different to avoid a first look confusion. Feel free to ignore if you think its not worth it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's preferable and I think it is a fairly common convention but I can't find too many links discussing this exact point. I'm going to leave it as-is and wait to see what @ansiwen thinks about this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't have a strong opinion, I just know that I sometime also use identical names and types, because it feels awkward otherwise, but I also get the point @anoopcs9 is talking about. Usually I would go whatever we do otherwise in go-ceph. Sorry, I'm a bad tie-breaker in this case.

@phlogistonjohn
Copy link
Collaborator Author

I fixed a lot of the low hanging fruit items that you pointed out, thanks! I will fold/squash the temp commits later after I spend a few more minutes thinking about the remaining items. In the meantime I will let the tests run to find any mistakes in these fixes :-)

@anoopcs9
Copy link
Collaborator

anoopcs9 commented May 5, 2025

We see CI failure on main because the regression reported via #1107 got fixed on Ceph side.

@phlogistonjohn
Copy link
Collaborator Author

fixes and udates squashed, branch rebased

@phlogistonjohn
Copy link
Collaborator Author

Thanks for finding all my lazy copy-and-pasteoid errors that I missed. :-D

anoopcs9
anoopcs9 previously approved these changes May 7, 2025
Copy link
Collaborator

@anoopcs9 anoopcs9 left a comment

Choose a reason for hiding this comment

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

lgtm, thanks.

Copy link

mergify bot commented May 17, 2025

This pull request has been removed from the queue for the following reason: pull request branch update failed.

The pull request can't be updated.

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@anoopcs9
Copy link
Collaborator

@Mergifyio rebase

Copy link

mergify bot commented May 18, 2025

rebase

✅ Branch has been successfully rebased

Copy link

mergify bot commented May 28, 2025

This pull request has been removed from the queue for the following reason: pull request dequeued.

Pull request #1100 has been dequeued. The pull request rule doesn't match anymore. The following conditions don't match anymore:

  • status-success=check
  • status-success=test-suite (octopus)
  • status-success=test-suite (pacific)
  • status-success=test-suite (quincy)
  • status-success=test-suite (reef)
  • status-success=test-suite (squid)
  • any of:
    • all of:
      • label=no-API
    • all of:
      • #approved-reviews-by>=2
    • all of:
      • updated-at<10 days ago
  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue default]
      • any of: [🛡 GitHub branch protection]
        • check-neutral = check
        • check-skipped = check
        • check-success = check
      • any of: [🛡 GitHub branch protection]
        • check-neutral = test-suite (octopus)
        • check-skipped = test-suite (octopus)
        • check-success = test-suite (octopus)
      • any of: [🛡 GitHub branch protection]
        • check-neutral = test-suite (pacific)
        • check-skipped = test-suite (pacific)
        • check-success = test-suite (pacific)
      • any of: [🛡 GitHub branch protection]
        • check-neutral = test-suite (quincy)
        • check-skipped = test-suite (quincy)
        • check-success = test-suite (quincy)
      • any of: [🛡 GitHub branch protection]
        • check-neutral = test-suite (reef)
        • check-skipped = test-suite (reef)
        • check-success = test-suite (reef)
      • any of: [🛡 GitHub branch protection]
        • check-neutral = test-suite (squid)
        • check-skipped = test-suite (squid)
        • check-success = test-suite (squid).

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@anoopcs9
Copy link
Collaborator

@Mergifyio requeue

Copy link

mergify bot commented May 28, 2025

requeue

✅ The queue state of this pull request has been cleaned. It can be re-embarked automatically

Part of the ceph command api supports commands with additional
data in a buffer. Add interfaces that match these function calls
in the go-ceph rados package.

Signed-off-by: John Mulligan <[email protected]>
The admin_test.go module is the place where we actually test the
smb module communicating with our go-ceph smb subpackage.

Signed-off-by: John Mulligan <[email protected]>
Add a small commentary on how the smb module is expected to be used.

Signed-off-by: John Mulligan <[email protected]>
@mergify mergify bot dismissed anoopcs9’s stale review May 28, 2025 15:20

Pull request has been modified.


// MarshalJSON supports marshalling a cluster to JSON.
func (cluster *Cluster) MarshalJSON() ([]byte, error) {
type vCluster Cluster
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not clear to me, what v and w stands for here. Just like x and y?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I started off with v for virtual, and then needed another placeholder so I just chose w to follow on with v. These types only exist to wrangle the json so I don't think I put a lot of thought into the naming here.


const (
// Present resources will be created or updated.
Present = Intent("present")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably has no real-world effect, but want to mention it anyway: like errors.New() using a pointer to a string instead of the string itself makes the switch-cases faster and allows identical string in different enums.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think I would want to change it now, but I will keep that in mind for the future.

return false
}

var rl = []rune("bcdfghjklmnpqrstvwxyz")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are some characters omitted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So that it makes junk strings and not words. I saw some other project doing that (k8s?) and kinda copied the idea.

// errorMerge is a helper function for combining a lower level error from
// the api with a resultGroup, treating the result group as an error if it
// is not successful.
func errorMerge(results ResultGroup, err error) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think "merge" is misleading, it is rather selecting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Far enough, it's a private function so we can change it whenever. Because I am anxious to land this PR after it's been open for almost 2 months I'm going to leave it as-is but I might come back in a follow up PR to adjust this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No great alternatives are jumping to mind, let me know if you have any suggestions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

errorPick?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought that was obvious from my wording: errorSelect, but I actually think errorPick is even better!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@ansiwen ansiwen left a comment

Choose a reason for hiding this comment

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

I left a few comments, but no blockers and otherwise LGTM as far as I can tell without knowing more about the business logic. I set do-not-merge to give a chance to react to the comments. Remove it at your own convenience.

@mergify mergify bot merged commit a1fcb9c into ceph:master Jun 4, 2025
14 of 16 checks passed
@phlogistonjohn phlogistonjohn deleted the jjm-admin-smb branch June 4, 2025 21:27
phlogistonjohn added a commit to phlogistonjohn/go-ceph that referenced this pull request Jun 4, 2025
It better reflects what the function does.
Per the discussion in
    ceph#1100 (comment)
and subsequent comments.

Signed-off-by: John Mulligan <[email protected]>
phlogistonjohn added a commit to phlogistonjohn/go-ceph that referenced this pull request Jun 4, 2025
It better reflects what the function does.
Per the discussion in
    ceph#1100 (comment)
and subsequent comments.

Signed-off-by: John Mulligan <[email protected]>
anoopcs9 pushed a commit to phlogistonjohn/go-ceph that referenced this pull request Jun 5, 2025
It better reflects what the function does.
Per the discussion in
    ceph#1100 (comment)
and subsequent comments.

Signed-off-by: John Mulligan <[email protected]>
mergify bot pushed a commit that referenced this pull request Jun 5, 2025
It better reflects what the function does.
Per the discussion in
    #1100 (comment)
and subsequent comments.

Signed-off-by: John Mulligan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API This PR includes a change to the public API of a go-ceph package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants