From 88f9646defe6dfa9550d92b03a26f30c56dc4b29 Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Tue, 25 Jun 2024 16:39:55 +0900 Subject: [PATCH 1/4] feature. implementation resume scenario when byoh cluster installing --- cmd/server/cluster_status.go | 2 ++ go.mod | 2 +- go.sum | 6 ------ 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cmd/server/cluster_status.go b/cmd/server/cluster_status.go index 33e4652..ef37a56 100644 --- a/cmd/server/cluster_status.go +++ b/cmd/server/cluster_status.go @@ -45,6 +45,8 @@ func processClusterStatus() error { switch workflow.Status.Phase { case "Running": newStatus = domain.ClusterStatus_INSTALLING + case "Stopped": + newStatus = domain.ClusterStatus_STOPPED case "Succeeded": newStatus = domain.ClusterStatus_RUNNING case "Failed": diff --git a/go.mod b/go.mod index 1da8157..92eb88f 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ toolchain go1.21.7 require ( github.com/gofrs/uuid v4.0.0+incompatible + github.com/openinfradev/tks-api v0.0.0-20240509015017-73cfae88477f github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.5 @@ -49,7 +50,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/openinfradev/tks-api v0.0.0-20240509015017-73cfae88477f // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect diff --git a/go.sum b/go.sum index 0a09e4d..b3f436a 100644 --- a/go.sum +++ b/go.sum @@ -142,12 +142,6 @@ github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs= github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys= github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= -github.com/openinfradev/tks-api v0.0.0-20240411053710-5b8a434e8797 h1:DQ5naso3RdA0XxQ2Fj70xZ4O3vBhtWYR9Kpdy7LQqRE= -github.com/openinfradev/tks-api v0.0.0-20240411053710-5b8a434e8797/go.mod h1:Ph4lPgdWg06R1GUNCtmXfzHNlNCW/XjUAvei+m5DD2o= -github.com/openinfradev/tks-api v0.0.0-20240508035732-2495843420e9 h1:UWP8YleZKOq4RBvcquMSKZdguvwcnQOsj/bJgjSoLW0= -github.com/openinfradev/tks-api v0.0.0-20240508035732-2495843420e9/go.mod h1:d7dJJYRDarGe73yxJ6UKxYgQuiftPhqNVGYcH13nmIk= -github.com/openinfradev/tks-api v0.0.0-20240509015017-73cfae88477f h1:G1HC9OHMJb6aGMzM3xouE3P5YCQTj9xHSKAioUH26+4= -github.com/openinfradev/tks-api v0.0.0-20240509015017-73cfae88477f/go.mod h1:d7dJJYRDarGe73yxJ6UKxYgQuiftPhqNVGYcH13nmIk= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= From bc7a8914aca51f781861c16d7fd9e7d85b639b34 Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Wed, 26 Jun 2024 10:48:39 +0900 Subject: [PATCH 2/4] trivial. fix build error --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 92eb88f..b7ceb73 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.21.7 require ( github.com/gofrs/uuid v4.0.0+incompatible - github.com/openinfradev/tks-api v0.0.0-20240509015017-73cfae88477f + github.com/openinfradev/tks-api v0.0.0-20240626013032-da099b77eb0e github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index b3f436a..6df4287 100644 --- a/go.sum +++ b/go.sum @@ -142,6 +142,8 @@ github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs= github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys= github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= +github.com/openinfradev/tks-api v0.0.0-20240626013032-da099b77eb0e h1:PcHoV29NDLHi55ZOosLkyZK0stbWro483nRKpZWa8NA= +github.com/openinfradev/tks-api v0.0.0-20240626013032-da099b77eb0e/go.mod h1:01x6TpTcRwEFo89/+f+6MHPri562UoxflwhiacIm978= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= From 411641038f10f256a899cb59812a4a8c766ddf9c Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Tue, 2 Jul 2024 14:54:51 +0900 Subject: [PATCH 3/4] feature. update cluster status when workflow paused --- cmd/server/cluster_status.go | 7 +++++++ go.mod | 2 +- go.sum | 4 ++-- internal/cluster/cluster.go | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/server/cluster_status.go b/cmd/server/cluster_status.go index ef37a56..c6c079f 100644 --- a/cmd/server/cluster_status.go +++ b/cmd/server/cluster_status.go @@ -45,6 +45,13 @@ func processClusterStatus() error { switch workflow.Status.Phase { case "Running": newStatus = domain.ClusterStatus_INSTALLING + + if cluster.CloudService == "BYOH" { + paused, err := argowfClient.IsPausedWorkflow(context.TODO(), "argo", workflowId) + if err == nil && paused { + newStatus = domain.ClusterStatus_STOPPED + } + } case "Stopped": newStatus = domain.ClusterStatus_STOPPED case "Succeeded": diff --git a/go.mod b/go.mod index b7ceb73..f5cfc39 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ toolchain go1.21.7 require ( github.com/gofrs/uuid v4.0.0+incompatible - github.com/openinfradev/tks-api v0.0.0-20240626013032-da099b77eb0e github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.5 @@ -50,6 +49,7 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/openinfradev/tks-api v0.0.0-20240702055309-610554b9f520 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect diff --git a/go.sum b/go.sum index 6df4287..4c54bb4 100644 --- a/go.sum +++ b/go.sum @@ -142,8 +142,8 @@ github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs= github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys= github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= -github.com/openinfradev/tks-api v0.0.0-20240626013032-da099b77eb0e h1:PcHoV29NDLHi55ZOosLkyZK0stbWro483nRKpZWa8NA= -github.com/openinfradev/tks-api v0.0.0-20240626013032-da099b77eb0e/go.mod h1:01x6TpTcRwEFo89/+f+6MHPri562UoxflwhiacIm978= +github.com/openinfradev/tks-api v0.0.0-20240702055309-610554b9f520 h1:h57Bw+UYtVIpmtmBgYyXPNS9E9JsC5i3hFfu/WE+J2Q= +github.com/openinfradev/tks-api v0.0.0-20240702055309-610554b9f520/go.mod h1:01x6TpTcRwEFo89/+f+6MHPri562UoxflwhiacIm978= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= diff --git a/internal/cluster/cluster.go b/internal/cluster/cluster.go index 9241f90..91c2beb 100644 --- a/internal/cluster/cluster.go +++ b/internal/cluster/cluster.go @@ -18,6 +18,7 @@ type Cluster struct { Status domain.ClusterStatus StatusDesc string IsStack bool + CloudService string } // Accessor accesses cluster info in DB. From 5275ca5ecf99b94a1759de8ea365ac1acf478179 Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Mon, 22 Jul 2024 15:45:49 +0900 Subject: [PATCH 4/4] trivial. add condition for pause installing --- cmd/server/cluster_status.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/server/cluster_status.go b/cmd/server/cluster_status.go index c6c079f..079e197 100644 --- a/cmd/server/cluster_status.go +++ b/cmd/server/cluster_status.go @@ -46,11 +46,9 @@ func processClusterStatus() error { case "Running": newStatus = domain.ClusterStatus_INSTALLING - if cluster.CloudService == "BYOH" { - paused, err := argowfClient.IsPausedWorkflow(context.TODO(), "argo", workflowId) - if err == nil && paused { - newStatus = domain.ClusterStatus_STOPPED - } + paused, err := argowfClient.IsPausedWorkflow(context.TODO(), "argo", workflowId) + if err == nil && paused { + newStatus = domain.ClusterStatus_STOPPED } case "Stopped": newStatus = domain.ClusterStatus_STOPPED