Skip to content

Commit

Permalink
remove HighAvailabilityMode from the code
Browse files Browse the repository at this point in the history
  • Loading branch information
andrej1991 committed Feb 18, 2025
1 parent ba3d175 commit 3448c65
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 42 deletions.
13 changes: 8 additions & 5 deletions src/commands/actions/install_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,15 @@ func (a *install) getFullInstallerCommand() string {
"--agent-image", a.agentConfig.AgentVersion,
}

if a.installParams.HighAvailabilityMode != nil {
installerCmdArgs = append(installerCmdArgs, "--high-availability-mode", swag.StringValue(a.installParams.HighAvailabilityMode))
}

if a.installParams.ControlPlaneCount != nil {
installerCmdArgs = append(installerCmdArgs, "--control-plane-count", strconv.FormatInt(int64(*a.installParams.ControlPlaneCount), 10))
installerCmdArgs = append(installerCmdArgs, "--control-plane-count", strconv.Itoa(int(*a.installParams.ControlPlaneCount)))
} else {
switch swag.StringValue(a.installParams.HighAvailabilityMode) {
case models.ClusterHighAvailabilityModeFull:
installerCmdArgs = append(installerCmdArgs, "--control-plane-count", "3")
case models.ClusterHighAvailabilityModeNone:
installerCmdArgs = append(installerCmdArgs, "--control-plane-count", "1")
}
}

if a.installParams.McoImage != "" {
Expand Down
66 changes: 30 additions & 36 deletions src/commands/actions/install_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ var _ = Describe("installer test", func() {
hostId := strfmt.UUID("f7ac1860-92cf-4ed8-aeec-2d9f20b35bab")
bootDevice := "/dev/disk/by-path/pci-0000:00:06.0"
return models.InstallCmdRequest{
BootDevice: swag.String(bootDevice),
CheckCvo: swag.Bool(true),
ClusterID: &clusterId,
HostID: &hostId,
InfraEnvID: &infraEnvId,
ControllerImage: swag.String("localhost:5000/edge-infrastructure/assisted-installer-controller:latest"),
DisksToFormat: []string{},
HighAvailabilityMode: swag.String(models.ClusterHighAvailabilityModeFull),
InstallerArgs: "[\"--append-karg\",\"ip=ens3:dhcp\"]",
InstallerImage: swag.String("quay.io/edge-infrastructure/assisted-installer:latest"),
McoImage: "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:3c30f115dc95c3fef94ea5185f386aa1af8a4b5f07ce8f41a17007d54004e1c4",
BootDevice: swag.String(bootDevice),
CheckCvo: swag.Bool(true),
ClusterID: &clusterId,
HostID: &hostId,
InfraEnvID: &infraEnvId,
ControllerImage: swag.String("localhost:5000/edge-infrastructure/assisted-installer-controller:latest"),
DisksToFormat: []string{},
ControlPlaneCount: swag.Int64(3),
InstallerArgs: "[\"--append-karg\",\"ip=ens3:dhcp\"]",
InstallerImage: swag.String("quay.io/edge-infrastructure/assisted-installer:latest"),
McoImage: "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:3c30f115dc95c3fef94ea5185f386aa1af8a4b5f07ce8f41a17007d54004e1c4",
MustGatherImage: "{\"cnv\":\"registry.redhat.io/container-native-virtualization/cnv-must-gather-rhel8:v2.6.5\"," +
"\"lso\":\"registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel8\"," +
"\"ocp\":\"quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:3c30f115dc95c3fef94ea5185f386aa1af8a4b5f07ce8f41a17007d54004e1c4\"," +
Expand Down Expand Up @@ -111,26 +111,13 @@ var _ = Describe("installer test", func() {
"--cluster-id cd781f46-f32a-4154-9670-6442a367ab81 --host-id f7ac1860-92cf-4ed8-aeec-2d9f20b35bab --boot-device /dev/disk/by-path/pci-0000:00:06.0 " +
"--url http://10.1.178.26:6000 --controller-image localhost:5000/edge-infrastructure/assisted-installer-controller:latest " +
"--agent-image quay.io/edge-infrastructure/assisted-installer-agent:latest " +
"--high-availability-mode Full " +
"--control-plane-count 3 " +
"--mco-image quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:3c30f115dc95c3fef94ea5185f386aa1af8a4b5f07ce8f41a17007d54004e1c4 " +
"--must-gather-image '{\"cnv\":\"registry.redhat.io/container-native-virtualization/cnv-must-gather-rhel8:v2.6.5\"," +
"\"lso\":\"registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel8\",\"ocp\":\"quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:3c30f115dc95c3fef94ea5185f386aa1af8a4b5f07ce8f41a17007d54004e1c4\"," +
"\"ocs\":\"registry.redhat.io/ocs4/ocs-must-gather-rhel8\"}' --openshift-version 4.9.24 --insecure --check-cluster-version --installer-args '[\"--append-karg\",\"ip=ens3:dhcp\"]'"))
})

It("ha mode is nil, parameter should be omitted", func() {
installCommandRequest.HighAvailabilityMode = nil
installCommandLineString = getInstallCommandLineString(installCommandRequest)

action := install{args: []string{installCommandLineString}, filesystem: filesystem, agentConfig: agentConfig}
validationError := action.Validate()
Expect(validationError).NotTo(HaveOccurred())

args := action.Args()
argsAsString := strings.Join(args, " ")
Expect(argsAsString).NotTo(ContainSubstring("--high-availability-mode"))
})

It("control_plane_count is nil, parameter should be omitted", func() {
installCommandRequest.ControlPlaneCount = nil
installCommandLineString = getInstallCommandLineString(installCommandRequest)
Expand All @@ -144,8 +131,9 @@ var _ = Describe("installer test", func() {
Expect(argsAsString).NotTo(ContainSubstring("--control-plane-count"))
})

It("ha mode is Full, command line parameter should indicate this", func() {
installCommandRequest.HighAvailabilityMode = swag.String(models.ClusterHighAvailabilityModeFull)
It("if control-plane-count is set, command line parameter should indicate this", func() {
ctrlPlaneCount := int64(4)
installCommandRequest.ControlPlaneCount = &ctrlPlaneCount
installCommandLineString = getInstallCommandLineString(installCommandRequest)

action := install{args: []string{installCommandLineString}, filesystem: filesystem, agentConfig: agentConfig}
Expand All @@ -154,11 +142,11 @@ var _ = Describe("installer test", func() {

args := action.Args()
argsAsString := strings.Join(args, " ")
Expect(argsAsString).To(ContainSubstring("--high-availability-mode Full"))
Expect(argsAsString).To(ContainSubstring("--control-plane-count 4"))
})

It("if control-plane-count is set, command line parameter should indicate this", func() {
ctrlPlaneCount := int64(4)
It("if control-plane-count is set to 1, command line parameter should indicate this", func() {
ctrlPlaneCount := int64(1)
installCommandRequest.ControlPlaneCount = &ctrlPlaneCount
installCommandLineString = getInstallCommandLineString(installCommandRequest)

Expand All @@ -168,11 +156,12 @@ var _ = Describe("installer test", func() {

args := action.Args()
argsAsString := strings.Join(args, " ")
Expect(argsAsString).To(ContainSubstring("--control-plane-count 4"))
Expect(argsAsString).To(ContainSubstring("--control-plane-count 1"))
})

It("ha mode is None, command line parameter should indicate this", func() {
installCommandRequest.HighAvailabilityMode = swag.String(models.ClusterHighAvailabilityModeNone)
It("high-availability-mode should not be present any more", func() {
ctrlPlaneCount := int64(4)
installCommandRequest.ControlPlaneCount = &ctrlPlaneCount
installCommandLineString = getInstallCommandLineString(installCommandRequest)

action := install{args: []string{installCommandLineString}, filesystem: filesystem, agentConfig: agentConfig}
Expand All @@ -181,7 +170,7 @@ var _ = Describe("installer test", func() {

args := action.Args()
argsAsString := strings.Join(args, " ")
Expect(argsAsString).To(ContainSubstring("--high-availability-mode None"))
Expect(argsAsString).NotTo(ContainSubstring("--high-availability-mode"))
})

It("install ca cert", func() {
Expand Down Expand Up @@ -415,8 +404,13 @@ var _ = Describe("installer test", func() {
_ = getInstall(installCommandRequest, filesystem, true)
})

It("bad HighAvailability", func() {
installCommandRequest.HighAvailabilityMode = swag.String("some string")
It("control-plane-count is set to negative", func() {
installCommandRequest.ControlPlaneCount = swag.Int64(-1)
_ = getInstall(installCommandRequest, filesystem, true)
})

It("control-plane-count is set to too big", func() {
installCommandRequest.ControlPlaneCount = swag.Int64(6)
_ = getInstall(installCommandRequest, filesystem, true)
})

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3448c65

Please sign in to comment.