API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

Automatic pre-upgrade checks

By Susan Shaju posted Wed March 05, 2025 06:13 AM

  

Here in API Connect we are continuously trying to improve and refine the upgrade experience for our customers. The latest improvement we are pleased to introduce when upgrading to v10.0.8.0+ is the execution of automatic pre-upgrade checks. 

Historically we identified a number of conditions that when present in the system would increase the likelihood of an upgrade to fail. Our first step to addressing this was to provide the ability to be able to manually download the apicops binary and run the preupgrade command prior to starting the upgrade. Although this was a step in the right direction, because it was documented as a manual action with no enforcement, it meant it was possible for it to be missed and the upgrade to take place on an unhealthy system which would ultimately still fail. 

The introduction of the automatic pre-upgrade check addresses that problem by providing runtime enforcement of the checks that are required to pass in order for an upgrade to proceed. 

Improvements to Upgrade experience 

Once the operator has been upgraded to 10.0.8.0+, it will detect the upgrade of a given operand by checking for a difference in the spec.version value.  When it detects the upgrade has been initiated, the first action it takes is to create a new ‘<subsystem>-preupgrade’ job that will execute the subsystem specific set of checks.  It does this by triggering the ‘apicops system:pre-upgrade-check' command (the apicops binary is bundled as part of the job image). 

Output from the job is written to a config-map named ‘<subsystem>-preupgrade’.  While the job is in progress the operand remains in ‘Pending’ state.  If the job fails due to failed preupgrade checks, the operator will read the errors from the config map and populate the status.preUpgradeCheck object with the error details.  The job will automatically retry and the status will remain in pending until the failing checks are rectified and the preupgrade job completes successfully.  Once the job completes successfully the upgrade of the operand will proceed as usual.  Finally, once the upgrade of the operand has completed the status.preUpgradeCheck and preupgrade job are removed. 

The apicops system:pre-upgrade-check command can still be run manually prior to starting any upgrade activities by downloading the latest release of apicops.

Example 

Here we are trying to upgrade the management subsystem from 10.0.5.7 to 10.0.8.0. Once the operator is updated to the latest available version, change the spec.version to 10.0.8.0, also change the spec.license accordingly. 

Once we update the spec.version and spec.license, the subsystem will move to pending status with reason ‘PreUpgradeCheckInProgress’ and message ‘Preupgrade check job initiated. See status.PreUpgradeCheck for more details’. 

  status: 
    conditions: 
    - lastTransitionTime: "2024-10-25T08:10:04Z" 
      message: 'Management instance being upgraded. Preupgrade check job initiated. See status.PreUpgradeCheck for more details. Not all services are ready, next pending services: consumer-catalog, s3proxy, analytics-ui, preupgrade, postgresDb' 
      reason: PreUpgradeCheckInProgress 
      status: "True" 
      type: Pending 

The status.preUpgradeCheck condition is added and will remain in pending state with message ‘preupgrade check job in progress’  

  status: 
    preUpgradeCheck: 
    - lastTransitionTime: "2024-10-25T08:10:08Z" 
      message: preupgrade check job is in progress 
      reason: Running 
      status: "True" 
      type: Pending 

Here we can see the management-preupgrade job has been created. 

> kubectl get job 
NAME                                                 COMPLETIONS   DURATION   AGE 
management-preupgrade                                0/1           53s        53s 
> kubectl get pod 
NAME                                          READY   STATUS      RESTARTS   AGE 
management-preupgrade-v6c6f                   1/1     Running     0          63s 

If the pre-upgrade check fails the management-preupgrade job will automatically retry until the failing checks are rectified.  The status of the subsystem CR will remain in 'Pending' with the reason 'PreUpgradeCheckInProgress'. 

  status: 
    conditions: 
    - lastTransitionTime: "2024-10-25T08:10:04Z" 
      message: 'Management instance being upgraded. Preupgrade check failed, retrying. See status.PreUpgradeCheck for more details. Not all services are ready, next pending services: consumer-catalog, s3proxy, analytics-ui, preupgrade, postgresDb' 
      reason: PreUpgradeCheckInProgress 
      status: "True" 
      type: Pending 

The 'status.preUpgradeCheck' block will contain more details about the failing checks.  The message field contains information including the number times the job has been retried, the name of the config-map where the full output can be viewed and up to the first 3 errors returned from the apicops command. 

  status: 
    preUpgradeCheck: 
    - lastTransitionTime: "2024-10-25T08:10:08Z" 
      message: 'Retrying preupgrade check job (attempt 2). Previous check failed with errors, see config map "management-preupgrade" for more details. Rectify the failing checks for the upgrade to proceed. To abort the upgrade set the spec.Version value back to "10.0.5.7". Set the spec.License back to the previous value as well if that was also changed. Preupgrade check errors: APIC_APICOPS_0060E - Oplock configmap with the name "test-oplock" is not owned by "ManagementCluster". Actual owner: "cluster", name: "undefined".; Error: not all pre-upgrade-check command checks passed' 
      reason: Retrying 
      status: "True" 
      type: Pending 

The config-map 'management-preupgrade' will contains 'errors' and 'output' fields.  The 'errors' field will contain any error messages returned during the execution of the ‘apicops system:pre-upgrade-check' command.  The 'output' field will contain the entire log output of the command.  The config map will contain the errors and output of up to the last 3 executions of the preupgrade job. 

> kubectl get configmap management-preupgrade 
NAME                    DATA   AGE 
management-preupgrade   7      22h 

Once all failing checks have been rectified the job will automatically retry and complete successfully.  The 'status.preUpgradeCheck' condition is transitioned to complete and the operand upgrade will proceed. 

  status: 
    preUpgradeCheck: 
    - lastTransitionTime: "2024-10-25T08:14:28Z" 
      message: "" 
      reason: Complete 
      status: "True" 
      type: Complete 

Once the upgrade is completed the ‘status.preUpgradeCheck condition block is removed from subsystem CR. 

 

With the introduction of the automatic pre-upgrade checks across subsystems we hope to have taken another positive step to improving the upgrade experience of API Connect. 

Reference: 

0 comments
29 views

Permalink