Repository: kubean-io/kubean
Pull request #833 (2023-06-19 08:35:10)

[docs] fix indentations in theory_of_airgapped_package.md
**What type of PR is this?**

/kind cleanup
/kind documentation

**What this PR does / why we need it**:
The current list is not good enough:

<img width="1074" alt="image" src="https://github.com/kubean-io/kubean/assets/79828097/4cb0df62-1947-48db-8b5e-0db48e8e61e2">

Local preview is good now.



Patch:
diff --git a/docs/en/concepts/theory_of_airgapped_package.md b/docs/en/concepts/theory_of_airgapped_package.md
index 39b102df2..eb2d798a0 100644
--- a/docs/en/concepts/theory_of_airgapped_package.md
+++ b/docs/en/concepts/theory_of_airgapped_package.md
@@ -20,20 +20,20 @@ This chapter explains the theory how the air-gapped packages come from.
 
 1. Images & binaries
 
-   As stated in Kubespray [offline deployment guide](https://github.com/kubernetes-sigs/kubespray/blob/master/contrib/offline/README.md),
-   Kubespray already provides scripts to generate images and binaries list. (Thanks to great Kubespray! )
+    As stated in Kubespray [offline deployment guide](https://github.com/kubernetes-sigs/kubespray/blob/master/contrib/offline/README.md),
+    Kubespray already provides scripts to generate images and binaries list. (Thanks to great Kubespray! )
 
-   With help of Kubespray [script to generate binaries & images list](https://github.com/kubernetes-sigs/kubespray/blob/master/contrib/offline/generate_list.sh),
-   then we can use [manage-offline-files.sh](https://github.com/kubernetes-sigs/kubespray/tree/master/contrib/offline#manage-offline-files.sh) to download those binaries and images.
-   At last, Kubean provides an [offline-build.sh](https://github.com/kubean-io/kubean/blob/main/.github/workflows/call-offline-build.yaml) to make them together.
+    With help of Kubespray [script to generate binaries & images list](https://github.com/kubernetes-sigs/kubespray/blob/master/contrib/offline/generate_list.sh),
+    then we can use [manage-offline-files.sh](https://github.com/kubernetes-sigs/kubespray/tree/master/contrib/offline#manage-offline-files.sh) to download those binaries and images.
+    At last, Kubean provides an [offline-build.sh](https://github.com/kubean-io/kubean/blob/main/.github/workflows/call-offline-build.yaml) to make them together.
 
 2. os-packages (deb/rpm)
 
-   During the k8s installation, a few packages could not be installed as binaries, so we have to install them via deb/rpm.
-   The [os packages list](https://github.com/kubean-io/kubean/blob/main/build/os-packages/packages.yml) defines what packages will be involved.
+    During the k8s installation, a few packages could not be installed as binaries, so we have to install them via deb/rpm.
+    The [os packages list](https://github.com/kubean-io/kubean/blob/main/build/os-packages/packages.yml) defines what packages will be involved.
 
-   Github Action will build packages in different OS (as Qemu) via `dnf/apt` to download and archive RPM/DEB packages.
+    Github Action will build packages in different OS (as Qemu) via `dnf/apt` to download and archive RPM/DEB packages.
 
 3. CI process
 
-   The offline assets are generated/managed by [Github Action scripts](https://github.com/kubean-io/kubean/tree/main/.github/workflows).
+    The offline assets are generated/managed by [Github Action scripts](https://github.com/kubean-io/kubean/tree/main/.github/workflows).
diff --git a/docs/zh/concepts/theory_of_airgapped_package.md b/docs/zh/concepts/theory_of_airgapped_package.md
index 6c5b54383..2ff513525 100644
--- a/docs/zh/concepts/theory_of_airgapped_package.md
+++ b/docs/zh/concepts/theory_of_airgapped_package.md
@@ -19,22 +19,22 @@ Kubean CI 构建便于在离线环境中安装 Kubernetes 的离线文件。
 
 1. 镜像和二进制文件
 
-   类似 Kubespray [离线部署指南](https://github.com/kubernetes-sigs/kubespray/blob/master/contrib/offline/README.md)所述，
-   Kubespray 提供了一些脚本来生成镜像和二进制文件列表（感谢 Kubespray！）
+    类似 Kubespray [离线部署指南](https://github.com/kubernetes-sigs/kubespray/blob/master/contrib/offline/README.md)所述，
+    Kubespray 提供了一些脚本来生成镜像和二进制文件列表（感谢 Kubespray！）
 
-   得益于 Kubespray [生成二进制和镜像列表的脚本](https://github.com/kubernetes-sigs/kubespray/blob/master/contrib/offline/generate_list.sh)，
-   我们可以使用 [manage-offline-files.sh](https://github.com/kubernetes-sigs/kubespray/tree/master/contrib/offline#manage-offline-files.sh)
-   下载这些二进制文件和镜像。
-   随后 Kubean 提供了 [offline-build.sh](https://github.com/kubean-io/kubean/blob/main/.github/workflows/call-offline-build.yaml)
-   将所有这些融合于一起。
+    得益于 Kubespray [生成二进制和镜像列表的脚本](https://github.com/kubernetes-sigs/kubespray/blob/master/contrib/offline/generate_list.sh)，
+    我们可以使用 [manage-offline-files.sh](https://github.com/kubernetes-sigs/kubespray/tree/master/contrib/offline#manage-offline-files.sh)
+    下载这些二进制文件和镜像。
+    随后 Kubean 提供了 [offline-build.sh](https://github.com/kubean-io/kubean/blob/main/.github/workflows/call-offline-build.yaml)
+    将所有这些融合于一起。
 
 2. os-packages (deb/rpm)
 
-   在 K8s 安装期间，有些文件包不会随二进制文件一起安装，因此我们必须通过 deb/rpm 来安装这些文件包。
-   [os packages 列表](https://github.com/kubean-io/kubean/blob/main/build/os-packages/packages.yml)定义了所涉及的文件包。
+    在 K8s 安装期间，有些文件包不会随二进制文件一起安装，因此我们必须通过 deb/rpm 来安装这些文件包。
+    [os packages 列表](https://github.com/kubean-io/kubean/blob/main/build/os-packages/packages.yml)定义了所涉及的文件包。
 
-   Github Action 将通过 `dnf/apt` 构建不同操作系统的文件包（例如 Qemu），便于下载和归档 RPM/DEB 包。
+    Github Action 将通过 `dnf/apt` 构建不同操作系统的文件包（例如 Qemu），便于下载和归档 RPM/DEB 包。
 
 3. CI 流程
 
-   离线文件包由 [Github Action 脚本](https://github.com/kubean-io/kubean/tree/main/.github/workflows)生成和管理。
+    离线文件包由 [Github Action 脚本](https://github.com/kubean-io/kubean/tree/main/.github/workflows)生成和管理。
diff --git a/pkg/controllers/clusterops/controller.go b/pkg/controllers/clusterops/controller.go
index d2c1783c4..656d97803 100644
--- a/pkg/controllers/clusterops/controller.go
+++ b/pkg/controllers/clusterops/controller.go
@@ -123,10 +123,10 @@ func (c *Controller) FetchGlobalInfoManifest() (*manifestv1alpha1.Manifest, erro
 	return global, nil
 }
 
-func (c *Controller) UpdateStatusLoop(clusterOps *clusteroperationv1alpha1.ClusterOperation, fetchJobStatus func(*clusteroperationv1alpha1.ClusterOperation) (clusteroperationv1alpha1.OpsStatus, *metav1.Time, error)) (bool, error) {
+func (c *Controller) UpdateStatusLoop(clusterOps *clusteroperationv1alpha1.ClusterOperation, fetchJobStatus func(*clusteroperationv1alpha1.ClusterOperation) (clusteroperationv1alpha1.OpsStatus, error)) (bool, error) {
 	if clusterOps.Status.Status == clusteroperationv1alpha1.RunningStatus || len(clusterOps.Status.Status) == 0 {
 		// need fetch jobStatus again when the last status of job is running
-		jobStatus, completionTime, err := fetchJobStatus(clusterOps)
+		jobStatus, err := fetchJobStatus(clusterOps)
 		if err != nil {
 			return false, err
 		}
@@ -137,9 +137,6 @@ func (c *Controller) UpdateStatusLoop(clusterOps *clusteroperationv1alpha1.Clust
 		// the status  succeed or failed
 		clusterOps.Status.Status = jobStatus
 		clusterOps.Status.EndTime = &metav1.Time{Time: time.Now()}
-		if completionTime != nil {
-			clusterOps.Status.EndTime = completionTime
-		}
 		if err := c.Client.Status().Update(context.Background(), clusterOps); err != nil {
 			return false, err
 		}
@@ -149,29 +146,29 @@ func (c *Controller) UpdateStatusLoop(clusterOps *clusteroperationv1alpha1.Clust
 	return false, nil
 }
 
-func (c *Controller) FetchJobConditionStatusAndCompletionTime(clusterOps *clusteroperationv1alpha1.ClusterOperation) (clusteroperationv1alpha1.OpsStatus, *metav1.Time, error) {
+func (c *Controller) FetchJobStatus(clusterOps *clusteroperationv1alpha1.ClusterOperation) (clusteroperationv1alpha1.OpsStatus, error) {
 	if clusterOps.Status.JobRef.IsEmpty() {
-		return "", nil, fmt.Errorf("clusterOps %s no job", clusterOps.Name)
+		return "", fmt.Errorf("clusterOps %s no job", clusterOps.Name)
 	}
 	targetJob, err := c.ClientSet.BatchV1().Jobs(clusterOps.Status.JobRef.NameSpace).Get(context.Background(), clusterOps.Status.JobRef.Name, metav1.GetOptions{})
 	if apierrors.IsNotFound(err) {
 		// maybe the job is removed.
 		klog.Errorf("clusterOps %s  job %s not found", clusterOps.Name, clusterOps.Status.JobRef.Name)
-		return clusteroperationv1alpha1.FailedStatus, nil, nil
+		return clusteroperationv1alpha1.FailedStatus, nil
 	}
 	if err != nil {
-		return "", nil, err
+		return "", err
 	}
 	// according to the job condtions, return success or failed
 	for _, contion := range targetJob.Status.Conditions {
 		if contion.Type == batchv1.JobComplete && contion.Status == corev1.ConditionTrue {
-			return clusteroperationv1alpha1.SucceededStatus, targetJob.Status.CompletionTime, nil
+			return clusteroperationv1alpha1.SucceededStatus, nil
 		} else if contion.Type == batchv1.JobFailed && contion.Status == corev1.ConditionTrue {
-			return clusteroperationv1alpha1.FailedStatus, targetJob.Status.CompletionTime, nil
+			return clusteroperationv1alpha1.FailedStatus, nil
 		}
 	}
 
-	return clusteroperationv1alpha1.RunningStatus, nil, nil
+	return clusteroperationv1alpha1.RunningStatus, nil
 }
 
 func (c *Controller) ListClusterOps(clusterName string) ([]clusteroperationv1alpha1.ClusterOperation, error) {
@@ -323,7 +320,7 @@ func (c *Controller) Reconcile(ctx context.Context, req controllerruntime.Reques
 		return controllerruntime.Result{RequeueAfter: RequeueAfter}, nil
 	}
 
-	needRequeue, err = c.UpdateStatusLoop(clusterOps, c.FetchJobConditionStatusAndCompletionTime)
+	needRequeue, err = c.UpdateStatusLoop(clusterOps, c.FetchJobStatus)
 	if err != nil {
 		klog.Error(err)
 		return controllerruntime.Result{RequeueAfter: RequeueAfter}, err
diff --git a/playbooks/precheck.yml b/playbooks/precheck.yml
index b8e197d88..2c23a98bb 100644
--- a/playbooks/precheck.yml
+++ b/playbooks/precheck.yml
@@ -93,7 +93,6 @@
         ( if [ ! -f /tmp/kubean_data_temp_cache ]; then touch /tmp/kubean_data_temp_cache ; fi )
         yq -i '.{{inventory_hostname}}.os_kernel_version_output="{{ ansible_kernel }}"' /tmp/kubean_data_temp_cache
         yq -i '.{{inventory_hostname}}.os_kernel_version="{{ ansible_kernel.split('-')[0] }}"' /tmp/kubean_data_temp_cache
-        yq -i '.{{inventory_hostname}}.pkg_mgr="{{ ansible_pkg_mgr }}"' /tmp/kubean_data_temp_cache
       ignore_errors: true
       delegate_to: localhost
       when:


Test patch:
diff --git a/pkg/controllers/clusterops/controller_test.go b/pkg/controllers/clusterops/controller_test.go
index 5dd87d77c..a1a539691 100644
--- a/pkg/controllers/clusterops/controller_test.go
+++ b/pkg/controllers/clusterops/controller_test.go
@@ -89,8 +89,8 @@ func TestUpdateStatusLoop(t *testing.T) {
 			name: "the status is Running and the result of fetchJobStatus is err",
 			args: func(ops *clusteroperationv1alpha1.ClusterOperation) bool {
 				ops.Status.Status = clusteroperationv1alpha1.RunningStatus
-				needRequeue, err := controller.UpdateStatusLoop(ops, func(ops *clusteroperationv1alpha1.ClusterOperation) (clusteroperationv1alpha1.OpsStatus, *metav1.Time, error) {
-					return "", nil, fmt.Errorf("one error")
+				needRequeue, err := controller.UpdateStatusLoop(ops, func(ops *clusteroperationv1alpha1.ClusterOperation) (clusteroperationv1alpha1.OpsStatus, error) {
+					return "", fmt.Errorf("one error")
 				})
 				return err != nil && err.Error() == "one error" && !needRequeue
 			},
@@ -100,8 +100,8 @@ func TestUpdateStatusLoop(t *testing.T) {
 			name: "the status is Running and the result of fetchJobStatus is still Running",
 			args: func(ops *clusteroperationv1alpha1.ClusterOperation) bool {
 				ops.Status.Status = clusteroperationv1alpha1.RunningStatus
-				needRequeue, err := controller.UpdateStatusLoop(ops, func(ops *clusteroperationv1alpha1.ClusterOperation) (clusteroperationv1alpha1.OpsStatus, *metav1.Time, error) {
-					return clusteroperationv1alpha1.RunningStatus, nil, nil
+				needRequeue, err := controller.UpdateStatusLoop(ops, func(ops *clusteroperationv1alpha1.ClusterOperation) (clusteroperationv1alpha1.OpsStatus, error) {
+					return clusteroperationv1alpha1.RunningStatus, nil
 				})
 				return err == nil && needRequeue
 			},
@@ -112,8 +112,8 @@ func TestUpdateStatusLoop(t *testing.T) {
 			args: func(ops *clusteroperationv1alpha1.ClusterOperation) bool {
 				ops.Status.Status = clusteroperationv1alpha1.RunningStatus
 				ops.Status.EndTime = nil
-				needRequeue, err := controller.UpdateStatusLoop(ops, func(ops *clusteroperationv1alpha1.ClusterOperation) (clusteroperationv1alpha1.OpsStatus, *metav1.Time, error) {
-					return clusteroperationv1alpha1.SucceededStatus, &metav1.Time{}, nil
+				needRequeue, err := controller.UpdateStatusLoop(ops, func(ops *clusteroperationv1alpha1.ClusterOperation) (clusteroperationv1alpha1.OpsStatus, error) {
+					return clusteroperationv1alpha1.SucceededStatus, nil
 				})
 				resultOps := &clusteroperationv1alpha1.ClusterOperation{}
 				controller.Client.Get(context.Background(), client.ObjectKey{Name: "clusteropsname"}, resultOps)
@@ -130,8 +130,8 @@ func TestUpdateStatusLoop(t *testing.T) {
 				controller.Client.Get(context.Background(), client.ObjectKey{Name: "clusteropsname"}, ops)
 				ops.Status.Status = clusteroperationv1alpha1.RunningStatus
 				ops.Status.EndTime = nil
-				needRequeue, err := controller.UpdateStatusLoop(ops, func(ops *clusteroperationv1alpha1.ClusterOperation) (clusteroperationv1alpha1.OpsStatus, *metav1.Time, error) {
-					return clusteroperationv1alpha1.FailedStatus, nil, nil
+				needRequeue, err := controller.UpdateStatusLoop(ops, func(ops *clusteroperationv1alpha1.ClusterOperation) (clusteroperationv1alpha1.OpsStatus, error) {
+					return clusteroperationv1alpha1.FailedStatus, nil
 				})
 				return err == nil && !needRequeue && ops.Status.EndTime != nil && ops.Status.Status == clusteroperationv1alpha1.FailedStatus
 			},
@@ -1745,7 +1745,7 @@ func Test_FetchJobStatus(t *testing.T) {
 			name: "jobRef is empty",
 			args: func() bool {
 				clusterOps := &clusteroperationv1alpha1.ClusterOperation{}
-				_, _, err := controller.FetchJobConditionStatusAndCompletionTime(clusterOps)
+				_, err := controller.FetchJobStatus(clusterOps)
 				return err != nil
 			},
 			want: true,
@@ -1755,7 +1755,7 @@ func Test_FetchJobStatus(t *testing.T) {
 			args: func() bool {
 				clusterOps := &clusteroperationv1alpha1.ClusterOperation{}
 				clusterOps.Status.JobRef = &apis.JobRef{NameSpace: "kubean-system", Name: "job123"}
-				status, _, err := controller.FetchJobConditionStatusAndCompletionTime(clusterOps)
+				status, err := controller.FetchJobStatus(clusterOps)
 				return err == nil && status == clusteroperationv1alpha1.FailedStatus
 			},
 			want: true,
@@ -1784,7 +1784,7 @@ func Test_FetchJobStatus(t *testing.T) {
 					},
 				}
 				controller.ClientSet.BatchV1().Jobs("kubean-system").Create(context.Background(), targetJob, metav1.CreateOptions{})
-				status, _, err := controller.FetchJobConditionStatusAndCompletionTime(clusterOps)
+				status, err := controller.FetchJobStatus(clusterOps)
 				return err == nil && status == clusteroperationv1alpha1.SucceededStatus
 			},
 			want: true,
@@ -1813,7 +1813,7 @@ func Test_FetchJobStatus(t *testing.T) {
 					},
 				}
 				controller.ClientSet.BatchV1().Jobs("kubean-system").Create(context.Background(), targetJob, metav1.CreateOptions{})
-				status, _, err := controller.FetchJobConditionStatusAndCompletionTime(clusterOps)
+				status, err := controller.FetchJobStatus(clusterOps)
 				return err == nil && status == clusteroperationv1alpha1.FailedStatus
 			},
 			want: true,
@@ -1834,8 +1834,8 @@ func Test_FetchJobStatus(t *testing.T) {
 					},
 				}
 				controller.ClientSet.BatchV1().Jobs("kubean-system").Create(context.Background(), targetJob, metav1.CreateOptions{})
-				status, completionTime, err := controller.FetchJobConditionStatusAndCompletionTime(clusterOps)
-				return err == nil && status == clusteroperationv1alpha1.RunningStatus && completionTime == nil
+				status, err := controller.FetchJobStatus(clusterOps)
+				return err == nil && status == clusteroperationv1alpha1.RunningStatus
 			},
 			want: true,
 		},