MicroCeph Remote Replication (2/3): RBD Mirroring#398
MicroCeph Remote Replication (2/3): RBD Mirroring#398UtkarshBhatthere wants to merge 35 commits intocanonical:mainfrom
Conversation
b33b75f to
ef9c3af
Compare
1ff1849 to
08e99d4
Compare
sabaini
left a comment
There was a problem hiding this comment.
Hi Utkarsh, did a quick once-over review -- please find some comments inline
| Get: rest.EndpointAction{Handler: cmdClusterGet, ProxyTarget: false}, | ||
| } | ||
|
|
||
| // cmdClusterGet returns a json dump of microceph configs with a new key patched in for the remote. |
There was a problem hiding this comment.
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.
| []string{"mon", "allow *"}, | ||
| []string{"osd", "allow *"}, | ||
| []string{"mds", "allow *"}, | ||
| []string{"mgr", "allow *"}, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Yes, I believe we should use the bare minimum caps needed. If possible, this should be more fine grained.
| } | ||
|
|
||
| return handleRbdRepRequest(r.Context(), req) | ||
| } |
There was a problem hiding this comment.
There seems to be code duplication with the cmdOpsReplication* funcs, possibly could unify them
| /*****************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 { |
There was a problem hiding this comment.
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.
| Delete: rest.EndpointAction{Handler: CmdRemoteDelete, ProxyTarget: false}, | ||
| } | ||
|
|
||
| var CmdRemotePut = func(state *state.State, r *http.Request) response.Response { |
There was a problem hiding this comment.
Please add doc comments at least for the main funcs
| @@ -0,0 +1,29 @@ | |||
| package types | |||
|
|
|||
| type Remote struct { | |||
There was a problem hiding this comment.
This type deserves some docs I believe
| } | ||
|
|
||
| // 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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
| 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) |
There was a problem hiding this comment.
This should be a BadRequest, since InternalError doesn't represent a user error, imo.
| if err != nil { | ||
| err := fmt.Errorf("failed to get config db: %w", err) | ||
| logger.Error(err.Error()) | ||
| return response.InternalError(err) |
| []string{"mon", "allow *"}, | ||
| []string{"osd", "allow *"}, | ||
| []string{"mds", "allow *"}, | ||
| []string{"mgr", "allow *"}, |
There was a problem hiding this comment.
Yes, I believe we should use the bare minimum caps needed. If possible, this should be more fine grained.
|
|
||
| if !req.RenderOnly { | ||
| // Asynchronously persist this on db and send request to other cluster members. | ||
| go func() { |
There was a problem hiding this comment.
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>
ba4ba0f to
76dafd2
Compare
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>
76dafd2 to
c31d4bc
Compare
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>
78c9c5d to
acf4b68
Compare
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
57da944 to
1861554
Compare
|
This Pr is being closed and moved to #437 |
This Pr is being closed and moved to #437 where it has been rebased over MicroCluster LTS changes.