-
Notifications
You must be signed in to change notification settings - Fork 2
Add workspaces_enabled toggle to gate the control-room workspaces step #364
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,9 @@ package steps | |
| import ( | ||
| "context" | ||
| "fmt" | ||
| "log/slog" | ||
|
|
||
| "github.com/posit-dev/ptd/lib/helpers" | ||
| "github.com/posit-dev/ptd/lib/types" | ||
| ) | ||
|
|
||
|
|
@@ -38,6 +40,28 @@ func (s *WorkspacesStep) Run(ctx context.Context) error { | |
| return fmt.Errorf("workspaces step can only be run on control room targets") | ||
| } | ||
|
|
||
| // The AWS WorkSpaces environment is opt-out per control room via the | ||
| // `workspaces_enabled` config toggle (default on). When a control room sets | ||
| // `workspaces_enabled: false`, the whole step is a no-op. This gate is loaded and | ||
| // evaluated before any credential fetch or Pulumi stack creation so it applies to | ||
| // BOTH the apply and destroy paths: a `--destroy` on a control room that has the | ||
| // toggle off is also a no-op (once the stack has been destroyed it stays gone). | ||
| // Config is loaded the same way runAWSInlineGo loads it (helpers.ConfigForTarget + | ||
| // type-assert to AWSControlRoomConfig), which is the only control-room config kind. | ||
| rawConfig, err := helpers.ConfigForTarget(s.DstTarget) | ||
| if err != nil { | ||
| return fmt.Errorf("workspaces: failed to load config: %w", err) | ||
| } | ||
| cfg, ok := rawConfig.(types.AWSControlRoomConfig) | ||
| if !ok { | ||
| return fmt.Errorf("workspaces: expected AWSControlRoomConfig, got %T", rawConfig) | ||
| } | ||
| if !cfg.WorkspacesIsEnabled() { | ||
| slog.Info("skipping workspaces step: workspaces_enabled is false for this control room", | ||
| "target", s.DstTarget.Name()) | ||
| return nil | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The destroy path has a silent-orphan risk: if a control room already has an active WorkSpaces Pulumi stack (real AWS resources) and someone then sets The comment says "once the stack has been destroyed it stays gone", which assumes the operator already tore down before toggling, but that ordering isn't enforced. Consider at minimum a warning log when if !cfg.WorkspacesIsEnabled() {
if s.Options.Destroy {
slog.Warn("workspaces step disabled but --destroy was requested; existing WorkSpaces stack will NOT be destroyed",
"target", s.DstTarget.Name())
} else {
slog.Info("skipping workspaces step: workspaces_enabled is false for this control room",
"target", s.DstTarget.Name())
}
return nil
} |
||
|
|
||
| creds, err := s.DstTarget.Credentials(ctx) | ||
| if err != nil { | ||
| return err | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,24 @@ type AWSControlRoomConfig struct { | |
| TraefikForwardAuthVersion string `json:"traefik_forward_auth_version" yaml:"traefik_forward_auth_version"` | ||
| TraefikVersion string `json:"traefik_version" yaml:"traefik_version"` | ||
| EbsCsiAddonVersion string `json:"ebs_csi_addon_version" yaml:"ebs_csi_addon_version"` | ||
| // WorkspacesEnabled toggles the AWS WorkSpaces (control-room `workspaces`) step. | ||
| // It is a pointer so an absent field can be distinguished from an explicit false. | ||
| // The historical behavior is always-on, so an unset value (nil) must resolve to | ||
| // true; only an explicit `workspaces_enabled: false` disables the step. Resolve | ||
| // via WorkspacesIsEnabled (nil → true). | ||
| WorkspacesEnabled *bool `json:"workspaces_enabled" yaml:"workspaces_enabled"` | ||
| } | ||
|
|
||
| // WorkspacesIsEnabled resolves the WorkspacesEnabled flag (default true). Returns | ||
| // true when the field is unset (nil) or explicitly true; returns false only when | ||
| // WorkspacesEnabled is explicitly set to false. The nil → true default preserves | ||
| // the historical always-on behavior of the AWS WorkSpaces step, mirroring how | ||
| // EKSAccessEntriesConfig.IsEnabled treats an absent flag as enabled. | ||
| func (c AWSControlRoomConfig) WorkspacesIsEnabled() bool { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor inconsistency with |
||
| if c.WorkspacesEnabled == nil { | ||
| return true | ||
| } | ||
| return *c.WorkspacesEnabled | ||
| } | ||
|
|
||
| // The following accessor methods return the value from config, or the Python | ||
|
|
||
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.
runAWSInlineGo(inworkspaces_aws.go:49-56) does the exact sameConfigForTarget+ type-assert, so the config is parsed twice on the apply path. The struct is cheap to parse, so this isn't a performance issue, but it's a consistency hazard: if the type-assert error message or the config-load error format ever diverges between the two call sites, debugging gets confusing.Not blocking, but worth noting if this pattern gets copied further.