Skip to content

Commit 22dbeba

Browse files
persist migration data (#136)
1 parent f0f1d9d commit 22dbeba

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "venona",
3-
"version": "1.2.12",
3+
"version": "1.2.13",
44
"description": "Codefresh agent to run on Codefresh's runtime environment and execute pipeline",
55
"main": "index.js",
66
"scripts": {

venonactl/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.12
1+
1.2.13

venonactl/cmd/migrate.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var migrateCmd = &cobra.Command{
3535
Use: "migrate",
3636
Short: "Migrate existing runtime-environment from 0.X to 1.X version",
3737
Run: func(cmd *cobra.Command, args []string) {
38-
lgr := createLogger("Migrate", true)
38+
lgr := createLogger("Migrate", verbose)
3939
builder := plugins.NewBuilder(lgr)
4040
builder.Add(plugins.VenonaPluginType)
4141
s := store.GetStore()
@@ -45,6 +45,9 @@ var migrateCmd = &cobra.Command{
4545
extendStoreWithAgentAPI(lgr, "", "")
4646
fillKubernetesAPI(lgr, migrateCmdOpt.kube.context, migrateCmdOpt.kube.namespace, false)
4747
values := s.BuildValues()
48+
spn := createSpinner("Migrating runtime (might take a few seconds)", "")
49+
spn.Start()
50+
defer spn.Stop()
4851
for _, p := range builder.Get() {
4952
err := p.Migrate( &plugins.MigrateOptions{
5053
ClusterNamespace: migrateCmdOpt.kube.namespace,

venonactl/pkg/plugins/venona.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ package plugins
1818

1919
import (
2020
"encoding/base64"
21+
"encoding/json"
2122
"errors"
2223
"fmt"
24+
"io/ioutil"
2325
"time"
2426

2527
"github.com/codefresh-io/go-sdk/pkg/codefresh"
@@ -28,13 +30,20 @@ import (
2830
templates "github.com/codefresh-io/venona/venonactl/pkg/templates/kubernetes"
2931
kerrors "k8s.io/apimachinery/pkg/api/errors"
3032
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
33+
"k8s.io/api/core/v1"
34+
3135
)
3236

3337
// venonaPlugin installs assets on Kubernetes Dind runtimectl Env
3438
type venonaPlugin struct {
3539
logger logger.Logger
3640
}
3741

42+
type migrationData struct {
43+
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
44+
Tolerations [] v1.Toleration `json:"tolerations,omitempty"`
45+
}
46+
3847
const (
3948
venonaFilesPattern = ".*.venona.yaml"
4049
)
@@ -248,6 +257,21 @@ func (u *venonaPlugin) Migrate(opt *MigrateOptions, v Values) error {
248257
u.logger.Error(fmt.Sprintf("Cannot find agent pod: %v ", err))
249258
return err
250259
}
260+
if (len(list.Items) == 0) {
261+
u.logger.Debug("Runner pod not found , existing migration")
262+
return nil
263+
}
264+
migrationData := migrationData{
265+
Tolerations: list.Items[0].Spec.Tolerations,
266+
NodeSelector: list.Items[0].Spec.NodeSelector,
267+
}
268+
var jsonData []byte
269+
jsonData, err = json.Marshal(migrationData)
270+
err = ioutil.WriteFile("migration.json", jsonData, 0644)
271+
if (err != nil) {
272+
u.logger.Error("Cannot write migration json")
273+
}
274+
251275
podName := list.Items[0].ObjectMeta.Name
252276
for fileName := range kubeObjects {
253277
if _, ok := deletePriorUpgrade[fileName]; ok {

0 commit comments

Comments
 (0)