Skip to content
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

Always treat an etcd backend as joinable #5437

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions pkg/apis/k0s/v1beta1/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,17 @@ func DefaultStorageSpec() *StorageSpec {
func (s *StorageSpec) IsJoinable() bool {
switch s.Type {
case EtcdStorageType:
return !s.Etcd.IsExternalClusterUsed()
// Controllers will always be able to connect to an etcd backend, either
// by joining as a managed etcd node, or by simply connecting to an
// external cluster over the network.
return true

case KineStorageType:
return s.Kine.IsJoinable()
}

return false
default:
return false
}
}

// UnmarshalJSON sets in some sane defaults when unmarshaling the data from json
Expand Down Expand Up @@ -211,18 +216,24 @@ func (k *KineConfig) IsJoinable() bool {

switch backend {
case "sqlite":
// An sqlite backend is only available via the file system.
return false

case "nats":
if u, err := url.Parse(dsn); err == nil {
if q, err := url.ParseQuery(u.RawQuery); err == nil {
// If it's not an embedded NATS, other controllers may
// also be able to connect to it over the network.
return q.Has("noEmbed")
}
}
return false
}

return true
default:
// The assumption is that all other backends will
// somehow be reachable over the network.
return true
}
}

// GetEndpointsAsString returns comma-separated list of external cluster endpoints if exist
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/k0s/v1beta1/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestStorageSpec_IsJoinable(t *testing.T) {
PeerAddress: "",
},
},
want: false,
want: true,
},
{
name: "kine-sqlite",
Expand Down
Loading