-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Before this change we had only one provider, so this was internal implementation detail. This change adds the second provider, allowing users to configure the provider in the environment file. Replace the `external: true` option with `provider: external`. With this we can remove the special handling or external cluster with calls to the external provider which does the right thing. The external provider basically does nothing, since we do not manage this cluster. However in start() we ensure that the cluster exists and then wait until the cluster is ready. This helps to debug issues with external cluster and reduces log noise. Signed-off-by: Nir Soffer <[email protected]>
- Loading branch information
Showing
4 changed files
with
90 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# SPDX-FileCopyrightText: The RamenDR authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import logging | ||
import time | ||
|
||
from drenv import cluster | ||
|
||
# Provider scope | ||
|
||
|
||
def setup(): | ||
logging.info("[external] Skipping setup for external provider") | ||
|
||
|
||
def cleanup(): | ||
logging.info("[external] Skipping cleanup for external provider") | ||
|
||
|
||
# Cluster scope | ||
|
||
|
||
def exists(profile): | ||
return True | ||
|
||
|
||
def start(profile, verbose=False): | ||
start = time.monotonic() | ||
logging.info("[%s] Checking external cluster status", profile["name"]) | ||
|
||
# Fail fast if cluster is not configured, we cannot recover from this. | ||
status = cluster.status(profile["name"]) | ||
if status == cluster.UNKNOWN: | ||
raise RuntimeError(f"Cluster '{profile['name']}' does not exist") | ||
|
||
# Otherwise handle temporary outage gracefuly. | ||
cluster.wait_until_ready(profile["name"], timeout=60, log=logging.debug) | ||
|
||
logging.info( | ||
"[%s] Cluster ready in %.2f seconds", | ||
profile["name"], | ||
time.monotonic() - start, | ||
) | ||
|
||
|
||
def configure(profile, existing=False): | ||
logging.info("[%s] Skipping configure for external cluster", profile["name"]) | ||
|
||
|
||
def stop(profile): | ||
logging.info("[%s] Skipping stop for external cluster", profile["name"]) | ||
|
||
|
||
def delete(profile): | ||
logging.info("[%s] Skipping delete for external cluster", profile["name"]) | ||
|
||
|
||
def suspend(profile): | ||
logging.info("[%s] Skipping suspend for external cluster", profile["name"]) | ||
|
||
|
||
def resume(profile): | ||
logging.info("[%s] Skipping resume for external cluster", profile["name"]) | ||
|
||
|
||
def cp(name, src, dst): | ||
logging.warning("[%s] cp not implemented yet for external cluster", name) | ||
|
||
|
||
def ssh(name, command): | ||
logging.warning("[%s] ssh not implemented yet for external cluster", name) |
This file contains 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