47 lines
1.6 KiB
Diff
47 lines
1.6 KiB
Diff
|
|
From a01e5ebfd9c314b840eb3a652cda71e33954a403 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Yuhang Wei <weiyuhang3@huawei.com>
|
||
|
|
Date: Wed, 16 Aug 2023 22:41:44 +0800
|
||
|
|
Subject: [PATCH 16/17] KubeOS: modify code for clean code
|
||
|
|
|
||
|
|
Signed-off-by: Yuhang Wei <weiyuhang3@huawei.com>
|
||
|
|
---
|
||
|
|
cmd/agent/server/config.go | 4 ++++
|
||
|
|
cmd/operator/controllers/os_controller.go | 6 +++++-
|
||
|
|
2 files changed, 9 insertions(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/cmd/agent/server/config.go b/cmd/agent/server/config.go
|
||
|
|
index 20af267..a96370d 100644
|
||
|
|
--- a/cmd/agent/server/config.go
|
||
|
|
+++ b/cmd/agent/server/config.go
|
||
|
|
@@ -317,6 +317,10 @@ func createConfigPath(configPath string) error {
|
||
|
|
if err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
+ err = f.Chmod(defaultKernelConPermission)
|
||
|
|
+ if err != nil {
|
||
|
|
+ return err
|
||
|
|
+ }
|
||
|
|
f.Close()
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
diff --git a/cmd/operator/controllers/os_controller.go b/cmd/operator/controllers/os_controller.go
|
||
|
|
index 620739b..e152681 100644
|
||
|
|
--- a/cmd/operator/controllers/os_controller.go
|
||
|
|
+++ b/cmd/operator/controllers/os_controller.go
|
||
|
|
@@ -94,7 +94,11 @@ func Reconcile(ctx context.Context, r common.ReadStatusWriter, req ctrl.Request)
|
||
|
|
func (r *OSReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||
|
|
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &upgradev1.OSInstance{}, values.OsiStatusName,
|
||
|
|
func(rawObj client.Object) []string {
|
||
|
|
- osi := rawObj.(*upgradev1.OSInstance)
|
||
|
|
+ osi, ok := rawObj.(*upgradev1.OSInstance)
|
||
|
|
+ if !ok {
|
||
|
|
+ log.Error(nil, "failed to convert to osInstance")
|
||
|
|
+ return []string{}
|
||
|
|
+ }
|
||
|
|
return []string{osi.Spec.NodeStatus}
|
||
|
|
}); err != nil {
|
||
|
|
return err
|
||
|
|
--
|
||
|
|
2.39.0
|
||
|
|
|