Roll back a Non-Replicated TimesTen Upgrade

You can use Helm to roll back an upgrade of a non-replicated TimesTenClassic object. This reverts the non-replicated TimesTenClassic object and its associated TimesTen databases to the downgraded release.

  1. Before the rollback, do the following:
    1. Confirm the non-replicated TimesTenClassic object exists in your namespace.
      kubectl get ttc 
      The output is similar to the following:
      NAME              STATE              ACTIVE            AGE
      norepsamplehelm   AllReplicasReady   N/A               20h
      repsamplehelm     Normal             repsamplehelm-0   23h
      

      The norepsamplehelm TimesTenClassic object exists and is in the AllReplicasReady state.

    2. Verify the image and the value of rollingUpdatePartition.
      kubectl get ttc norepsamplehelm -o yaml | grep 'image\|rollingUpdatePartition'
      The output is similar to the following:
          image: container-registry.oracle.com/timesten/timesten:22.1.1.28.0
      ...
          rollingUpdatePartition: 0
      ...

      The current value for rollingUpdatePartition is 0. However, the value used for the downgrade is the original value of rollingUpdatePartition. In the example, the original value is 2. If you roll back to the original chart release in which the rollingUpdatePartition value is 2, Kubernetes only downgrades the -2 Pod. An upcoming step illustrates this.

  2. Review the revision history.
    helm history norepsamplehelm
    The output is similar to the following:
    
    REVISION        UPDATED                         STATUS          CHART                   APP VERSION     DESCRIPTION
    1               Sun Aug  4 17:42:47 2024        superseded      ttclassic-2211270.1.0   22.1.1.27.0     Install complete
    2               Mon Aug  5 04:22:15 2024        superseded      ttclassic-2211280.1.0   22.1.1.28.0     Upgrade complete
    3               Mon Aug  5 04:56:32 2024        deployed        ttclassic-2211280.1.0   22.1.1.28.0     Upgrade complete

    Revision 3 of the norepsamplehelm chart is running release 22.1.1.28.0. Revision 1 is running release 22.1.1.27.0.

  3. Roll back to revision 1.
    helm rollback norepsamplehelm 1

    The output is the following:

    Rollback was a success! Happy Helming!
  4. Monitor the progress.
    kubectl get ttc norepsamplehelm

    The output is similar to the following:

    NAME              STATE               ACTIVE   AGE
    norepsamplehelm   SomeReplicasReady   N/A      20h

    The object is in the SomeReplicasReady state.

    Wait a few minutes. Then, monitor again.

    kubectl get ttc norepsamplehelm

    The output is similar to the following:

    NAME              STATE              ACTIVE   AGE
    norepsamplehelm   AllReplicasReady   N/A      20h

    The object is in the AllReplicasReady state. All replicas are ready and available. TimesTen databases are up and running and functioning properly.

  5. Check the rollingUpdatePartition value and the image for the Pods.
    1. Check the value of rollingUpdatePartition.
      kubectl get ttc norepsamplehelm -o yaml | grep rollingUpdatePartition

      The output is similar to the following:

      rollingUpdatePartition: 2

      As part of the downgrade process, the value of rollingUpdatePartition changes to its original value of 2.

    2. Check the norepsamplehelm-2 Pod.
      kubectl describe pod norepsamplehelm-2 | grep Image

      The output is similar to the following:

      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0

      The containers in the Pod are running the downgraded image. Due to the rollingUpdatePartition value of 2, Kubernetes updated this Pod with the downgraded image. This is correct behavior.

    3. Check the norepsamplehelm-1 Pod.
      kubectl describe pod norepsamplehelm-1 | grep Image

      The output is similar to the following:

      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0

      The containers in the Pod are not running the downgraded image. Due to the rollingUpdatePartition value of 2, Kubernetes does not update this Pod with the downgraded image. This is correct behavior.

    4. Check the norepsamplehelm-0 Pod.
      kubectl describe pod norepsamplehelm-0 | grep Image

      The output is similar to the following:

      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0
      Image:          container-registry.oracle.com/timesten/timesten:22.1.1.28.0

      The containers in the Pod are not running the downgraded image. Due to the rollingUpdatePartition value of 2, Kubernetes does not updated this Pod with the downgraded image. This is correct behavior.

    After you confirm the downgrade is working, you can downgrade the remaining Pods.
  6. Create a new YAML file and in it specify the rollingUpdatePartition variable and set the value to 0.
    vi customyaml/changerollingupdate0.yaml
    
    rollingUpdatePartition: 0
  7. Change the rollingUpdatePartition value.

    Note:

    We recommend the following syntax. This ensures existing customizations are preserved.
    helm get values norepsamplehelm --all > prev-values-noreprolling0.yaml && helm upgrade -f prev-values-noreprolling0.yaml -f customyaml/changerollingupdate0.yaml  norepsamplehelm ./ttclassic
    The output is similar to the following:
    Release "norepsamplehelm" has been upgraded. Happy Helming!
    NAME: norepsamplehelm
    LAST DEPLOYED: Mon Aug  5 15:09:42 2024
    NAMESPACE: default
    STATUS: deployed
    REVISION: 5
    NOTES:
    Version 2211270.1.0 of the ttclassic chart has been installed.
    
    This release is named "norepsamplehelm".
    
    To learn more about the release, try:
    
      $ helm status norepsamplehelm
      $ helm get all norepsamplehelm
      $ helm history norepsamplehelm
    
    To rollback to a previous version of the chart, run:
    
      $ helm rollback norepsamplehelm <REVISION>
        - run 'helm history norepsamplehelm' for a list of revisions.

    Kubernetes automatically begins to terminate Pods and replace them with new ones. These new Pods run the downgraded image. Since rollingUpdatePartition is now 0, you should expect to see the norepsamplehelm-1 and norepsamplehelm-0 Pods updated with the downgraded image.

  8. Monitor the progress.
    1. TimesTenClassic object:
      kubectl get ttc norepsamplehelm

      The output is similar to the following

      NAME              STATE               ACTIVE            AGE
      norepsamplehelm   SomeReplicasReady   N/A               21h
    2. Pods:
      kubectl get pods

      The output is similar to the following:

      NAME                                 READY   STATUS     RESTARTS        AGE
      norepsamplehelm-0                    3/3     Running    0               10h
      norepsamplehelm-1                    0/3     Init:0/1   0               73s
      norepsamplehelm-2                    3/3     Running    0               34m

      Kubernetes replaces the norepsamplehelm-1 Pod first. Wait a few minutes. Then monitor again.

      kubectl get pods

      The output is similar to the following:

      NAME                                 READY   STATUS    RESTARTS        AGE
      norepsamplehelm-0                    3/3     Running   0               7m24s
      norepsamplehelm-1                    3/3     Running   0               9m49s
      norepsamplehelm-2                    3/3     Running   0               42m

      Kubernetes replaced the norepsamplehelm-1 and the norepsamplehelm-0 Pods. All Pods are running.

  9. Confirm the Pods are running the downgraded container image.

    Pod norepsamplehelm-1:

    kubectl describe pod norepsamplehelm-1 | grep Image

    The output is similar to the following:

    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0

    Pod norepsamplehelm-0:

    kubectl describe pod norepsamplehelm-0 | grep Image

    The output is similar to the following:

    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0
    Image:          container-registry.oracle.com/timesten/timesten:22.1.1.27.0

    The Pods are running the new image.

  10. Confirm the value of rollingUpdatePartition.
    kubectl get ttc norepsamplehelm -o yaml | grep rollingUpdatePartition

    The output is similar to the following:

    rollingUpdatePartition: 0
  11. Confirm the state of the TimesTenClassic object.
    kubectl get ttc norepsamplehelm

    The output is similar to the following:

    NAME              STATE              ACTIVE   AGE
    norepsamplehelm   AllReplicasReady   N/A      21h
  12. Check the history.
    helm history norepsamplehelm

    The output is similar to the following:

    REVISION        UPDATED                         STATUS          CHART                   APP VERSION     DESCRIPTION
    1               Sun Aug  4 17:42:47 2024        superseded      ttclassic-2211270.1.0   22.1.1.27.0     Install complete
    2               Mon Aug  5 04:22:15 2024        superseded      ttclassic-2211280.1.0   22.1.1.28.0     Upgrade complete
    3               Mon Aug  5 04:56:32 2024        superseded      ttclassic-2211280.1.0   22.1.1.28.0     Upgrade complete
    4               Mon Aug  5 14:36:43 2024        superseded      ttclassic-2211270.1.0   22.1.1.27.0     Rollback to 1
    5               Mon Aug  5 15:09:42 2024        deployed        ttclassic-2211270.1.0   22.1.1.27.0     Upgrade complete

    Revision 5 is running the 2211270.1.0 chart.

  13. Confirm the norepsamplehelm release is downgraded.
    helm list
    The output is similar to the following:
    NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART                   APP VERSION
    norepsamplehelm default         5               2024-08-05 15:09:42.959017268 +0000 UTC deployed        ttclassic-2211270.1.0   22.1.1.27.0

    The norepsamplehelm chart release is downgraded.

Congratulations! You successfully completed the rollback. The TimesTenClassic object is downgraded to the desired release and is in the AllReplicasReady state. All replicas are ready and available. Pods are running the downgraded TimesTen container image. TimesTen databases are upgraded and fully operational.