Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1968164

Summary: [Assisted-4.7] [Integration][OCS] OCS become Available before OCS is actually Ready
Product: OpenShift Container Platform Reporter: Lital Alon <lalon>
Component: assisted-installerAssignee: Rewant <resoni>
assisted-installer sub component: OCS Plugin QA Contact: Lital Alon <lalon>
Status: CLOSED DEFERRED Docs Contact:
Severity: urgent    
Priority: unspecified CC: aos-bugs, godas, nibalach, omachace, oourfali, pkliczew, resoni, sabose, yobshans
Version: 4.7Keywords: TestBlocker
Target Milestone: ---Flags: pkliczew: needinfo-
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-14 06:07:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Lital Alon 2021-06-06 11:59:33 UTC
Description of problem:
I have installed OCP with OCS cluster (both compact and standard modes). 
The issue is that OCS become available in AI, while in actual when checking OCS storage class it is still Progressing rather than Ready (but become Ready after few minutes).

As a result, API tests are failing. In tests there is 5 min timeout for waiting OCS to be Ready.
In some cases test wont fail but it will become ready in the last attempt i.e:


2021-06-06 11:20:25,155 DEBUG      - 139964519545728 - Checking if OCS is Ready 	(/tmp/little/kni-assisted-installer-auto/api_tests/test_ocs_validations.py:143)
2021-06-06 11:20:27,444 DEBUG      - 139964519545728 - OCS in status "Ready": False 	(/tmp/little/kni-assisted-installer-auto/api_tests/test_ocs_validations.py:137)
2021-06-06 11:21:25,374 DEBUG      - 139964519545728 - OCS in status "Ready": False 	(/tmp/little/kni-assisted-installer-auto/api_tests/test_ocs_validations.py:137)
2021-06-06 11:22:25,433 DEBUG      - 139964519545728 - OCS in status "Ready": False 	(/tmp/little/kni-assisted-installer-auto/api_tests/test_ocs_validations.py:137)
2021-06-06 11:23:25,474 DEBUG      - 139964519545728 - OCS in status "Ready": False 	(/tmp/little/kni-assisted-installer-auto/api_tests/test_ocs_validations.py:137)
2021-06-06 11:24:25,475 DEBUG      - 139964519545728 - OCS in status "Ready": True 	(/tmp/little/kni-assisted-installer-auto/api_tests/test_ocs_validations.py:137)

I expected OCS to become Available (in AI) only when OCS is Ready

Version-Release number of selected component (if applicable):
Integration, master

How reproducible:
Intermediate

Steps to Reproduce:
1. Install OCP and OCS cluster


Actual results:
OCS Operator is Available before OCS is Ready

Expected results:
OCS Operator is Available when OCS is Ready

Comment 1 Lital Alon 2021-06-06 16:06:42 UTC
also test: test_ocs_failed_to_deploy_ocp_success
expect OCS to be failed, but in last test execution, OCS finished with success in AI, in actual OCS wont be able to install.
not sure it is the same bug, but might be same wrong status report (LMK if different bug is needed).

AI Operators:

    OpenShift Container Storage available
    OpenShift Local Storage available


From machine: 

[root@sealusa11 ~]# oc get StorageCluster -n openshift-storage
NAME                 AGE   PHASE         EXTERNAL   CREATED AT             VERSION
ocs-storagecluster   16m   Progressing              2021-06-06T15:46:36Z   4.7.0
[root@sealusa11 ~]# oc get po -n openshift-local-storage
NAME                                      READY   STATUS    RESTARTS   AGE
diskmaker-manager-4sflj                   1/1     Running   0          16m
diskmaker-manager-54xbv                   1/1     Running   0          16m
diskmaker-manager-8tmkk                   1/1     Running   0          16m
local-storage-operator-866667c768-lmxcs   1/1     Running   0          36m
[root@sealusa11 ~]# oc get pvc -n openshift-storage
NAME                          STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS    AGE
ocs-deviceset-0-data-0qkv9q   Pending                                      localblock-sc   14m
ocs-deviceset-1-data-0mkgvl   Pending                                      localblock-sc   14m
ocs-deviceset-2-data-0bc69x   Pending                                      localblock-sc   14m

[root@sealusa11 ~]# oc get csv -n openshift-storage
NAME                  DISPLAY                       VERSION   REPLACES   PHASE
ocs-operator.v4.7.0   OpenShift Container Storage   4.7.0                Installing


Events:
  Type     Reason               Age                From                        Message
  ----     ------               ----               ----                        -------
  Normal   RequirementsUnknown  37m                operator-lifecycle-manager  requirements not yet checked
  Normal   RequirementsNotMet   37m (x2 over 37m)  operator-lifecycle-manager  one or more requirements couldn't be found
  Normal   InstallWaiting       36m (x2 over 36m)  operator-lifecycle-manager  installing: waiting for deployment rook-ceph-operator to become ready: Waiting for rollout to finish: 0 of 1 updated replicas are available...
  Normal   InstallSucceeded     35m                operator-lifecycle-manager  install strategy completed with no errors
  Warning  ComponentUnhealthy   16m (x2 over 16m)  operator-lifecycle-manager  installing: waiting for deployment ocs-operator to become ready: Waiting for rollout to finish: 0 of 1 updated replicas are available...
  Normal   NeedsReinstall       11m (x3 over 16m)  operator-lifecycle-manager  installing: waiting for deployment ocs-operator to become ready: Waiting for rollout to finish: 0 of 1 updated replicas are available...
  Normal   AllRequirementsMet   11m (x6 over 36m)  operator-lifecycle-manager  all requirements found, attempting install
  Normal   InstallSucceeded     11m (x5 over 36m)  operator-lifecycle-manager  waiting for install components to report healthy
  Normal   InstallWaiting       11m (x5 over 36m)  operator-lifecycle-manager  installing: waiting for deployment ocs-operator to become ready: Waiting for rollout to finish: 0 of 1 updated replicas are available...
  Warning  InstallCheckFailed   81s (x5 over 11m)  operator-lifecycle-manager  install timeout

Comment 2 N Balachandran 2021-06-08 04:55:36 UTC
Possible cause being investigated:
https://bugzilla.redhat.com/show_bug.cgi?id=1968606

Comment 3 N Balachandran 2021-06-10 05:36:33 UTC
We are currently investigating why this is happening.
In the meantime, how feasible is it for the AI code check for the StorageCluster status instead of the CSV for OCS operator?

Comment 4 Piotr Kliczewski 2021-06-10 07:51:47 UTC
Ondra how difficult it would be to change status monitoring to OCS operator?

Comment 5 Ondra Machacek 2021-06-10 08:41:20 UTC
It would be simple, but there are two problems:
1) After applying StorageCluster CR we need to wait before we start to wait for the Succeeded state. And don't check the state immediately.
2) As stated in bug 1968606 the OCS operator should not report Failed state in case it's still installing.

I would maybe suggest to fix this bug as adding a sleep before waiting to the proper CSV state after CR is applied. And ignore Failed state for a few times, before failing and marking the operator as it failed the installation.

Comment 6 N Balachandran 2021-06-11 16:00:29 UTC
(In reply to Ondra Machacek from comment #5)
> It would be simple, but there are two problems:
> 1) After applying StorageCluster CR we need to wait before we start to wait
> for the Succeeded state. And don't check the state immediately.
> 2) As stated in bug 1968606 the OCS operator should not report Failed state
> in case it's still installing.
> 
> I would maybe suggest to fix this bug as adding a sleep before waiting to
> the proper CSV state after CR is applied. And ignore Failed state for a few
> times, before failing and marking the operator as it failed the installation.

That sounds fine as well. 

Did anything change in the operator status check recently? I was wondering why this suddenly started happening/

Comment 7 Ondra Machacek 2021-06-14 13:14:50 UTC
Yes, this PR seems to cause it:

https://github.com/openshift/assisted-installer/pull/284

Comment 8 Priyanka 2021-06-16 06:21:21 UTC
@omachace  @pkliczew, the bug needs to be fixed in Assisted-Installer. 


1) After applying StorageCluster CR we need to wait before we start to wait for the Succeeded state. And don't check the state immediately.
2) As stated in bug 1968606 the OCS operator should not report Failed state in case it's still installing.

I would maybe suggest to fix this bug as adding a sleep before waiting to the proper CSV state after CR is applied. And ignore Failed state for a few times, before failing and marking the operator as it failed the installation.


We could fix by any of the above approach.

Comment 9 Piotr Kliczewski 2021-06-16 06:25:33 UTC
I wonder how you will select timeout value. Will it work on all (fast and slow) environments?

Why not to check OCS operator for status instead?

Comment 10 Priyanka 2021-06-16 06:28:17 UTC
Yes, we could check the StorageCluster CR status instead of checking csv status.

Comment 11 Rewant 2021-06-30 09:29:36 UTC
Adding a retry mechanism that ignores the failed state a few times.
PR: https://github.com/openshift/assisted-installer/pull/319

Comment 12 Lital Alon 2021-07-08 21:13:09 UTC
Issue still persist in Integration environment - In some cases, OCS become available in AI, while in actual when checking OCS storage class it is still Progressing rather than Ready (but become Ready after 10~ minutes).

Comment 13 Rewant 2021-07-09 05:29:30 UTC
CSV status of OCS is updated as:
1. It succeeds when OCS is deployed
2. It fails when the StorageCluster is being applied
3. It succeeds when the StorageCluster is applied

So, might be that it checks the csv status on phase 1 and see that it succeeded even if the StorageCluster CR is not applied, so we can check the status of the StorageCluster CR, till it's fixed in OCS.

Comment 14 Ondra Machacek 2021-07-13 05:54:20 UTC
Sure, it seems that checking the StorageCluster CR is the best workaround for now.

Comment 16 Sahina Bose 2021-09-02 09:12:43 UTC
Rewant, Priyanka - does the introduction of OperatorCondition in OCS solve this? Changes needed to AI code too?

Comment 17 Priyanka 2021-09-02 09:28:09 UTC
AI code will need to check the StorageCluster CR status instead of relying on CSV status only.With introduction of Operator Conditions, csv will not depend upon StorageCluster phases. 
@Rewant, how do we check the Operator status curently?

Comment 18 Rewant 2021-09-02 09:35:47 UTC
We check them from the CSV now(https://github.com/openshift/assisted-installer/blob/master/src/assisted_installer_controller/assisted_installer_controller.go#L481), We don't have anything to check the status of StorageCluster CR, we would need to implement it. Also, should we check only StorageCluster CR status or both StorageCluster and CSV status?

Comment 19 Priyanka 2021-09-02 10:37:59 UTC
We need to check both: CSV status and StorageCluster status.

Comment 20 Rewant 2021-09-02 10:45:28 UTC
Then we would need to implement that in AI. I will check with Piotr about the changes we need to make and open tasks for same.

Comment 22 Rewant 2022-04-19 10:25:08 UTC
It's related to https://issues.redhat.com/browse/MGMT-10018, the StorageCluster is still not in a ready state but the operator is ready. There will be an email sent by @