feat(drivers): implement SGCP NFS consistency group resource#1067
Open
PaulJouvanceau wants to merge 1 commit into
Open
feat(drivers): implement SGCP NFS consistency group resource#1067PaulJouvanceau wants to merge 1 commit into
PaulJouvanceau wants to merge 1 commit into
Conversation
Add a new `resfssgcp_nfs_cg` resource driver to manage Scaleway NFS consistency groups (CG). This driver provides: - Switchover / failover of a CG to a target availability zone (AZ). - Sync-resume to re-establish replication after an incident. - Detailed status reporting including geo-redundancy and replication states. **Changes in `util/sgcp/file.go`:** - Add `GetConsistencyGroup` and `PatchConsistencyGroup` methods to the `FilesAPI` struct. These allow retrieving CG details and applying operations (switchover, failover, resume-replication) via the Scaleway API. **Implementation of `drivers/resfssgcp_nfs_cg/main.go`:** - Define data models (`CgInfo`, `GeoRedundancyInfo`, `ReplicationInfo`, etc.) that mirror the API response. - Implement `cgMgr` to abstract API calls and handle retries. - Implement `T` resource with configuration keywords: `uuid`, `az`, `secret`, `endpoint`, `timeout`, `failover`. - Add `Start()`: performs switchover (or failover when `--force` is set), with fallback to failover on precondition failure (412) if conditions are met. - Add `SyncResume()`: checks resumability via `checkResumable()` and calls the resume API, waiting for the CG to become ready. - Add `Status()`: displays CG status, geo-redundancy targets, and replication targets with appropriate log levels. - Implement caching (`cgInfoCache`) to reduce API calls during status polling. **Testing (`drivers/resfssgcp_nfs_cg/main_test.go`):** - Unit tests for helpers, `checkResumable`, `localRepStatus`, and `waitForFn` using JSON fixtures. - Integration tests covering `Start` (success, 412 fallback, force, already up, operation in progress) and `SyncResume` (success, already resumed, in progress) using a mocked API. - Add `util/sgcpcgtesthelper` package: an in-memory mock implementation of `cgAPI` with call counters and customisable callbacks (`PatchSwitchoverFunc`, `PatchFailoverFunc`, `PatchResumeFunc`). This allows precise control over API responses and state transitions.
d2a0afa to
4572888
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new
resfssgcp_nfs_cgresource driver to manage Scaleway NFS consistency groups (CG). This driver provides:Changes in
util/sgcp/file.go:GetConsistencyGroupandPatchConsistencyGroupmethods to theFilesAPIstruct. These allow retrieving CG details and applying operations (switchover, failover, resume-replication) via the Scaleway API.Implementation of
drivers/resfssgcp_nfs_cg/main.go:CgInfo,GeoRedundancyInfo,ReplicationInfo, etc.) that mirror the API response.cgMgrto abstract API calls and handle retries.Tresource with configuration keywords:uuid,az,secret,endpoint,timeout,failover.Start(): performs switchover (or failover when--forceis set), with fallback to failover on precondition failure (412) if conditions are met.SyncResume(): checks resumability viacheckResumable()and calls the resume API, waiting for the CG to become ready.Status(): displays CG status, geo-redundancy targets, and replication targets with appropriate log levels.cgInfoCache) to reduce API calls during status polling.Testing (
drivers/resfssgcp_nfs_cg/main_test.go):checkResumable,localRepStatus, andwaitForFnusing JSON fixtures.Start(success, 412 fallback, force, already up, operation in progress) andSyncResume(success, already resumed, in progress) using a mocked API.util/sgcpcgtesthelperpackage: an in-memory mock implementation ofcgAPIwith call counters and customisable callbacks (PatchSwitchoverFunc,PatchFailoverFunc,PatchResumeFunc). This allows precise control over API responses and state transitions.