Skip to content

Commit

Permalink
Revert "NO-ISSUE: better handle pull secret or file of pull secret (#…
Browse files Browse the repository at this point in the history
…2561)" (#2566)

This reverts commit fee7791.
  • Loading branch information
eifrach authored Nov 17, 2024
1 parent ab350a6 commit d985a9c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 47 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ BASE_DOMAIN := $(or $(BASE_DOMAIN),redhat.com)

# secrets
SSH_PUB_KEY := $(or $(SSH_PUB_KEY),$(shell cat ~/.ssh/id_rsa.pub))
PULL_SECRET := $(or $(PULL_SECRET), $(shell if ! [ -z "${PULL_SECRET_FILE}" ];then cat ${PULL_SECRET_FILE};fi))
ROUTE53_SECRET := $(or $(ROUTE53_SECRET), "")
OFFLINE_TOKEN := $(or $(OFFLINE_TOKEN), "")
SERVICE_ACCOUNT_CLIENT_ID := $(or $(SERVICE_ACCOUNT_CLIENT_ID), "")
Expand Down
1 change: 0 additions & 1 deletion skipper.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
VSPHERE_PARENT_FOLDER
VSPHERE_FOLDER
PULL_SECRET
PULL_SECRET_FILE
SECOND_PULL_SECRET
NUM_WORKERS
SSH_PUB_KEY
Expand Down
56 changes: 10 additions & 46 deletions src/assisted_test_infra/test_infra/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,7 @@ def run_command(command, shell=False, raise_errors=True, env=None, cwd=None, run
return

process = subprocess.run(
command,
shell=shell,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
universal_newlines=True,
cwd=cwd,
command, shell=shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, universal_newlines=True, cwd=cwd
)

def _io_buffer_to_str(buf):
Expand Down Expand Up @@ -222,11 +216,7 @@ def get_assisted_service_url_by_args(args, wait=True):
tries=5 if wait else 1,
delay=3,
backoff=2,
exceptions=(
requests.ConnectionError,
requests.ConnectTimeout,
requests.RequestException,
),
exceptions=(requests.ConnectionError, requests.ConnectTimeout, requests.RequestException),
)(get_url)(**kwargs)


Expand Down Expand Up @@ -272,18 +262,13 @@ def is_assisted_service_reachable(url):
try:
r = requests.get(url + "/health", timeout=10, verify=False)
return r.status_code == 200
except (
requests.ConnectionError,
requests.ConnectTimeout,
requests.RequestException,
):
except (requests.ConnectionError, requests.ConnectTimeout, requests.RequestException):
return False


def get_tf_folder(cluster_name, namespace=None):
warnings.warn(
"get_tf_folder is deprecated. Use utils.TerraformControllerUtil.get_folder instead.",
DeprecationWarning,
"get_tf_folder is deprecated. Use utils.TerraformControllerUtil.get_folder instead.", DeprecationWarning
)
folder_name = f"{cluster_name}__{namespace}" if namespace else f"{cluster_name}"
return os.path.join(consts.TF_FOLDER, folder_name)
Expand Down Expand Up @@ -317,11 +302,7 @@ def file_lock_context(filepath="/tmp/src.lock", timeout=300):
try:
lock.acquire()
except filelock.Timeout:
log.info(
"Deleting lock file: %s " "since it exceeded timeout of: %d seconds",
filepath,
timeout,
)
log.info("Deleting lock file: %s " "since it exceeded timeout of: %d seconds", filepath, timeout)
os.unlink(filepath)
lock.acquire()

Expand Down Expand Up @@ -366,11 +347,7 @@ def extract_nodes_from_tf_state(tf_state, network_names, role):
if nic["network_name"] not in network_names:
continue

data[nic["mac"]] = {
"ip": nic["addresses"],
"name": d["attributes"]["name"],
"role": role,
}
data[nic["mac"]] = {"ip": nic["addresses"], "name": d["attributes"]["name"], "role": role}

return data

Expand All @@ -387,12 +364,7 @@ def touch(path):
os.utime(path, None)


def config_etc_hosts(
cluster_name: str,
base_dns_domain: str,
api_vip: str = None,
ingress_vip: str = None,
):
def config_etc_hosts(cluster_name: str, base_dns_domain: str, api_vip: str = None, ingress_vip: str = None):
suffix = f"{cluster_name}.{base_dns_domain}"

dns = {}
Expand Down Expand Up @@ -568,16 +540,13 @@ def get_openshift_release_image(allow_default=True):

@contextmanager
def pull_secret_file():
if os.environ.get("PULL_SECRET_FILE") is None:
pull_secret = os.environ.get("PULL_SECRET")
else:
with open(os.environ.get("PULL_SECRET_FILE"), "r") as f:
pull_secret = f.read()
pull_secret = os.environ.get("PULL_SECRET")

try:
json.loads(pull_secret)
except json.JSONDecodeError as e:
raise ValueError("Value of PULL_SECRET environment variable is not a valid JSON payload") from e

with tempfile.NamedTemporaryFile(mode="w") as f:
f.write(pull_secret)
f.flush()
Expand All @@ -604,12 +573,7 @@ def fetch_url(url, timeout=60, max_retries=5):
Raises an exception in case of any failure.
"""
try:
retries = Retry(
read=max_retries,
status=max_retries,
backoff_factor=0.5,
status_forcelist=[500],
)
retries = Retry(read=max_retries, status=max_retries, backoff_factor=0.5, status_forcelist=[500])
s = Session()
s.mount("http://", HTTPAdapter(max_retries=retries))

Expand Down

0 comments on commit d985a9c

Please sign in to comment.