Skip to content

Add Remote ConfigBackup type with S3 object storage - #490

Open
felix-kaestner wants to merge 7 commits into
mainfrom
remote-backup
Open

Add Remote ConfigBackup type with S3 object storage#490
felix-kaestner wants to merge 7 commits into
mainfrom
remote-backup

Conversation

@felix-kaestner

Copy link
Copy Markdown
Contributor

No description provided.

Introduce a Method string type with constants MethodCLI and
MethodCLIASCII. Add WithMethod(m Method) on Request, following
the same pattern as WithRollback.

The cli_ascii method returns plain text in the result.msg field
instead of structured JSON in result.body. The response decoder
now handles both fields, returning whichever is populated.

This enables callers to retrieve unstructured output such as
show running-config as a JSON-encoded string.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Add a new ConfigBackupType 'Remote' that fetches the running
configuration from the device via RunningConfig() and uploads
it to an S3-compatible object store.

API changes:
- Add ConfigBackupTypeRemote enum value
- Add ConfigBackupS3 struct (endpoint, bucket, region, creds)
- Add S3 field to ConfigBackupSpec with CEL validation
- Add SecretNotFoundReason condition reason
- Add GetSecretRefs() helper on ConfigBackup

Controller changes:
- Add ObjectStorage interface and optional field on reconciler
- Add ListRemoteConfigBackups, CreateRemoteConfigBackup, and
  DeleteRemoteConfigBackups methods
- Integrate Remote type into the existing reconcile flow with
  switch/default dispatch alongside Local/Startup
- Watch referenced Secrets to re-reconcile on creation/update
- Handle missing Secret with terminal SecretNotFound condition

New package internal/objectstorage:
- S3-compatible client wrapping aws-sdk-go-v2 with PutObject,
  ListObjects, and DeleteObjects operations

Also adds RunningConfig() to ConfigBackupProvider interface
with NX-OS implementation via cli_ascii NX-API method.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Add a MinIO deployment to config/develop for local S3 testing.
Includes a ClusterIP Service and credentials Secret. The Tilt
setup port-forwards the MinIO console to localhost:9001.

Add a remote-backup sample in the ConfigBackup samples that
backs up every minute to the in-cluster MinIO instance with
retention of 10 backups.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Before performing a Remote backup, the controller now calls
HeadBucket to verify the S3 endpoint is reachable and the
configured bucket exists.

If the check succeeds, RemoteEndpointReady is set to True.
If it fails, both RemoteEndpointReady and Ready are set to
False with reason RemoteEndpointUnreachable, and the
reconciliation stops with an error.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Add ConfigBackupEncryption struct with support for AES-256-GCM
and ChaCha20-Poly1305 algorithms. Encryption is performed in
the controller pod before uploading to object storage.

The encryption key is resolved from a referenced Secret via
the existing clientutil.Secret pattern. If the key Secret is
missing, a terminal SecretNotFound condition is set. If
encryption fails (e.g., invalid key size), a terminal
EncryptionFailed condition is set with a warning event.

The LastBackup status now includes EncryptionAlgorithm and
EncryptionKeySecret fields so users can inspect which
encryption was applied to each backup.

GetSecretRefs is extended to include the encryption key Secret
so the watcher triggers re-reconciliation on key changes.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Add hack/decrypt-backup, a CLI tool that downloads and decrypts
a remote ConfigBackup from S3. It reads the ConfigBackup
resource to determine the S3 endpoint, credentials, encryption
settings, and the object key from status.lastBackup.filepath.

Also adds GetObject to the objectstorage client for downloading
objects from S3.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Document the new Remote backup type including S3 configuration,
encrypted backups, supported algorithms, status conditions, and
the decrypt-backup tool usage.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
@github-actions

Copy link
Copy Markdown

Merging this branch changes the coverage (2 decrease, 2 increase)

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/api/core/v1alpha1 1.70% (-0.02%) 👎
github.com/ironcore-dev/network-operator/hack/decrypt-backup 0.00% (ø)
github.com/ironcore-dev/network-operator/internal/controller/core 61.53% (+0.01%) 👍
github.com/ironcore-dev/network-operator/internal/objectstorage 0.00% (ø)
github.com/ironcore-dev/network-operator/internal/provider 0.00% (ø)
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos 9.23% (-0.03%) 👎
github.com/ironcore-dev/network-operator/internal/transport/nxapi 69.47% (+1.70%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/api/core/v1alpha1/configbackup_types.go 5.56% (-5.56%) 18 (+9) 1 17 (+9) 👎
github.com/ironcore-dev/network-operator/api/core/v1alpha1/groupversion_info.go 0.00% (ø) 2 0 2
github.com/ironcore-dev/network-operator/api/core/v1alpha1/zz_generated.deepcopy.go 0.00% (ø) 2505 (+22) 0 2505 (+22)
github.com/ironcore-dev/network-operator/hack/decrypt-backup/main.go 0.00% (ø) 87 (+87) 0 87 (+87)
github.com/ironcore-dev/network-operator/internal/controller/core/configbackup_controller.go 59.50% (-3.41%) 321 (+108) 191 (+57) 130 (+51) 👎
github.com/ironcore-dev/network-operator/internal/objectstorage/doc.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/internal/objectstorage/s3.go 0.00% (ø) 34 (+34) 0 34 (+34)
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/provider.go 0.37% (-0.00%) 2136 (+9) 8 2128 (+9) 👎
github.com/ironcore-dev/network-operator/internal/provider/provider.go 0.00% (ø) 42 0 42
github.com/ironcore-dev/network-operator/internal/transport/nxapi/nxapi.go 69.47% (+1.70%) 95 (+5) 66 (+5) 29 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/ironcore-dev/network-operator/internal/controller/core/configbackup_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/suite_test.go
  • github.com/ironcore-dev/network-operator/internal/transport/nxapi/nxapi_test.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant