Skip to content

Commit

Permalink
Merge pull request #468 from nickgerace/master-ensure-ns
Browse files Browse the repository at this point in the history
Ensure fleet-system does not get deleted upon upgrade
  • Loading branch information
nickgerace authored Jul 22, 2021
2 parents a06d96f + 9c4da6e commit ea8cd77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ require (
github.com/pkg/errors v0.9.1
github.com/rancher/fleet/pkg/apis v0.0.0
github.com/rancher/gitjob v0.1.5
github.com/rancher/lasso v0.0.0-20210408231703-9ddd9378d08d
github.com/rancher/wrangler v0.8.1-0.20210521213200-39dd8bf93e9f
github.com/rancher/lasso v0.0.0-20210616224652-fc3ebd901c08
github.com/rancher/wrangler v0.8.4-0.20210721232424-82b1bc4f2de5
github.com/rancher/wrangler-cli v0.0.0-20200815040857-81c48cf8ab43
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v1.1.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1176,13 +1176,13 @@ github.com/rancher/helm/v3 v3.3.3-fleet1 h1:5kutcoifVpkL9H6JMZVBhM1YvgSf8zTL4UQk
github.com/rancher/helm/v3 v3.3.3-fleet1/go.mod h1:qUawjWz9THVCBVsNPJ/Q20VNEyrK7kN6lYf5loyp194=
github.com/rancher/lasso v0.0.0-20200820172840-0e4cc0ef5cb0/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18=
github.com/rancher/lasso v0.0.0-20200905045615-7fcb07d6a20b/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18=
github.com/rancher/lasso v0.0.0-20210408231703-9ddd9378d08d h1:vfjPEF6M7Jf1/zK1xF7z2drLfniooKcgDQdoXO5+U7w=
github.com/rancher/lasso v0.0.0-20210408231703-9ddd9378d08d/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18=
github.com/rancher/lasso v0.0.0-20210616224652-fc3ebd901c08 h1:NxR8Fh0eE7/5/5Zvlog9B5NVjWKqBSb1WYMUF7/IE5c=
github.com/rancher/lasso v0.0.0-20210616224652-fc3ebd901c08/go.mod h1:9qZd/S8DqWzfKtjKGgSoHqGEByYmUE3qRaBaaAHwfEM=
github.com/rancher/wrangler v0.6.1/go.mod h1:L4HtjPeX8iqLgsxfJgz+JjKMcX2q3qbRXSeTlC/CSd4=
github.com/rancher/wrangler v0.6.2-0.20200829053106-7e1dd4260224/go.mod h1:I7qe4DZNMOLKVa9ax7DJdBZ0XtKOppLF/dalhPX3vaE=
github.com/rancher/wrangler v0.7.3-0.20201002224307-4303c423125a/go.mod h1:goezjesEKwMxHLfltdjg9DW0xWV7txQee6vOuSDqXAI=
github.com/rancher/wrangler v0.8.1-0.20210521213200-39dd8bf93e9f h1:3LJN3poWNzVHPpbbsCnFih4ujSGYCyVnG5+wZ9kXwGs=
github.com/rancher/wrangler v0.8.1-0.20210521213200-39dd8bf93e9f/go.mod h1:aj/stIidTzU6UEKKRB8JyrrqNMJAfDMziL1+zhG8lc0=
github.com/rancher/wrangler v0.8.4-0.20210721232424-82b1bc4f2de5 h1:irIeJbyOWB/RKWoRpdgZH8OtQSC/4YpxMBB71dqnOU0=
github.com/rancher/wrangler v0.8.4-0.20210721232424-82b1bc4f2de5/go.mod h1:dKEaHNB4izxmPUtpq1Hvr3z3Oh+9k5pCZyFO9sUhlaY=
github.com/rancher/wrangler-cli v0.0.0-20200815040857-81c48cf8ab43 h1:+Bc9QnL9GuZiYxc3Mvm4n6EEjgI5TFQLDGjpRhQbkVk=
github.com/rancher/wrangler-cli v0.0.0-20200815040857-81c48cf8ab43/go.mod h1:KxpGNhk/oVL6LCfyxESTD1sb8eXRlUxtkbNm06+7dZU=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
Expand Down
9 changes: 8 additions & 1 deletion pkg/controllers/cluster/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import (
"github.com/rancher/wrangler/pkg/randomtoken"
"github.com/rancher/wrangler/pkg/yaml"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
Expand All @@ -29,6 +31,7 @@ var (
ImportTokenPrefix = "import-token-"
ImportTokenTTL = 12 * time.Hour
t = true
NamespaceKind = "Namespace"
)

type importHandler struct {
Expand Down Expand Up @@ -186,7 +189,11 @@ func (i *importHandler) importCluster(cluster *fleet.Cluster, status fleet.Clust
if err != nil {
return status, err
}
apply = apply.WithDynamicLookup().WithSetID("fleet-agent-bootstrap")
apply = apply.WithDynamicLookup().WithSetID("fleet-agent-bootstrap").WithNoDeleteGVK(schema.GroupVersionKind{
Group: corev1.SchemeGroupVersion.Group,
Version: corev1.SchemeGroupVersion.Version,
Kind: NamespaceKind,
})

token, err := i.tokens.Get(cluster.Namespace, ImportTokenPrefix+cluster.Name)
if err != nil {
Expand Down

0 comments on commit ea8cd77

Please sign in to comment.