-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ws-deployment] Prelim checkin to create a workspace cluster using cli #6338
Conversation
The execution is failing with error:
I am fixing this |
The PR does its job. I could trigger a ws cluster creation from my local env which eventually failed due to helm provider failing to install cert manager:
I am updating the ops repo branch with some tf module changes. Once they are done, this CLI would be fully operational. |
// MetaClusters is optional as we may not want to register the cluster | ||
MetaClusters []*common.MetaCluster `yaml:"metaClusters"` | ||
WorkspaceClusters []*common.WorkspaceCluster `yaml:"workspaceClusters"` | ||
// TODO(princerachit): Add gitpod version here when we decide to use installed instead of relying solely on ops repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not rely on the ops repo at all, but use the Gitpod version/version manifest/installer image directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Since these changes are only for cluster creation purpose and not gitpod installation, I have not added it here yet. It will be part of next set of changes.
commandToRun := fmt.Sprintf("cd %s && terraform init && terraform apply -auto-approve", tfModulesDir) | ||
err := runner.ShellRunWithDefaultConfig("/bin/sh", []string{"-c", commandToRun}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point I think we might want to introduce a bit of execution infrastructure akin to leeway (executeCommandForPackage
and how it's used). There we first build up a set of commands and then execute them one after the other. Benefits:
- the code is easy to read because you can write the entire recipe in one function without needing to deal with the intricacies of things going wrong (mostly you're just building string arrays)
- adding a debug log that prints the commands you execute is easy
- if all modifications happen as part of this execution mechanism adding a dry run is easy enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should introduce this but not at this point in time. These are improvements that we should be iterating on. I don't want this PR to become one big feature branch before we merge it.
I would rather have working code and then stitch the missing pieces later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree - we don't want to blow this up. Chances are we'll be running a lot of code execution though. Hence we could try and follow a pattern where the individual steps produce a list of commands which get executed at the end.
We don't need fancy reporter infrastructure, just something like:
func createCluster() error {
var commands [][]string
commands = append(commands, []string{DefaultTFModuleGeneratorScriptPath, "-l", cfg.Region, "-n", cfg.Name})
commands = append(commands, []string{"terraform", "init"})
commands = append(commands, []string{"terraform", "apply", "--approve"})
return runCommands(wd, commands)
}
That's very similar to what you've started with the "runner"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to make this change. It feels going back to the discussion of introducing structures.
Once we have at least the gitpod installation step working (which will be a good way of knowing what is going to be repeated and the patterns we discover) I would be happy to introduce these structures.
Do you see this as a blocker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you see this as a blocker?
No
It feels going back to the discussion of introducing structures.
Not sure - we should not trade on the extreme ends of this spectrum. That said, I'm also fine with going ahead as things are and harmonising afterwards.
For future notice: prior to marking something as ready for approval, please check that the commits could land in main like this. Right now it's 60 commits that clearly need some squashing/authoring :) |
e1c4e10
to
a6102bc
Compare
Codecov Report
@@ Coverage Diff @@
## main #6338 +/- ##
==========================================
- Coverage 19.04% 16.00% -3.05%
==========================================
Files 2 13 +11
Lines 168 1406 +1238
==========================================
+ Hits 32 225 +193
- Misses 134 1162 +1028
- Partials 2 19 +17
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
) | ||
|
||
func Deploy(context *common.ProjectContext, clusters []*common.WorkspaceCluster) error { | ||
var wg sync.WaitGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for future reference (not in this PR): an errgroup might be better suited here to actually fail when the creation of a cluster fails
LGTM label has been added. Git tree hash: 66a8d733374fb2d2e4dc4f7084626f7e20bfe0d6
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: csweichel Associated issue: #6331 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
Related Issue(s)
Fixes #6331
How to test
Release Notes
Documentation