Skip to content

Commit 155f9d2

Browse files
authored
Merge branch 'master' into check-before-pull
2 parents 9d5e877 + 30c33c3 commit 155f9d2

File tree

1,596 files changed

+123906
-69276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,596 files changed

+123906
-69276
lines changed

.ci-operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build_root_image:
22
name: release
33
namespace: openshift
4-
tag: rhel-8-release-golang-1.19-openshift-4.12
4+
tag: rhel-8-release-golang-1.19-openshift-4.13

cmd/openshift-install/agent.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var (
5656
}
5757

5858
agentImageTarget = target{
59-
name: "Image",
59+
name: "Agent ISO Image",
6060
command: &cobra.Command{
6161
Use: "image",
6262
Short: "Generates a bootable image containing all the information needed to deploy a cluster",
@@ -69,7 +69,21 @@ var (
6969
},
7070
}
7171

72-
agentTargets = []target{agentConfigTarget, agentManifestsTarget, agentImageTarget}
72+
agentPXEFilesTarget = target{
73+
name: "Agent PXE Files",
74+
command: &cobra.Command{
75+
Use: "pxe-files",
76+
Short: "Generates PXE bootable image files containing all the information needed to deploy a cluster",
77+
Args: cobra.ExactArgs(0),
78+
},
79+
assets: []asset.WritableAsset{
80+
&image.AgentPXEFiles{},
81+
&kubeconfig.AgentAdminClient{},
82+
&password.KubeadminPassword{},
83+
},
84+
}
85+
86+
agentTargets = []target{agentConfigTarget, agentManifestsTarget, agentImageTarget, agentPXEFilesTarget}
7387
)
7488

7589
func newAgentCreateCmd() *cobra.Command {

cmd/openshift-install/agent/waitfor.go

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package agent
22

33
import (
4+
"context"
5+
46
"github.com/pkg/errors"
57
"github.com/sirupsen/logrus"
68
"github.com/spf13/cobra"
@@ -31,6 +33,19 @@ func NewWaitForCmd() *cobra.Command {
3133
return cmd
3234
}
3335

36+
func handleBootstrapError(cluster *agentpkg.Cluster, err error) {
37+
logrus.Debug("Printing the event list gathered from the Agent Rest API")
38+
cluster.PrintInfraEnvRestAPIEventList()
39+
err2 := cluster.API.OpenShift.LogClusterOperatorConditions()
40+
if err2 != nil {
41+
logrus.Error("Attempted to gather ClusterOperator status after wait failure: ", err2)
42+
}
43+
logrus.Info("Use the following commands to gather logs from the cluster")
44+
logrus.Info("openshift-install gather bootstrap --help")
45+
logrus.Error(errors.Wrap(err, "Bootstrap failed to complete: "))
46+
logrus.Exit(exitCodeBootstrapFailed)
47+
}
48+
3449
func newWaitForBootstrapCompleteCmd() *cobra.Command {
3550
return &cobra.Command{
3651
Use: "bootstrap-complete",
@@ -42,19 +57,16 @@ func newWaitForBootstrapCompleteCmd() *cobra.Command {
4257
if len(assetDir) == 0 {
4358
logrus.Fatal("No cluster installation directory found")
4459
}
45-
cluster, err := agentpkg.WaitForBootstrapComplete(assetDir)
60+
61+
ctx := context.Background()
62+
cluster, err := agentpkg.NewCluster(ctx, assetDir)
4663
if err != nil {
47-
logrus.Debug("Printing the event list gathered from the Agent Rest API")
48-
cluster.PrintInfraEnvRestAPIEventList()
49-
err2 := cluster.API.OpenShift.LogClusterOperatorConditions()
50-
if err2 != nil {
51-
logrus.Error("Attempted to gather ClusterOperator status after wait failure: ", err2)
52-
}
53-
logrus.Info("Use the following commands to gather logs from the cluster")
54-
logrus.Info("openshift-install gather bootstrap --help")
55-
logrus.Error(errors.Wrap(err, "Bootstrap failed to complete: "))
5664
logrus.Exit(exitCodeBootstrapFailed)
5765
}
66+
67+
if err := agentpkg.WaitForBootstrapComplete(cluster); err != nil {
68+
handleBootstrapError(cluster, err)
69+
}
5870
},
5971
}
6072
}
@@ -70,10 +82,19 @@ func newWaitForInstallCompleteCmd() *cobra.Command {
7082
if len(assetDir) == 0 {
7183
logrus.Fatal("No cluster installation directory found")
7284
}
73-
cluster, err := agentpkg.WaitForInstallComplete(assetDir)
85+
86+
ctx := context.Background()
87+
cluster, err := agentpkg.NewCluster(ctx, assetDir)
7488
if err != nil {
75-
logrus.Debug("Printing the event list gathered from the Agent Rest API")
76-
cluster.PrintInfraEnvRestAPIEventList()
89+
logrus.Exit(exitCodeBootstrapFailed)
90+
}
91+
92+
if err := agentpkg.WaitForBootstrapComplete(cluster); err != nil {
93+
handleBootstrapError(cluster, err)
94+
}
95+
96+
if err = agentpkg.WaitForInstallComplete(cluster); err != nil {
97+
logrus.Error(err)
7798
err2 := cluster.API.OpenShift.LogClusterOperatorConditions()
7899
if err2 != nil {
79100
logrus.Error("Attempted to gather ClusterOperator status after wait failure: ", err2)

cmd/openshift-install/agent_internal_integration_test.go

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,27 @@ func runIntegrationTest(t *testing.T, testFolder string) {
103103
},
104104

105105
Cmds: map[string]func(*testscript.TestScript, bool, []string){
106-
"isocmp": isoCmp,
106+
"isocmp": isoCmp,
107+
"ignitionImgContains": ignitionImgContains,
107108
},
108109
})
109110
}
110111

112+
// [!] ignitionImgContains `isoPath` `file` check if the specified file `file`
113+
// is stored within /images/ignition.img archive in the ISO `isoPath` image.
114+
func ignitionImgContains(ts *testscript.TestScript, neg bool, args []string) {
115+
if len(args) != 2 {
116+
ts.Fatalf("usage: ignitionImgContains isoPath file")
117+
}
118+
119+
workDir := ts.Getenv("WORK")
120+
isoPath, eFilePath := args[0], args[1]
121+
isoPathAbs := filepath.Join(workDir, isoPath)
122+
123+
_, err := extractFileFromIgnitionImg(isoPathAbs, eFilePath)
124+
ts.Check(err)
125+
}
126+
111127
// [!] isoCmp `isoPath` `isoFile` `expectedFile` check that the content of the file
112128
// `isoFile` - extracted from the ISO embedded ignition configuration file referenced
113129
// by `isoPath` - matches the content of the local file `expectedFile`.
@@ -120,7 +136,7 @@ func isoCmp(ts *testscript.TestScript, neg bool, args []string) {
120136
isoPath, aFilePath, eFilePath := args[0], args[1], args[2]
121137
isoPathAbs := filepath.Join(workDir, isoPath)
122138

123-
aData, err := readFileFromISO(isoPathAbs, aFilePath)
139+
aData, err := readFileFromISOIgnitionCfg(isoPathAbs, aFilePath)
124140
ts.Check(err)
125141

126142
eFilePathAbs := filepath.Join(workDir, eFilePath)
@@ -152,8 +168,8 @@ func isoCmp(ts *testscript.TestScript, neg bool, args []string) {
152168
ts.Fatalf("%s and %s differ", aFilePath, eFilePath)
153169
}
154170

155-
func readFileFromISO(isoPath string, nodePath string) ([]byte, error) {
156-
config, err := readIgnitionFromISO(isoPath)
171+
func readFileFromISOIgnitionCfg(isoPath string, nodePath string) ([]byte, error) {
172+
config, err := extractIgnitionCfg(isoPath)
157173
if err != nil {
158174
return nil, err
159175
}
@@ -171,7 +187,7 @@ func readFileFromISO(isoPath string, nodePath string) ([]byte, error) {
171187
return nil, errors.NotFound(nodePath)
172188
}
173189

174-
func readIgnitionFromISO(isoPath string) (*igntypes.Config, error) {
190+
func extractFileFromIgnitionImg(isoPath string, fileName string) ([]byte, error) {
175191
disk, err := diskfs.OpenWithMode(isoPath, diskfs.ReadOnly)
176192
if err != nil {
177193
return nil, err
@@ -193,12 +209,31 @@ func readIgnitionFromISO(isoPath string) (*igntypes.Config, error) {
193209
}
194210

195211
cpioReader := cpio.NewReader(gzipReader)
196-
_, err = cpioReader.Next()
197-
if err != nil {
198-
return nil, err
212+
213+
for {
214+
header, err := cpioReader.Next()
215+
if err == io.EOF { //nolint:errorlint
216+
// end of cpio archive
217+
break
218+
}
219+
if err != nil {
220+
return nil, err
221+
}
222+
223+
if header.Name == fileName {
224+
rawContent, err := io.ReadAll(cpioReader)
225+
if err != nil {
226+
return nil, err
227+
}
228+
return rawContent, nil
229+
}
199230
}
200231

201-
rawContent, err := io.ReadAll(cpioReader)
232+
return nil, errors.NotFound(fmt.Sprintf("File %s not found within the /images/ignition.img archive", fileName))
233+
}
234+
235+
func extractIgnitionCfg(isoPath string) (*igntypes.Config, error) {
236+
rawContent, err := extractFileFromIgnitionImg(isoPath, "config.ign")
202237
if err != nil {
203238
return nil, err
204239
}

cmd/openshift-install/create.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
configclient "github.com/openshift/client-go/config/clientset/versioned"
2828
routeclient "github.com/openshift/client-go/route/clientset/versioned"
2929
"github.com/openshift/installer/pkg/asset"
30+
"github.com/openshift/installer/pkg/asset/agent/agentconfig"
3031
"github.com/openshift/installer/pkg/asset/cluster"
3132
"github.com/openshift/installer/pkg/asset/installconfig"
3233
"github.com/openshift/installer/pkg/asset/logging"
@@ -299,7 +300,7 @@ func runTargetCmd(targets ...asset.WritableAsset) func(cmd *cobra.Command, args
299300
logrus.Fatal(err)
300301
}
301302
switch cmd.Name() {
302-
case "cluster", "image":
303+
case "cluster", "image", "pxe-files":
303304
default:
304305
logrus.Infof(logging.LogCreatedFiles(cmd.Name(), rootOpts.dir, targets))
305306
}
@@ -376,6 +377,11 @@ func waitForBootstrapComplete(ctx context.Context, config *rest.Config) *cluster
376377
silenceRemaining := logDownsample
377378
previousErrorSuffix := ""
378379
timer.StartTimer("API")
380+
381+
if assetStore, err := assetstore.NewStore(rootOpts.dir); err == nil {
382+
checkIfAgentCommand(assetStore)
383+
}
384+
379385
var lastErr error
380386
wait.Until(func() {
381387
version, err := discovery.ServerVersion()
@@ -475,6 +481,8 @@ func waitForInitializedCluster(ctx context.Context, config *rest.Config) error {
475481
timeout = 60 * time.Minute
476482
}
477483
}
484+
485+
checkIfAgentCommand(assetStore)
478486
}
479487

480488
untilTime := time.Now().Add(timeout)
@@ -638,3 +646,9 @@ The cluster should be accessible for troubleshooting as detailed in the document
638646
https://docs.openshift.com/container-platform/latest/support/troubleshooting/troubleshooting-installations.html
639647
The 'wait-for install-complete' subcommand can then be used to continue the installation`)
640648
}
649+
650+
func checkIfAgentCommand(assetStore asset.Store) {
651+
if agentConfig, err := assetStore.Load(&agentconfig.AgentConfig{}); err == nil && agentConfig != nil {
652+
logrus.Warning("An agent configuration was detected but this command is not the agent wait-for command")
653+
}
654+
}

cmd/openshift-install/destroy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func newDestroyClusterCmd() *cobra.Command {
5555
if err != nil {
5656
logrus.Fatal(err)
5757
}
58+
logrus.Infof("Uninstallation complete!")
5859
},
5960
}
6061
}

cmd/openshift-install/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/pkg/errors"
1010
"github.com/sirupsen/logrus"
1111
"github.com/spf13/cobra"
12-
"golang.org/x/crypto/ssh/terminal"
12+
terminal "golang.org/x/term"
1313
"k8s.io/klog"
1414
klogv2 "k8s.io/klog/v2"
1515
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Verify that the most relevant assets are properly generated in the ISO
2+
3+
exec openshift-install agent create image --dir $WORK
4+
5+
exists $WORK/agent.x86_64.iso
6+
7+
ignitionImgContains agent.x86_64.iso config.ign
8+
ignitionImgContains agent.x86_64.iso agent
9+
10+
-- install-config.yaml --
11+
apiVersion: v1
12+
baseDomain: test.metalkube.org
13+
controlPlane:
14+
name: master
15+
replicas: 1
16+
compute:
17+
- name: worker
18+
replicas: 0
19+
metadata:
20+
namespace: cluster0
21+
name: ostest
22+
networking:
23+
clusterNetwork:
24+
- cidr: 10.128.0.0/14
25+
hostPrefix: 23
26+
networkType: OVNKubernetes
27+
machineNetwork:
28+
- cidr: 192.168.111.0/24
29+
serviceNetwork:
30+
- 172.30.0.0/16
31+
platform:
32+
none: {}
33+
sshKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDK6UTEydcEKzuNdPaofn8Z2DwgHqdcionLZBiPf/zIRNco++etLsat7Avv7yt04DINQd5zjxIFgG8jblaUB5E5C9ClUcMwb52GO0ay2Y9v1uBv1a4WhI3peKktAzYNk0EBMQlJtXPjRMrC9ylBPh+DsBHMu+KmDnfk7PIwyN4efC8k5kSRuPWoNdme1rz2+umU8FSmaWTHIajrbspf4GQbsntA5kuKEtDbfoNCU97o2KrRnUbeg3a8hwSjfh3u6MhlnGcg5K2Ij+zivEsWGCLKYUtE1ErqwfIzwWmJ6jnV66XCQGHf4Q1iIxqF7s2a1q24cgG2Z/iDXfqXrCIfy4P7b/Ztak3bdT9jfAdVZtdO5/r7I+O5hYhF86ayFlDWzZWP/ByiSb+q4CQbfVgK3BMmiAv2MqLHdhesmD/SmIcoOWUF6rFmRKZVFFpKpt5ATNTgUJ3JRowoXrrDruVXClUGRiCS6Zabd1rZ3VmTchaPJwtzQMdfIWISXj+Ig+C4UK0=
34+
pullSecret: '{"auths": {"quay.io": {"auth": "c3VwZXItc2VjcmV0Cg=="}}}'
35+
36+
-- agent-config.yaml --
37+
apiVersion: v1alpha1
38+
metadata:
39+
name: ostest
40+
namespace: cluster0
41+
rendezvousIP: 192.168.111.20
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Verify a default configuration for the compact topology on vsphere
2+
3+
exec openshift-install agent create image --dir $WORK
4+
5+
stderr 'The rendezvous host IP \(node0 IP\) is 192.168.111.20'
6+
7+
exists $WORK/agent.x86_64.iso
8+
exists $WORK/auth/kubeconfig
9+
exists $WORK/auth/kubeadmin-password
10+
11+
-- install-config.yaml --
12+
apiVersion: v1
13+
baseDomain: test.metalkube.org
14+
controlPlane:
15+
name: master
16+
replicas: 3
17+
compute:
18+
- name: worker
19+
replicas: 0
20+
metadata:
21+
namespace: cluster0
22+
name: ostest
23+
networking:
24+
clusterNetwork:
25+
- cidr: 10.128.0.0/14
26+
hostPrefix: 23
27+
networkType: OVNKubernetes
28+
machineNetwork:
29+
- cidr: 192.168.111.0/24
30+
serviceNetwork:
31+
- 172.30.0.0/16
32+
platform:
33+
vsphere:
34+
apiVips:
35+
- 192.168.111.5
36+
ingressVips:
37+
- 192.168.111.4
38+
sshKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDK6UTEydcEKzuNdPaofn8Z2DwgHqdcionLZBiPf/zIRNco++etLsat7Avv7yt04DINQd5zjxIFgG8jblaUB5E5C9ClUcMwb52GO0ay2Y9v1uBv1a4WhI3peKktAzYNk0EBMQlJtXPjRMrC9ylBPh+DsBHMu+KmDnfk7PIwyN4efC8k5kSRuPWoNdme1rz2+umU8FSmaWTHIajrbspf4GQbsntA5kuKEtDbfoNCU97o2KrRnUbeg3a8hwSjfh3u6MhlnGcg5K2Ij+zivEsWGCLKYUtE1ErqwfIzwWmJ6jnV66XCQGHf4Q1iIxqF7s2a1q24cgG2Z/iDXfqXrCIfy4P7b/Ztak3bdT9jfAdVZtdO5/r7I+O5hYhF86ayFlDWzZWP/ByiSb+q4CQbfVgK3BMmiAv2MqLHdhesmD/SmIcoOWUF6rFmRKZVFFpKpt5ATNTgUJ3JRowoXrrDruVXClUGRiCS6Zabd1rZ3VmTchaPJwtzQMdfIWISXj+Ig+C4UK0=
39+
pullSecret: '{"auths": {"quay.io": {"auth": "c3VwZXItc2VjcmV0Cg=="}}}'
40+
41+
-- agent-config.yaml --
42+
apiVersion: v1alpha1
43+
metadata:
44+
name: ostest
45+
namespace: cluster0
46+
rendezvousIP: 192.168.111.20

0 commit comments

Comments
 (0)