Skip to content

Commit 2238c31

Browse files
Merge pull request #8336 from honza/write-masters-file
METAL-872: baremetal: write masters.json file
2 parents 1593f7f + ec35f88 commit 2238c31

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

cmd/openshift-install/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ func waitForBootstrapComplete(ctx context.Context, config *rest.Config) *cluster
462462
defer cancel()
463463

464464
if platformName == baremetal.Name {
465-
if err := baremetalutils.WaitForBaremetalBootstrapControlPlane(waitCtx, config); err != nil {
465+
if err := baremetalutils.WaitForBaremetalBootstrapControlPlane(waitCtx, config, command.RootOpts.Dir); err != nil {
466466
return newBootstrapError(err)
467467
}
468468
logrus.Infof(" Baremetal control plane finished provisioning.")

pkg/utils/baremetal/bootstrap.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package baremetal
22

33
import (
44
"context"
5+
"encoding/json"
56
"fmt"
7+
"os"
8+
"path/filepath"
69

710
baremetalhost "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
811
"github.com/sirupsen/logrus"
@@ -12,11 +15,13 @@ import (
1215
"k8s.io/client-go/dynamic"
1316
"k8s.io/client-go/rest"
1417
clientwatch "k8s.io/client-go/tools/watch"
18+
19+
"github.com/openshift/installer/pkg/infrastructure/baremetal"
1520
)
1621

1722
// WaitForBaremetalBootstrapControlPlane will watch baremetalhost resources on the bootstrap
1823
// and wait for the control plane to finish provisioning.
19-
func WaitForBaremetalBootstrapControlPlane(ctx context.Context, config *rest.Config) error {
24+
func WaitForBaremetalBootstrapControlPlane(ctx context.Context, config *rest.Config, dir string) error {
2025
client, err := dynamic.NewForConfig(config)
2126
if err != nil {
2227
return fmt.Errorf("creating a baremetal client: %w", err)
@@ -91,5 +96,19 @@ func WaitForBaremetalBootstrapControlPlane(ctx context.Context, config *rest.Con
9196
},
9297
)
9398

94-
return err
99+
if err != nil {
100+
return err
101+
}
102+
103+
mastersJSON, err := json.Marshal(masters)
104+
if err != nil {
105+
return fmt.Errorf("failed to marshal masters: %w", err)
106+
}
107+
108+
err = os.WriteFile(filepath.Join(dir, baremetal.MastersFileName), mastersJSON, 0600)
109+
if err != nil {
110+
return fmt.Errorf("failed to persist masters file to disk: %w", err)
111+
}
112+
113+
return nil
95114
}

0 commit comments

Comments
 (0)