MCPcopy
hub / github.com/cortexlabs/cortex / runManagerWithClusterConfig

Function runManagerWithClusterConfig

cli/cmd/lib_manager.go:163–218  ·  view source on GitHub ↗
(entrypoint string, clusterConfig *clusterconfig.Config, awsClient *aws.Client, copyToPaths []dockerCopyToPath, copyFromPaths []dockerCopyFromPath, extraEnvs []string)

Source from the content-addressed store, hash-verified

161}
162
163func runManagerWithClusterConfig(entrypoint string, clusterConfig *clusterconfig.Config, awsClient *aws.Client, copyToPaths []dockerCopyToPath, copyFromPaths []dockerCopyFromPath, extraEnvs []string) (string, *int, error) {
164 clusterConfigBytes, err := yaml.Marshal(clusterConfig)
165 if err != nil {
166 return "", nil, errors.WithStack(err)
167 }
168
169 cachedClusterConfigPath := getCachedClusterConfigPath(clusterConfig.ClusterName, clusterConfig.Region)
170 if err := files.WriteFile(clusterConfigBytes, cachedClusterConfigPath); err != nil {
171 return "", nil, err
172 }
173
174 containerClusterConfigPath := "/in/" + filepath.Base(cachedClusterConfigPath)
175 copyToPaths = append(copyToPaths, dockerCopyToPath{
176 input: &archive.Input{
177 Files: []archive.FileInput{
178 {
179 Source: cachedClusterConfigPath,
180 Dest: containerClusterConfigPath,
181 },
182 },
183 },
184 containerPath: "/",
185 })
186
187 envs := []string{
188 "AWS_ACCESS_KEY_ID=" + *awsClient.AccessKeyID(),
189 "AWS_SECRET_ACCESS_KEY=" + *awsClient.SecretAccessKey(),
190 "CORTEX_TELEMETRY_DISABLE=" + os.Getenv("CORTEX_TELEMETRY_DISABLE"),
191 "CORTEX_TELEMETRY_SENTRY_DSN=" + os.Getenv("CORTEX_TELEMETRY_SENTRY_DSN"),
192 "CORTEX_TELEMETRY_SEGMENT_WRITE_KEY=" + os.Getenv("CORTEX_TELEMETRY_SEGMENT_WRITE_KEY"),
193 "CORTEX_DEV_DEFAULT_IMAGE_REGISTRY=" + os.Getenv("CORTEX_DEV_DEFAULT_IMAGE_REGISTRY"),
194 "CORTEX_DEV_ADD_CONTROL_PLANE_DASHBOARD=" + os.Getenv("CORTEX_DEV_ADD_CONTROL_PLANE_DASHBOARD"),
195 "CORTEX_CLUSTER_CONFIG_FILE=" + containerClusterConfigPath,
196 }
197 envs = append(envs, extraEnvs...)
198 containerConfig := &container.Config{
199 Image: clusterConfig.ImageManager,
200 Entrypoint: []string{"/bin/bash", "-c"},
201 Cmd: []string{fmt.Sprintf("eval $(python /root/cluster_config_env.py %s) && %s", containerClusterConfigPath, entrypoint)},
202 Tty: true,
203 AttachStdout: true,
204 AttachStderr: true,
205 Env: envs,
206 }
207
208 if sessionToken := awsClient.SessionToken(); sessionToken != nil {
209 containerConfig.Env = append(containerConfig.Env, "AWS_SESSION_TOKEN="+*sessionToken)
210 }
211
212 output, exitCode, err := runManager(containerConfig, false, copyToPaths, copyFromPaths)
213 if err != nil {
214 return "", nil, err
215 }
216
217 return output, exitCode, nil
218}
219
220func runManagerAccessCommand(entrypoint string, accessConfig clusterconfig.AccessConfig, awsClient *aws.Client, copyToPaths []dockerCopyToPath, copyFromPaths []dockerCopyFromPath) (string, *int, error) {

Callers 1

cluster.goFile · 0.85

Calls 7

WithStackFunction · 0.92
WriteFileFunction · 0.92
runManagerFunction · 0.85
AccessKeyIDMethod · 0.80
SecretAccessKeyMethod · 0.80
SessionTokenMethod · 0.80

Tested by

no test coverage detected