-
Notifications
You must be signed in to change notification settings - Fork 98
use EC kinds for the EC node join response, and include the app version #5274
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 9 commits
e275f99
ad4d376
538ad77
5fbe477
94df539
e99df56
7ae3430
bd731a6
e76aa85
6fb2067
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 |
---|---|---|
|
@@ -5,7 +5,8 @@ import ( | |
"fmt" | ||
"net/http" | ||
|
||
ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1" | ||
"github.com/google/uuid" | ||
"github.com/replicatedhq/embedded-cluster/kinds/types/join" | ||
|
||
"github.com/replicatedhq/kots/pkg/embeddedcluster" | ||
"github.com/replicatedhq/kots/pkg/k8sutil" | ||
|
@@ -19,16 +20,6 @@ type GenerateEmbeddedClusterNodeJoinCommandResponse struct { | |
Command []string `json:"command"` | ||
} | ||
|
||
type GetEmbeddedClusterNodeJoinCommandResponse struct { | ||
ClusterID string `json:"clusterID"` | ||
K0sJoinCommand string `json:"k0sJoinCommand"` | ||
K0sToken string `json:"k0sToken"` | ||
EmbeddedClusterVersion string `json:"embeddedClusterVersion"` | ||
AirgapRegistryAddress string `json:"airgapRegistryAddress"` | ||
TCPConnectionsRequired []string `json:"tcpConnectionsRequired"` | ||
InstallationSpec ecv1beta1.InstallationSpec `json:"installationSpec,omitempty"` | ||
} | ||
|
||
type GenerateEmbeddedClusterNodeJoinCommandRequest struct { | ||
Roles []string `json:"roles"` | ||
} | ||
|
@@ -178,13 +169,41 @@ func (h *Handler) GetEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *ht | |
return | ||
} | ||
|
||
JSON(w, http.StatusOK, GetEmbeddedClusterNodeJoinCommandResponse{ | ||
ClusterID: install.Spec.ClusterID, | ||
clusterUUID, err := uuid.Parse(install.Spec.ClusterID) | ||
if err != nil { | ||
logger.Error(fmt.Errorf("failed to parse cluster id: %w", err)) | ||
w.WriteHeader(http.StatusInternalServerError) | ||
return | ||
} | ||
|
||
var currentAppVersionLabel string | ||
// attempt to get the current app version label from the installed app | ||
installedApps, err := store.GetStore().ListInstalledApps() | ||
if err == nil && len(installedApps) > 0 { | ||
// "CurrentSequence" is the latest available version of the app in a non-embedded cluster. | ||
// However, in an embedded cluster, the "CurrentSequence" is also the currently deployed version of the app. | ||
// This is because EC uses the new upgrade flow, which only creates a new app version when | ||
// the app version gets deployed. And because rollbacks are not supported in embedded cluster yet. | ||
appVersion, err := store.GetStore().GetAppVersion(installedApps[0].ID, installedApps[0].CurrentSequence) | ||
sgalsaleh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
logger.Error(fmt.Errorf("failed to get app version: %w", err)) | ||
w.WriteHeader(http.StatusInternalServerError) | ||
return | ||
} | ||
currentAppVersionLabel = appVersion.VersionLabel | ||
} else { | ||
// if there are no installed apps, we can't get the current app version label | ||
logger.Info("no installed apps found") | ||
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. i think this should fail. same if the list of installed apps != 1 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. You can join nodes before installing an app - or at least that's my understanding of the sequencing 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 app would be installed at this point. the meaning of 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. Gotcha |
||
} | ||
|
||
JSON(w, http.StatusOK, join.JoinCommandResponse{ | ||
ClusterID: clusterUUID, | ||
K0sJoinCommand: k0sJoinCommand, | ||
K0sToken: k0sToken, | ||
EmbeddedClusterVersion: ecVersion, | ||
AirgapRegistryAddress: airgapRegistryAddress, | ||
TCPConnectionsRequired: endpoints, | ||
InstallationSpec: install.Spec, | ||
AppVersionLabel: currentAppVersionLabel, | ||
}) | ||
} |
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 you should fail if
err != nil
here, as that won't fail if there are no apps installed.