File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
src/codeflare_sdk/cluster Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 21
21
22
22
import abc
23
23
import openshift as oc
24
+ from openshift import OpenShiftPythonException
24
25
25
26
26
27
class Authentication (metaclass = abc .ABCMeta ):
@@ -61,13 +62,25 @@ def __init__(
61
62
self .token = token
62
63
self .server = server
63
64
64
- def login (self ):
65
+ def login (self , skip_tls = False ):
65
66
"""
66
67
This function is used to login to an OpenShift cluster using the user's API token and API server address.
68
+ Depending on the cluster, a user can choose to login in with "--insecure-skip-tls-verify` by setting `skip_tls`
69
+ to `True`.
67
70
"""
68
71
token = self .token
69
72
server = self .server
70
- response = oc .invoke ("login" , [f"--token={ token } " , f"--server={ server } :6443" ])
73
+ args = [f"--token={ token } " , f"--server={ server } :6443" ]
74
+ if skip_tls :
75
+ args .append ("--insecure-skip-tls-verify" )
76
+ try :
77
+ response = oc .invoke ("login" , args )
78
+ except OpenShiftPythonException as osp :
79
+ error_msg = osp .result .err ()
80
+ if "The server uses a certificate signed by unknown authority" in error_msg :
81
+ return "Error: certificate auth failure, please set `skip_tls=True` in your cluster config"
82
+ else :
83
+ return error_msg
71
84
return response .out ()
72
85
73
86
def logout (self ):
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ def up(self):
95
95
Applies the AppWrapper yaml, pushing the resource request onto
96
96
the MCAD queue.
97
97
"""
98
- self .config .auth .login ()
98
+ self .config .auth .login (self . config . skip_tls )
99
99
namespace = self .config .namespace
100
100
with oc .project (namespace ):
101
101
oc .invoke ("apply" , ["-f" , self .app_wrapper_yaml ])
Original file line number Diff line number Diff line change @@ -48,3 +48,4 @@ class ClusterConfiguration:
48
48
envs : dict = field (default_factory = dict )
49
49
image : str = "ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103"
50
50
auth : Authentication = Authentication ()
51
+ skip_tls = False
You can’t perform that action at this time.
0 commit comments