Skip to content

MicroCeph Remote Replication (2/3): RBD Mirroring#398

Closed
UtkarshBhatthere wants to merge 35 commits intocanonical:mainfrom
UtkarshBhatthere:feature/remoteRBDReplication
Closed

MicroCeph Remote Replication (2/3): RBD Mirroring#398
UtkarshBhatthere wants to merge 35 commits intocanonical:mainfrom
UtkarshBhatthere:feature/remoteRBDReplication

Conversation

@UtkarshBhatthere
Copy link
Copy Markdown
Contributor

@UtkarshBhatthere UtkarshBhatthere commented Aug 8, 2024

This Pr is being closed and moved to #437 where it has been rebased over MicroCluster LTS changes.

@UtkarshBhatthere UtkarshBhatthere force-pushed the feature/remoteRBDReplication branch from b33b75f to ef9c3af Compare August 9, 2024 12:30
@UtkarshBhatthere UtkarshBhatthere force-pushed the feature/remoteRBDReplication branch 2 times, most recently from 1ff1849 to 08e99d4 Compare August 20, 2024 12:54
Copy link
Copy Markdown
Collaborator

@sabaini sabaini left a comment

Choose a reason for hiding this comment

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

Hi Utkarsh, did a quick once-over review -- please find some comments inline

Comment thread microceph/api/cluster.go
Get: rest.EndpointAction{Handler: cmdClusterGet, ProxyTarget: false},
}

// cmdClusterGet returns a json dump of microceph configs with a new key patched in for the remote.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Feel this doc comment could elaborate some more e.g.

// cmdClusterGet returns a json dump of microceph configs including credentials for a new remote. Credentials returned as a newly created keyring.

Comment thread microceph/api/cluster.go
[]string{"mon", "allow *"},
[]string{"osd", "allow *"},
[]string{"mds", "allow *"},
[]string{"mgr", "allow *"},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These are full caps, I wonder if we really need all? Also I seem to recall some description from the spec where the key should only be initialized with minimal caps?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, I believe we should use the bare minimum caps needed. If possible, this should be more fine grained.

Comment thread microceph/api/ops_replication.go Outdated
}

return handleRbdRepRequest(r.Context(), req)
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There seems to be code duplication with the cmdOpsReplication* funcs, possibly could unify them

Comment thread microceph/api/remote.go
/*****************HELPER FUNCTIONS**************************/

// RenderConfAndKeyringFiles generates the $cluster.conf and $cluster.keyring files on the host.
var RenderConfAndKeyringFiles = func(remoteName string, localName string, configs map[string]string) error {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see there's several func variables defined here. Do you need to stub them out for unit testing? (Don't see any unit tests referencing them now).

IMHO adding stubs for testing like this is most useful if you need to override a low-level function that won't easily be run in a test env.

I'd also advise to wrap stubs in an interface, this allows to generate mocks with stretchr and mockery

https://github.com/stretchr/testify
https://github.com/vektra/mockery

F.e. take a look at the ceph.processExec var which in a deploymend runs shell commands but for unit testing is mocked out.

Comment thread microceph/api/remote.go
Delete: rest.EndpointAction{Handler: CmdRemoteDelete, ProxyTarget: false},
}

var CmdRemotePut = func(state *state.State, r *http.Request) response.Response {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add doc comments at least for the main funcs

@@ -0,0 +1,29 @@
package types

type Remote struct {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This type deserves some docs I believe

Comment thread microceph/ceph/keyring.go
}

// CreateKey creates a client key and returns the said key hash without saving it as a file.
var CreateKey = func(clientName string, caps ...[]string) (string, error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

See above re: mocking. The cephRun() func you're using here to perform system commands can be mocked already, see var processExec Runner = RunnerImpl{}

}

func genericServiceInit(s interfaces.StateInterface, name string) error {
func genericServiceInit(s interfaces.StateInterface, name string, isClientService bool) error {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder if instead of adding a flag to the genericServiceInit the rbd-mirror service could subclass GenericServicePlacement, like the RGW service placement does? This would feel cleaner

@UtkarshBhatthere UtkarshBhatthere changed the title Enable RBD Mirroring MicroCeph Remote Replication (2/3): RBD Mirroring Aug 27, 2024
Comment thread microceph/api/cluster.go
if err != nil || !isOk {
err := fmt.Errorf("cluster names can only have [a-z] or [0-9] characters: %w", err)
logger.Error(err.Error())
return response.InternalError(err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be a BadRequest, since InternalError doesn't represent a user error, imo.

Comment thread microceph/api/cluster.go
if err != nil {
err := fmt.Errorf("failed to get config db: %w", err)
logger.Error(err.Error())
return response.InternalError(err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above.

Comment thread microceph/api/cluster.go
[]string{"mon", "allow *"},
[]string{"osd", "allow *"},
[]string{"mds", "allow *"},
[]string{"mgr", "allow *"},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, I believe we should use the bare minimum caps needed. If possible, this should be more fine grained.

Comment thread microceph/api/remote.go

if !req.RenderOnly {
// Asynchronously persist this on db and send request to other cluster members.
go func() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we should return before this call completes. Why not make this a synchronous call?

Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
@UtkarshBhatthere UtkarshBhatthere force-pushed the feature/remoteRBDReplication branch from ba4ba0f to 76dafd2 Compare September 3, 2024 12:08
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
@UtkarshBhatthere UtkarshBhatthere force-pushed the feature/remoteRBDReplication branch from 76dafd2 to c31d4bc Compare September 4, 2024 21:54
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
@UtkarshBhatthere UtkarshBhatthere force-pushed the feature/remoteRBDReplication branch from 78c9c5d to acf4b68 Compare September 5, 2024 12:58
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
@UtkarshBhatthere UtkarshBhatthere force-pushed the feature/remoteRBDReplication branch from 57da944 to 1861554 Compare October 3, 2024 18:25
@UtkarshBhatthere
Copy link
Copy Markdown
Contributor Author

This Pr is being closed and moved to #437

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.

3 participants