Skip to content

Commit 9bc3a30

Browse files
committed
OCM-7330 | feat: Deprecate unused control-plane flag from upgrade/cluster
1 parent 4879b0b commit 9bc3a30

File tree

2 files changed

+3
-39
lines changed

2 files changed

+3
-39
lines changed

cmd/upgrade/cluster/cmd.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ func init() {
135135
"For Hosted Control Plane, whether the upgrade should cover only the control plane",
136136
)
137137

138+
flags.MarkDeprecated("control-plane", "Flag is deprecated, and can be omitted when running this "+
139+
"command in the future")
140+
138141
confirm.AddFlag(flags)
139142
}
140143

@@ -160,17 +163,6 @@ func runWithRuntime(r *rosa.Runtime, cmd *cobra.Command) error {
160163
}
161164
isHypershift := cluster.Hypershift().Enabled()
162165

163-
// Check parameters preconditions
164-
if args.controlPlane && !isHypershift {
165-
return fmt.Errorf("The '--control-plane' option is only supported for Hosted Control Planes")
166-
}
167-
168-
if !interactive.Enabled() {
169-
if !args.controlPlane && isHypershift {
170-
return fmt.Errorf("The '--control-plane' option is currently mandatory for Hosted Control Planes")
171-
}
172-
}
173-
174166
if currentUpgradeScheduling.Schedule == "" && currentUpgradeScheduling.AllowMinorVersionUpdates {
175167
return fmt.Errorf("The '--allow-minor-version-upgrades' option needs to be used with --schedule")
176168
}

cmd/upgrade/cluster/cmd_test.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,8 @@ var _ = Describe("Upgrade", Ordered, func() {
6969
BeforeEach(func() {
7070
testRuntime.InitRuntime()
7171
})
72-
It("Fails if flag is missing", func() {
73-
testRuntime.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, hypershiftClusterNotReady))
74-
err := runWithRuntime(testRuntime.RosaRuntime, Cmd)
75-
Expect(err).ToNot(BeNil())
76-
Expect(err.Error()).To(
77-
ContainSubstring("The '--control-plane' option is currently mandatory for Hosted Control Plane"))
78-
})
79-
It("Fails if cluster is not hypershift and we are using hypershift specific flags", func() {
80-
args.controlPlane = true
81-
testRuntime.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, classicCluster))
82-
err := runWithRuntime(testRuntime.RosaRuntime, Cmd)
83-
Expect(err).ToNot(BeNil())
84-
Expect(err.Error()).To(
85-
ContainSubstring("The '--control-plane' option is only supported for Hosted Control Planes"))
86-
})
8772

8873
It("Fails if cluster is not hypershift and we are using hypershift specific flags", func() {
89-
args.controlPlane = false
9074
args.schedule = cronSchedule
9175
testRuntime.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, classicCluster))
9276
err := runWithRuntime(testRuntime.RosaRuntime, Cmd)
@@ -95,7 +79,6 @@ var _ = Describe("Upgrade", Ordered, func() {
9579
ContainSubstring("The '--schedule' option is only supported for Hosted Control Planes"))
9680
})
9781
It("Fails if we are using minor version flag for manual upgrades", func() {
98-
args.controlPlane = true
9982
args.schedule = ""
10083
args.allowMinorVersionUpdates = true
10184
testRuntime.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, hypershiftClusterReady))
@@ -105,7 +88,6 @@ var _ = Describe("Upgrade", Ordered, func() {
10588
"option needs to be used with --schedule"))
10689
})
10790
It("Fails if we are mixing scheduling type flags", func() {
108-
args.controlPlane = true
10991
args.schedule = cronSchedule
11092
args.scheduleDate = "31 Jan"
11193
testRuntime.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, hypershiftClusterReady))
@@ -115,7 +97,6 @@ var _ = Describe("Upgrade", Ordered, func() {
11597
"options are mutually exclusive with '--schedule'"))
11698
})
11799
It("Fails if we are mixing automatic scheduling and version flags", func() {
118-
args.controlPlane = true
119100
args.schedule = cronSchedule
120101
args.scheduleDate = ""
121102
args.version = "4.13.0"
@@ -126,7 +107,6 @@ var _ = Describe("Upgrade", Ordered, func() {
126107
"option is mutually exclusive with '--version'"))
127108
})
128109
It("Fails if cluster is not ready", func() {
129-
args.controlPlane = true
130110
args.allowMinorVersionUpdates = false
131111
args.schedule = ""
132112
args.scheduleDate = ""
@@ -142,7 +122,6 @@ var _ = Describe("Upgrade", Ordered, func() {
142122
Expect(err.Error()).To(ContainSubstring("Cluster 'cluster1' is not yet ready"))
143123
})
144124
It("Cluster is ready but existing upgrade scheduled", func() {
145-
args.controlPlane = true
146125
args.schedule = cronSchedule
147126
testRuntime.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, hypershiftClusterReady))
148127
// An existing policy upgrade
@@ -162,7 +141,6 @@ var _ = Describe("Upgrade", Ordered, func() {
162141
"There is already a pending upgrade to version 4.12.18 on 2023-06-02 12:30 UTC"))
163142
})
164143
It("Cluster is ready and with automatic scheduling but bad cron format", func() {
165-
args.controlPlane = true
166144
// not a valid cron
167145
args.schedule = "* a"
168146
testRuntime.ApiServer.AppendHandlers(RespondWithJSON(http.StatusOK, hypershiftClusterReady))
@@ -176,7 +154,6 @@ var _ = Describe("Upgrade", Ordered, func() {
176154
})
177155

178156
It("Cluster is ready and with manual scheduling but bad format", func() {
179-
args.controlPlane = true
180157
args.schedule = ""
181158
// Not a valid date format
182159
args.scheduleDate = "Jan 23"
@@ -193,7 +170,6 @@ var _ = Describe("Upgrade", Ordered, func() {
193170
"schedule date should use the format 'yyyy-mm-dd'\n Schedule time should use the format 'HH:mm'"))
194171
})
195172
It("Cluster is ready and with manual scheduling but no upgrades available", func() {
196-
args.controlPlane = true
197173
args.schedule = ""
198174
// Not a valid date format
199175
args.scheduleDate = dateSchedule
@@ -210,7 +186,6 @@ var _ = Describe("Upgrade", Ordered, func() {
210186
Expect(stderr).To(ContainSubstring("There are no available upgrades"))
211187
})
212188
It("Cluster is ready and with automatic scheduling, no upgrades available -> still success", func() {
213-
args.controlPlane = true
214189
args.schedule = "20 5 * * *"
215190
args.scheduleDate = ""
216191
args.scheduleTime = ""
@@ -235,7 +210,6 @@ var _ = Describe("Upgrade", Ordered, func() {
235210
Expect(stderr).To(BeEmpty())
236211
})
237212
It("Cluster is ready and with manual scheduling and available upgrades but a wrong version in input", func() {
238-
args.controlPlane = true
239213
args.schedule = ""
240214
// Not a valid date format
241215
args.scheduleDate = dateSchedule
@@ -253,7 +227,6 @@ var _ = Describe("Upgrade", Ordered, func() {
253227
ContainSubstring("Expected a valid version to upgrade cluster to.\nValid versions: [4.13.1]"))
254228
})
255229
It("Cluster is ready and with manual scheduling and one available upgrade but cluster not found", func() {
256-
args.controlPlane = true
257230
args.schedule = ""
258231
// Not a valid date format
259232
args.scheduleDate = dateSchedule
@@ -278,7 +251,6 @@ var _ = Describe("Upgrade", Ordered, func() {
278251
Expect(err.Error()).To(ContainSubstring("There is no cluster with identifier or name"))
279252
})
280253
It("Fails if node-drain-grace-period flag is specified for hypershift clusters", func() {
281-
args.controlPlane = true
282254
args.schedule = "20 5 * * *"
283255
args.scheduleDate = ""
284256
args.scheduleTime = ""

0 commit comments

Comments
 (0)