1
0
mirror of https://github.com/openshift/installer.git synced 2026-02-05 15:47:14 +01:00

Add assetDir and kubeconfigPath parameters to NewCluster

NewCluster needs both assetDir for install workflow and
kubeconfigPath for addnodes workflow.

Cluster.assetDir should only be initialized for the install
workflow.
This commit is contained in:
Richard Su
2024-04-15 23:46:36 -04:00
parent 51a57560cf
commit 63c5738cb9
3 changed files with 18 additions and 21 deletions

View File

@@ -2,7 +2,6 @@ package agent
import (
"context"
"path/filepath"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -64,15 +63,8 @@ func newWaitForBootstrapCompleteCmd() *cobra.Command {
logrus.Fatal("No cluster installation directory found")
}
kubeconfigPath := filepath.Join(assetDir, "auth", "kubeconfig")
rendezvousIP, sshKey, err := agentpkg.FindRendezvouIPAndSSHKeyFromAssetStore(assetDir)
if err != nil {
logrus.Exit(exitCodeBootstrapFailed)
}
ctx := context.Background()
cluster, err := agentpkg.NewCluster(ctx, kubeconfigPath, rendezvousIP, sshKey, workflow.AgentWorkflowTypeInstall)
cluster, err := agentpkg.NewCluster(ctx, assetDir, "", "", workflow.AgentWorkflowTypeInstall)
if err != nil {
logrus.Exit(exitCodeBootstrapFailed)
}
@@ -99,15 +91,8 @@ func newWaitForInstallCompleteCmd() *cobra.Command {
logrus.Fatal("No cluster installation directory found")
}
kubeconfigPath := filepath.Join(assetDir, "auth", "kubeconfig")
rendezvousIP, sshKey, err := agentpkg.FindRendezvouIPAndSSHKeyFromAssetStore(assetDir)
if err != nil {
logrus.Exit(exitCodeBootstrapFailed)
}
ctx := context.Background()
cluster, err := agentpkg.NewCluster(ctx, kubeconfigPath, rendezvousIP, sshKey, workflow.AgentWorkflowTypeInstall)
cluster, err := agentpkg.NewCluster(ctx, assetDir, "", "", workflow.AgentWorkflowTypeInstall)
if err != nil {
logrus.Exit(exitCodeBootstrapFailed)
}

View File

@@ -66,11 +66,24 @@ type clusterInstallStatusHistory struct {
}
// NewCluster initializes a Cluster object
func NewCluster(ctx context.Context, kubeconfigPath, rendezvousIP, sshKey string, workflowType workflow.AgentWorkflowType) (*Cluster, error) {
func NewCluster(ctx context.Context, assetDir, rendezvousIP, kubeconfigPath string, workflowType workflow.AgentWorkflowType) (*Cluster, error) {
czero := &Cluster{}
capi := &clientSet{}
var sshKey string
if workflowType == workflow.AgentWorkflowTypeInstall {
kubeconfigPath = filepath.Join(assetDir, "auth", "kubeconfig")
ip, key, err := FindRendezvouIPAndSSHKeyFromAssetStore(assetDir)
if err != nil {
logrus.Fatal(err)
}
rendezvousIP = ip
sshKey = key
czero.assetDir = assetDir
}
restclient, err := NewNodeZeroRestClient(ctx, rendezvousIP, sshKey)
if err != nil {
logrus.Fatal(err)
@@ -114,7 +127,6 @@ func NewCluster(ctx context.Context, kubeconfigPath, rendezvousIP, sshKey string
czero.workflow = workflowType
czero.clusterID = nil
czero.clusterInfraEnvID = nil
czero.assetDir = kubeconfigPath
czero.clusterConsoleRouteURL = ""
czero.installHistory = cinstallstatushistory
czero.installHistory.ValidationResults = cvalidationresults

View File

@@ -11,7 +11,7 @@ import (
// NewMonitorAddNodesCommand creates a new command for monitor add nodes.
func NewMonitorAddNodesCommand(directory, kubeconfigPath string, ips []string) error {
cluster, err := agentpkg.NewCluster(context.Background(), kubeconfigPath, ips[0], "", workflow.AgentWorkflowTypeAddNodes)
cluster, err := agentpkg.NewCluster(context.Background(), "", ips[0], kubeconfigPath, workflow.AgentWorkflowTypeAddNodes)
if err != nil {
// TODO exit code enumerate
logrus.Exit(1)