@@ -313,6 +313,70 @@ func TestBackendTry(t *testing.T) {
313313 manager .EXPECT ().AdminUpdate (gomock .Any ()).Return (nil )
314314 },
315315 },
316+ {
317+ name : "StateAdminUpdating success, last ProvisioningState non-terminal, sets ProvisioningState to Succeeded, clears LastAdminUpdateError and MaintenanceTask, and has maintenance state none" ,
318+ fixture : func (f * testdatabase.Fixture ) {
319+ f .AddOpenShiftClusterDocuments (& api.OpenShiftClusterDocument {
320+ Key : strings .ToLower (resourceID ),
321+ OpenShiftCluster : & api.OpenShiftCluster {
322+ ID : resourceID ,
323+ Name : "resourceName" ,
324+ Type : "Microsoft.RedHatOpenShift/OpenShiftClusters" ,
325+ Location : "location" ,
326+ Properties : api.OpenShiftClusterProperties {
327+ ProvisioningState : api .ProvisioningStateAdminUpdating ,
328+ LastProvisioningState : api .ProvisioningStateAdminUpdating ,
329+ LastAdminUpdateError : "oh no" ,
330+ MaintenanceTask : api .MaintenanceTaskEverything ,
331+ MaintenanceState : api .MaintenanceStateUnplanned ,
332+ NetworkProfile : api.NetworkProfile {
333+ PodCIDR : "10.128.0.0/14" ,
334+ ServiceCIDR : "172.30.0.0/16" ,
335+ PreconfiguredNSG : api .PreconfiguredNSGDisabled ,
336+ OutboundType : api .OutboundTypeLoadbalancer ,
337+ LoadBalancerProfile : & api.LoadBalancerProfile {
338+ ManagedOutboundIPs : & api.ManagedOutboundIPs {
339+ Count : 0 ,
340+ },
341+ },
342+ },
343+ },
344+ },
345+ })
346+ f .AddSubscriptionDocuments (& api.SubscriptionDocument {
347+ ID : mockSubID ,
348+ })
349+ },
350+ checker : func (c * testdatabase.Checker ) {
351+ c .AddOpenShiftClusterDocuments (& api.OpenShiftClusterDocument {
352+ Key : strings .ToLower (resourceID ),
353+ OpenShiftCluster : & api.OpenShiftCluster {
354+ ID : resourceID ,
355+ Name : "resourceName" ,
356+ Type : "Microsoft.RedHatOpenShift/OpenShiftClusters" ,
357+ Location : "location" ,
358+ Properties : api.OpenShiftClusterProperties {
359+ ProvisioningState : api .ProvisioningStateSucceeded ,
360+ MaintenanceState : api .MaintenanceStateNone ,
361+ NetworkProfile : api.NetworkProfile {
362+ PodCIDR : "10.128.0.0/14" ,
363+ ServiceCIDR : "172.30.0.0/16" ,
364+ PreconfiguredNSG : api .PreconfiguredNSGDisabled ,
365+ OutboundType : api .OutboundTypeLoadbalancer ,
366+ LoadBalancerProfile : & api.LoadBalancerProfile {
367+ ManagedOutboundIPs : & api.ManagedOutboundIPs {
368+ Count : 0 ,
369+ },
370+ },
371+ },
372+ },
373+ },
374+ })
375+ },
376+ mocks : func (manager * mock_cluster.MockInterface , dbOpenShiftClusters database.OpenShiftClusters ) {
377+ manager .EXPECT ().AdminUpdate (gomock .Any ()).Return (nil )
378+ },
379+ },
316380 {
317381 name : "StateAdminUpdating run failure populates LastAdminUpdateError, restores previous provisioning state + failed provisioning state, and sets maintenance state to ongoing" ,
318382 fixture : func (f * testdatabase.Fixture ) {
@@ -379,6 +443,73 @@ func TestBackendTry(t *testing.T) {
379443 manager .EXPECT ().AdminUpdate (gomock .Any ()).Return (errors .New ("oh no!" ))
380444 },
381445 },
446+ {
447+ name : "StateAdminUpdating run failure, last ProvisioningState non-terminal, populates LastAdminUpdateError, sets ProvisioningState to failed, and sets maintenance state to ongoing" ,
448+ fixture : func (f * testdatabase.Fixture ) {
449+ f .AddOpenShiftClusterDocuments (& api.OpenShiftClusterDocument {
450+ Key : strings .ToLower (resourceID ),
451+ OpenShiftCluster : & api.OpenShiftCluster {
452+ ID : resourceID ,
453+ Name : "resourceName" ,
454+ Type : "Microsoft.RedHatOpenShift/OpenShiftClusters" ,
455+ Location : "location" ,
456+ Properties : api.OpenShiftClusterProperties {
457+ ProvisioningState : api .ProvisioningStateAdminUpdating ,
458+ LastProvisioningState : api .ProvisioningStateAdminUpdating ,
459+ FailedProvisioningState : api .ProvisioningStateUpdating ,
460+ MaintenanceTask : api .MaintenanceTaskEverything ,
461+ MaintenanceState : api .MaintenanceStateUnplanned ,
462+ NetworkProfile : api.NetworkProfile {
463+ PodCIDR : "10.128.0.0/14" ,
464+ ServiceCIDR : "172.30.0.0/16" ,
465+ PreconfiguredNSG : api .PreconfiguredNSGDisabled ,
466+ OutboundType : api .OutboundTypeLoadbalancer ,
467+ LoadBalancerProfile : & api.LoadBalancerProfile {
468+ ManagedOutboundIPs : & api.ManagedOutboundIPs {
469+ Count : 0 ,
470+ },
471+ },
472+ },
473+ },
474+ },
475+ })
476+ f .AddSubscriptionDocuments (& api.SubscriptionDocument {
477+ ID : mockSubID ,
478+ })
479+ },
480+ checker : func (c * testdatabase.Checker ) {
481+ c .AddOpenShiftClusterDocuments (& api.OpenShiftClusterDocument {
482+ Key : strings .ToLower (resourceID ),
483+ Dequeues : 1 ,
484+ OpenShiftCluster : & api.OpenShiftCluster {
485+ ID : resourceID ,
486+ Name : "resourceName" ,
487+ Type : "Microsoft.RedHatOpenShift/OpenShiftClusters" ,
488+ Location : "location" ,
489+ Properties : api.OpenShiftClusterProperties {
490+ ProvisioningState : api .ProvisioningStateFailed ,
491+ FailedProvisioningState : api .ProvisioningStateUpdating ,
492+ LastAdminUpdateError : "oh no!" ,
493+ MaintenanceState : api .MaintenanceStateUnplanned ,
494+ NetworkProfile : api.NetworkProfile {
495+ PodCIDR : "10.128.0.0/14" ,
496+ ServiceCIDR : "172.30.0.0/16" ,
497+ PreconfiguredNSG : api .PreconfiguredNSGDisabled ,
498+ OutboundType : api .OutboundTypeLoadbalancer ,
499+ LoadBalancerProfile : & api.LoadBalancerProfile {
500+ ManagedOutboundIPs : & api.ManagedOutboundIPs {
501+ Count : 0 ,
502+ },
503+ },
504+ },
505+ },
506+ },
507+ })
508+ },
509+ mocks : func (manager * mock_cluster.MockInterface , dbOpenShiftClusters database.OpenShiftClusters ) {
510+ manager .EXPECT ().AdminUpdate (gomock .Any ()).Return (errors .New ("oh no!" ))
511+ },
512+ },
382513 {
383514 name : "StateDeleting success deletes the document" ,
384515 fixture : func (f * testdatabase.Fixture ) {
0 commit comments