-
Notifications
You must be signed in to change notification settings - Fork 6
feat(longhorn): generalize install for non-AWS providers #270
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
base: main
Are you sure you want to change the base?
Changes from all commits
b798497
87d81bc
eb550c4
22f8642
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 |
|---|---|---|
| @@ -1,5 +1,12 @@ | ||
| package aws | ||
|
|
||
| import "github.com/nebari-dev/nebari-infrastructure-core/pkg/storage/longhorn" | ||
|
|
||
| // LonghornConfig is kept as a package-local alias so existing yaml under | ||
| // `longhorn:` still unmarshals into the same shape; the underlying type now | ||
| // lives in pkg/storage/longhorn so non-AWS providers can share install logic. | ||
| type LonghornConfig = longhorn.Config | ||
|
Contributor
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. Stylistic (re: |
||
|
|
||
| type Config struct { | ||
| Region string `yaml:"region"` | ||
| StateBucket string `yaml:"state_bucket,omitempty"` | ||
|
|
@@ -19,7 +26,7 @@ type Config struct { | |
| NodeGroups map[string]NodeGroup `yaml:"node_groups"` | ||
| Tags map[string]string `yaml:"tags,omitempty"` | ||
| EFS *EFSConfig `yaml:"efs,omitempty"` | ||
| Longhorn *LonghornConfig `yaml:"longhorn,omitempty"` | ||
| Longhorn *longhorn.Config `yaml:"longhorn,omitempty"` | ||
| } | ||
|
|
||
| type NodeGroup struct { | ||
|
|
@@ -41,25 +48,20 @@ type Taint struct { | |
| } | ||
|
|
||
| // LonghornEnabled returns whether Longhorn distributed block storage should | ||
| // be deployed on this AWS cluster. Defaults to true when the Longhorn config | ||
| // is nil or Enabled is not set. | ||
| // be deployed on this AWS cluster. Defaults to true when the Longhorn block | ||
| // is omitted entirely — Longhorn is the AWS storage default. The shared | ||
| // longhorn.Config defaults to disabled-when-nil because non-AWS providers | ||
| // require an explicit opt-in. | ||
| func (c *Config) LonghornEnabled() bool { | ||
| if c.Longhorn == nil { | ||
| return true | ||
| } | ||
| if c.Longhorn.Enabled == nil { | ||
| return true | ||
| } | ||
| return *c.Longhorn.Enabled | ||
| return c.Longhorn.IsEnabled() | ||
| } | ||
|
|
||
| // LonghornReplicaCount returns the number of Longhorn volume replicas. | ||
| // Defaults to 2 when not set. | ||
| func (c *Config) LonghornReplicaCount() int { | ||
| if c.Longhorn == nil || c.Longhorn.ReplicaCount == 0 { | ||
| return 2 | ||
| } | ||
| return c.Longhorn.ReplicaCount | ||
| return c.Longhorn.Replicas() | ||
| } | ||
|
|
||
| type EFSConfig struct { | ||
|
|
@@ -83,10 +85,3 @@ func (c *Config) EFSStorageClassName() string { | |
| } | ||
| return c.EFS.StorageClassName | ||
| } | ||
|
|
||
| type LonghornConfig struct { | ||
| Enabled *bool `yaml:"enabled,omitempty"` | ||
| ReplicaCount int `yaml:"replica_count,omitempty"` | ||
| DedicatedNodes bool `yaml:"dedicated_nodes,omitempty"` | ||
| NodeSelector map[string]string `yaml:"node_selector,omitempty"` | ||
| } | ||
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.
Question. The comment says this alias exists "so existing yaml under
longhorn:still unmarshals into the same shape", but YAML shape comes from the struct tags onlonghorn.Configdirectly - the alias isn't required for unmarshaling and isn't referenced outside tests. Looks like dead surface area; consider removing.