Skip to content

feat(drivers): implement SGCP NFS consistency group resource#1067

Open
PaulJouvanceau wants to merge 1 commit into
opensvc:mainfrom
PaulJouvanceau:feat/sgcp-nfs-consistency
Open

feat(drivers): implement SGCP NFS consistency group resource#1067
PaulJouvanceau wants to merge 1 commit into
opensvc:mainfrom
PaulJouvanceau:feat/sgcp-nfs-consistency

Conversation

@PaulJouvanceau

Copy link
Copy Markdown
Contributor

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.

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.
@PaulJouvanceau PaulJouvanceau force-pushed the feat/sgcp-nfs-consistency branch from d2a0afa to 4572888 Compare July 16, 2026 13:25
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.

1 participant