From d75042cc8599faf3970503cd590bcd3e5f8d007f Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Wed, 12 Aug 2020 11:43:02 +0300 Subject: [PATCH 1/5] Remove unused Tags from NodeUp --- nodeup/pkg/bootstrap/install.go | 7 +-- nodeup/pkg/distros/distribution.go | 45 ------------------- .../fi/nodeup/cloudinit/cloud_init_target.go | 10 +---- upup/pkg/fi/nodeup/command.go | 15 +------ upup/pkg/fi/nodeup/local/local_target.go | 7 --- upup/pkg/fi/nodeup/nodetasks/package.go | 30 ++++++++----- upup/pkg/fi/nodeup/nodetasks/service.go | 23 ++++++---- .../fi/nodeup/nodetasks/update_packages.go | 10 +++-- upup/pkg/fi/nodeup/tags/BUILD.bazel | 8 ---- upup/pkg/fi/nodeup/tags/tags.go | 31 ------------- 10 files changed, 43 insertions(+), 143 deletions(-) delete mode 100644 upup/pkg/fi/nodeup/tags/BUILD.bazel delete mode 100644 upup/pkg/fi/nodeup/tags/tags.go diff --git a/nodeup/pkg/bootstrap/install.go b/nodeup/pkg/bootstrap/install.go index 6b758d06cc71b..675e828537d1e 100644 --- a/nodeup/pkg/bootstrap/install.go +++ b/nodeup/pkg/bootstrap/install.go @@ -22,7 +22,6 @@ import ( "os" "strings" - "k8s.io/apimachinery/pkg/util/sets" "k8s.io/klog" "k8s.io/kops/nodeup/pkg/distros" "k8s.io/kops/pkg/systemd" @@ -40,14 +39,11 @@ type Installation struct { } func (i *Installation) Run() error { - distribution, err := distros.FindDistribution(i.FSRoot) + _, err := distros.FindDistribution(i.FSRoot) if err != nil { return fmt.Errorf("error determining OS distribution: %v", err) } - tags := sets.NewString() - tags.Insert(distribution.BuildTags()...) - tasks := make(map[string]fi.Task) buildContext := &fi.ModelBuilderContext{ @@ -75,7 +71,6 @@ func (i *Installation) Run() error { target := &local.LocalTarget{ CacheDir: i.CacheDir, - Tags: tags, } checkExisting := true diff --git a/nodeup/pkg/distros/distribution.go b/nodeup/pkg/distros/distribution.go index 2364b9b872259..2416361255df0 100644 --- a/nodeup/pkg/distros/distribution.go +++ b/nodeup/pkg/distros/distribution.go @@ -18,7 +18,6 @@ package distros import ( "k8s.io/klog" - "k8s.io/kops/upup/pkg/fi/nodeup/tags" ) type Distribution string @@ -38,50 +37,6 @@ var ( DistributionContainerOS Distribution = "containeros" ) -func (d Distribution) BuildTags() []string { - var t []string - - switch d { - case DistributionDebian9, DistributionDebian10: - t = []string{} // trying to move away from tags - case DistributionXenial: - t = []string{"_xenial"} - case DistributionBionic: - t = []string{"_bionic"} - case DistributionFocal: - t = []string{"_focal"} - case DistributionAmazonLinux2: - t = []string{"_amazonlinux2"} - case DistributionCentos7: - t = []string{"_centos7"} - case DistributionRhel7: - t = []string{"_rhel7"} - case DistributionCentos8: - t = []string{"_centos8"} - case DistributionRhel8: - t = []string{"_rhel8"} - case DistributionFlatcar: - t = []string{"_flatcar"} - case DistributionContainerOS: - t = []string{"_containeros"} - default: - klog.Fatalf("unknown distribution: %s", d) - return nil - } - - if d.IsDebianFamily() { - t = append(t, tags.TagOSFamilyDebian) - } - if d.IsRHELFamily() { - t = append(t, tags.TagOSFamilyRHEL) - } - if d.IsSystemd() { - t = append(t, tags.TagSystemd) - } - - return t -} - func (d Distribution) IsDebianFamily() bool { switch d { case DistributionDebian9, DistributionDebian10: diff --git a/upup/pkg/fi/nodeup/cloudinit/cloud_init_target.go b/upup/pkg/fi/nodeup/cloudinit/cloud_init_target.go index 28b3b34325a4f..b83b8ad0552a9 100644 --- a/upup/pkg/fi/nodeup/cloudinit/cloud_init_target.go +++ b/upup/pkg/fi/nodeup/cloudinit/cloud_init_target.go @@ -23,7 +23,6 @@ import ( "os" "path" - "k8s.io/apimachinery/pkg/util/sets" "k8s.io/klog" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/utils" @@ -32,7 +31,6 @@ import ( type CloudInitTarget struct { Config *CloudConfig out io.Writer - Tags sets.String } type AddBehaviour int @@ -42,11 +40,10 @@ const ( Once ) -func NewCloudInitTarget(out io.Writer, tags sets.String) *CloudInitTarget { +func NewCloudInitTarget(out io.Writer) *CloudInitTarget { t := &CloudInitTarget{ Config: &CloudConfig{}, out: out, - Tags: tags, } return t } @@ -69,11 +66,6 @@ type CloudConfigFile struct { Content string `json:"content,omitempty"` } -func (t *CloudInitTarget) HasTag(tag string) bool { - _, found := t.Tags[tag] - return found -} - func (t *CloudInitTarget) ProcessDeletions() bool { // We don't expect any, but it would be our job to process them return true diff --git a/upup/pkg/fi/nodeup/command.go b/upup/pkg/fi/nodeup/command.go index b6ba1db31e31b..b9c5e1b81fa94 100644 --- a/upup/pkg/fi/nodeup/command.go +++ b/upup/pkg/fi/nodeup/command.go @@ -46,7 +46,6 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" - "k8s.io/apimachinery/pkg/util/sets" "k8s.io/klog" ) @@ -163,22 +162,11 @@ func (c *NodeUpCommand) Run(out io.Writer) error { return fmt.Errorf("error determining OS architecture: %v", err) } - archTags := architecture.BuildTags() - distribution, err := distros.FindDistribution(c.FSRoot) if err != nil { return fmt.Errorf("error determining OS distribution: %v", err) } - distroTags := distribution.BuildTags() - - nodeTags := sets.NewString() - nodeTags.Insert(archTags...) - nodeTags.Insert(distroTags...) - - klog.Infof("Arch tags: %v", archTags) - klog.Infof("Distro tags: %v", distroTags) - configAssets := c.config.Assets[architecture] assetStore := fi.NewAssetStore(c.CacheDir) for _, asset := range configAssets { @@ -290,14 +278,13 @@ func (c *NodeUpCommand) Run(out io.Writer) error { case "direct": target = &local.LocalTarget{ CacheDir: c.CacheDir, - Tags: nodeTags, } case "dryrun": assetBuilder := assets.NewAssetBuilder(c.cluster, "") target = fi.NewDryRunTarget(assetBuilder, out) case "cloudinit": checkExisting = false - target = cloudinit.NewCloudInitTarget(out, nodeTags) + target = cloudinit.NewCloudInitTarget(out) default: return fmt.Errorf("unsupported target type %q", c.Target) } diff --git a/upup/pkg/fi/nodeup/local/local_target.go b/upup/pkg/fi/nodeup/local/local_target.go index 2f02bc7bac67d..6b9555cf73fe5 100644 --- a/upup/pkg/fi/nodeup/local/local_target.go +++ b/upup/pkg/fi/nodeup/local/local_target.go @@ -19,13 +19,11 @@ package local import ( "os/exec" - "k8s.io/apimachinery/pkg/util/sets" "k8s.io/kops/upup/pkg/fi" ) type LocalTarget struct { CacheDir string - Tags sets.String } var _ fi.Target = &LocalTarget{} @@ -39,11 +37,6 @@ func (t *LocalTarget) ProcessDeletions() bool { return true } -func (t *LocalTarget) HasTag(tag string) bool { - _, found := t.Tags[tag] - return found -} - // CombinedOutput is a helper function that executes a command, returning stdout & stderr combined func (t *LocalTarget) CombinedOutput(args []string) ([]byte, error) { c := exec.Command(args[0], args[1:]...) diff --git a/upup/pkg/fi/nodeup/nodetasks/package.go b/upup/pkg/fi/nodeup/nodetasks/package.go index 92fe2145779b1..981118d16a86e 100644 --- a/upup/pkg/fi/nodeup/nodetasks/package.go +++ b/upup/pkg/fi/nodeup/nodetasks/package.go @@ -26,11 +26,11 @@ import ( "sync" "k8s.io/klog" + "k8s.io/kops/nodeup/pkg/distros" "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/nodeup/cloudinit" "k8s.io/kops/upup/pkg/fi/nodeup/local" - "k8s.io/kops/upup/pkg/fi/nodeup/tags" "k8s.io/kops/util/pkg/hashing" ) @@ -129,13 +129,16 @@ func (p *Package) String() string { } func (e *Package) Find(c *fi.Context) (*Package, error) { - target := c.Target.(*local.LocalTarget) + d, err := distros.FindDistribution("/") + if err != nil { + return nil, fmt.Errorf("unknown or unsupported distro: %v", err) + } - if target.HasTag(tags.TagOSFamilyDebian) { + if d.IsDebianFamily() { return e.findDpkg(c) } - if target.HasTag(tags.TagOSFamilyRHEL) { + if d.IsRHELFamily() { return e.findYum(c) } @@ -270,6 +273,11 @@ func (_ *Package) RenderLocal(t *local.LocalTarget, a, e, changes *Package) erro packageManagerLock.Lock() defer packageManagerLock.Unlock() + d, err := distros.FindDistribution("/") + if err != nil { + return fmt.Errorf("unknown or unsupported distro: %v", err) + } + if a == nil || changes.Version != nil { klog.Infof("Installing package %q (dependencies: %v)", e.Name, e.Deps) var pkgs []string @@ -283,9 +291,9 @@ func (_ *Package) RenderLocal(t *local.LocalTarget, a, e, changes *Package) erro // Append file extension for local files var ext string - if t.HasTag(tags.TagOSFamilyDebian) { + if d.IsDebianFamily() { ext = ".deb" - } else if t.HasTag(tags.TagOSFamilyRHEL) { + } else if d.IsRHELFamily() { ext = ".rpm" } else { return fmt.Errorf("unsupported package system") @@ -315,11 +323,11 @@ func (_ *Package) RenderLocal(t *local.LocalTarget, a, e, changes *Package) erro var args []string env := os.Environ() - if t.HasTag(tags.TagOSFamilyDebian) { + if d.IsDebianFamily() { args = []string{"apt-get", "install", "--yes", "--no-install-recommends"} env = append(env, "DEBIAN_FRONTEND=noninteractive") - } else if t.HasTag(tags.TagOSFamilyRHEL) { - if t.HasTag(tags.TagOSCentOS8) || t.HasTag(tags.TagOSRHEL8) { + } else if d.IsRHELFamily() { + if d == distros.DistributionCentos8 || d == distros.DistributionRhel8 { args = []string{"/usr/bin/dnf", "install", "-y", "--setopt=install_weak_deps=False"} } else { args = []string{"/usr/bin/yum", "install", "-y"} @@ -338,7 +346,7 @@ func (_ *Package) RenderLocal(t *local.LocalTarget, a, e, changes *Package) erro } } else { if changes.Healthy != nil { - if t.HasTag(tags.TagOSFamilyDebian) { + if d.IsDebianFamily() { args := []string{"dpkg", "--configure", "-a"} klog.Infof("package is not healthy; running command %s", args) cmd := exec.Command(args[0], args[1:]...) @@ -348,7 +356,7 @@ func (_ *Package) RenderLocal(t *local.LocalTarget, a, e, changes *Package) erro } changes.Healthy = nil - } else if t.HasTag(tags.TagOSFamilyRHEL) { + } else if d.IsRHELFamily() { // Not set on TagOSFamilyRHEL, we can't currently reach here anyway... return fmt.Errorf("package repair not supported on RHEL/CentOS") } else { diff --git a/upup/pkg/fi/nodeup/nodetasks/service.go b/upup/pkg/fi/nodeup/nodetasks/service.go index 2889e7e76fffb..35d1248997a58 100644 --- a/upup/pkg/fi/nodeup/nodetasks/service.go +++ b/upup/pkg/fi/nodeup/nodetasks/service.go @@ -26,10 +26,10 @@ import ( "time" "k8s.io/klog" + "k8s.io/kops/nodeup/pkg/distros" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/nodeup/cloudinit" "k8s.io/kops/upup/pkg/fi/nodeup/local" - "k8s.io/kops/upup/pkg/fi/nodeup/tags" ) const ( @@ -126,14 +126,19 @@ func getSystemdStatus(name string) (map[string]string, error) { return properties, nil } -func (e *Service) systemdSystemPath(target tags.HasTags) (string, error) { - if target.HasTag(tags.TagOSFamilyDebian) { +func (e *Service) systemdSystemPath() (string, error) { + d, err := distros.FindDistribution("/") + if err != nil { + return "", fmt.Errorf("unknown or unsupported distro: %v", err) + } + + if d.IsDebianFamily() { return debianSystemdSystemPath, nil - } else if target.HasTag(tags.TagOSFamilyRHEL) { + } else if d.IsRHELFamily() { return centosSystemdSystemPath, nil - } else if target.HasTag("_flatcar") { + } else if d == distros.DistributionFlatcar { return flatcarSystemdSystemPath, nil - } else if target.HasTag("_containeros") { + } else if d == distros.DistributionContainerOS { return containerosSystemdSystemPath, nil } else { return "", fmt.Errorf("unsupported systemd system") @@ -141,7 +146,7 @@ func (e *Service) systemdSystemPath(target tags.HasTags) (string, error) { } func (e *Service) Find(c *fi.Context) (*Service, error) { - systemdSystemPath, err := e.systemdSystemPath(c.Target.(tags.HasTags)) + systemdSystemPath, err := e.systemdSystemPath() if err != nil { return nil, err } @@ -239,7 +244,7 @@ func (s *Service) CheckChanges(a, e, changes *Service) error { } func (_ *Service) RenderLocal(t *local.LocalTarget, a, e, changes *Service) error { - systemdSystemPath, err := e.systemdSystemPath(t) + systemdSystemPath, err := e.systemdSystemPath() if err != nil { return err } @@ -355,7 +360,7 @@ func (_ *Service) RenderLocal(t *local.LocalTarget, a, e, changes *Service) erro } func (_ *Service) RenderCloudInit(t *cloudinit.CloudInitTarget, a, e, changes *Service) error { - systemdSystemPath, err := e.systemdSystemPath(t) + systemdSystemPath, err := e.systemdSystemPath() if err != nil { return err } diff --git a/upup/pkg/fi/nodeup/nodetasks/update_packages.go b/upup/pkg/fi/nodeup/nodetasks/update_packages.go index 7bac41af736b2..154d27627a733 100644 --- a/upup/pkg/fi/nodeup/nodetasks/update_packages.go +++ b/upup/pkg/fi/nodeup/nodetasks/update_packages.go @@ -23,10 +23,10 @@ import ( "syscall" "k8s.io/klog" + "k8s.io/kops/nodeup/pkg/distros" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/nodeup/cloudinit" "k8s.io/kops/upup/pkg/fi/nodeup/local" - "k8s.io/kops/upup/pkg/fi/nodeup/tags" ) type UpdatePackages struct { @@ -65,11 +65,15 @@ func (_ *UpdatePackages) RenderLocal(t *local.LocalTarget, a, e, changes *Update klog.Infof("SKIP_PACKAGE_UPDATE was set; skipping package update") return nil } + d, err := distros.FindDistribution("/") + if err != nil { + return fmt.Errorf("unknown or unsupported distro: %v", err) + } var args []string - if t.HasTag(tags.TagOSFamilyDebian) { + if d.IsDebianFamily() { args = []string{"apt-get", "update"} - } else if t.HasTag(tags.TagOSFamilyRHEL) { + } else if d.IsRHELFamily() { // Probably not technically needed args = []string{"/usr/bin/yum", "check-update"} } else { diff --git a/upup/pkg/fi/nodeup/tags/BUILD.bazel b/upup/pkg/fi/nodeup/tags/BUILD.bazel deleted file mode 100644 index e852c632ca5c6..0000000000000 --- a/upup/pkg/fi/nodeup/tags/BUILD.bazel +++ /dev/null @@ -1,8 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = ["tags.go"], - importpath = "k8s.io/kops/upup/pkg/fi/nodeup/tags", - visibility = ["//visibility:public"], -) diff --git a/upup/pkg/fi/nodeup/tags/tags.go b/upup/pkg/fi/nodeup/tags/tags.go deleted file mode 100644 index c59f6b3dffeda..0000000000000 --- a/upup/pkg/fi/nodeup/tags/tags.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package tags - -const ( - TagOSFamilyRHEL = "_rhel_family" - TagOSFamilyDebian = "_debian_family" - - TagOSCentOS8 = "_centos8" - TagOSRHEL8 = "_rhel8" - - TagSystemd = "_systemd" -) - -type HasTags interface { - HasTag(tag string) bool -} From 44db702f7e0d0c9e8de316f60d8bc21f9fdd37a6 Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Wed, 12 Aug 2020 14:54:38 +0300 Subject: [PATCH 2/5] Update bazel --- nodeup/pkg/bootstrap/BUILD.bazel | 1 - nodeup/pkg/distros/BUILD.bazel | 5 +---- upup/pkg/fi/nodeup/BUILD.bazel | 1 - upup/pkg/fi/nodeup/cloudinit/BUILD.bazel | 1 - upup/pkg/fi/nodeup/local/BUILD.bazel | 5 +---- upup/pkg/fi/nodeup/nodetasks/BUILD.bazel | 2 +- 6 files changed, 3 insertions(+), 12 deletions(-) diff --git a/nodeup/pkg/bootstrap/BUILD.bazel b/nodeup/pkg/bootstrap/BUILD.bazel index 0d6f7e2e1763c..555f077dddaf9 100644 --- a/nodeup/pkg/bootstrap/BUILD.bazel +++ b/nodeup/pkg/bootstrap/BUILD.bazel @@ -12,7 +12,6 @@ go_library( "//upup/pkg/fi/nodeup/local:go_default_library", "//upup/pkg/fi/nodeup/nodetasks:go_default_library", "//util/pkg/vfs:go_default_library", - "//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/nodeup/pkg/distros/BUILD.bazel b/nodeup/pkg/distros/BUILD.bazel index d4215cbbf3113..5d8fa86cdced3 100644 --- a/nodeup/pkg/distros/BUILD.bazel +++ b/nodeup/pkg/distros/BUILD.bazel @@ -8,8 +8,5 @@ go_library( ], importpath = "k8s.io/kops/nodeup/pkg/distros", visibility = ["//visibility:public"], - deps = [ - "//upup/pkg/fi/nodeup/tags:go_default_library", - "//vendor/k8s.io/klog:go_default_library", - ], + deps = ["//vendor/k8s.io/klog:go_default_library"], ) diff --git a/upup/pkg/fi/nodeup/BUILD.bazel b/upup/pkg/fi/nodeup/BUILD.bazel index a1dfa3daa88ce..4645532fdc5d1 100644 --- a/upup/pkg/fi/nodeup/BUILD.bazel +++ b/upup/pkg/fi/nodeup/BUILD.bazel @@ -27,7 +27,6 @@ go_library( "//vendor/github.com/aws/aws-sdk-go/aws:go_default_library", "//vendor/github.com/aws/aws-sdk-go/aws/session:go_default_library", "//vendor/github.com/aws/aws-sdk-go/service/ec2:go_default_library", - "//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/upup/pkg/fi/nodeup/cloudinit/BUILD.bazel b/upup/pkg/fi/nodeup/cloudinit/BUILD.bazel index 2afbd76fcb371..16138f75e3515 100644 --- a/upup/pkg/fi/nodeup/cloudinit/BUILD.bazel +++ b/upup/pkg/fi/nodeup/cloudinit/BUILD.bazel @@ -8,7 +8,6 @@ go_library( deps = [ "//upup/pkg/fi:go_default_library", "//upup/pkg/fi/utils:go_default_library", - "//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/upup/pkg/fi/nodeup/local/BUILD.bazel b/upup/pkg/fi/nodeup/local/BUILD.bazel index 556169aeadbce..00eef0dcffbab 100644 --- a/upup/pkg/fi/nodeup/local/BUILD.bazel +++ b/upup/pkg/fi/nodeup/local/BUILD.bazel @@ -5,8 +5,5 @@ go_library( srcs = ["local_target.go"], importpath = "k8s.io/kops/upup/pkg/fi/nodeup/local", visibility = ["//visibility:public"], - deps = [ - "//upup/pkg/fi:go_default_library", - "//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library", - ], + deps = ["//upup/pkg/fi:go_default_library"], ) diff --git a/upup/pkg/fi/nodeup/nodetasks/BUILD.bazel b/upup/pkg/fi/nodeup/nodetasks/BUILD.bazel index 33f9f08259789..676e74f8cc7ea 100644 --- a/upup/pkg/fi/nodeup/nodetasks/BUILD.bazel +++ b/upup/pkg/fi/nodeup/nodetasks/BUILD.bazel @@ -20,6 +20,7 @@ go_library( importpath = "k8s.io/kops/upup/pkg/fi/nodeup/nodetasks", visibility = ["//visibility:public"], deps = [ + "//nodeup/pkg/distros:go_default_library", "//pkg/apis/kops:go_default_library", "//pkg/backoff:go_default_library", "//pkg/kubeconfig:go_default_library", @@ -27,7 +28,6 @@ go_library( "//upup/pkg/fi:go_default_library", "//upup/pkg/fi/nodeup/cloudinit:go_default_library", "//upup/pkg/fi/nodeup/local:go_default_library", - "//upup/pkg/fi/nodeup/tags:go_default_library", "//upup/pkg/fi/utils:go_default_library", "//util/pkg/hashing:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library", From ec8bb515c9055faeebe0f495ee69d201e3cbd4c8 Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Wed, 12 Aug 2020 15:00:12 +0300 Subject: [PATCH 3/5] Update packages --- hack/.packages | 1 - 1 file changed, 1 deletion(-) diff --git a/hack/.packages b/hack/.packages index d4b076ed44210..0c713ab385b96 100644 --- a/hack/.packages +++ b/hack/.packages @@ -186,7 +186,6 @@ k8s.io/kops/upup/pkg/fi/nodeup k8s.io/kops/upup/pkg/fi/nodeup/cloudinit k8s.io/kops/upup/pkg/fi/nodeup/local k8s.io/kops/upup/pkg/fi/nodeup/nodetasks -k8s.io/kops/upup/pkg/fi/nodeup/tags k8s.io/kops/upup/pkg/fi/secrets k8s.io/kops/upup/pkg/fi/utils k8s.io/kops/upup/pkg/kutil From d70fb506e5e723c8ce68dd1c355eee566452d98e Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Wed, 12 Aug 2020 15:32:45 +0300 Subject: [PATCH 4/5] Remove unused FSRoot from NodeUp --- cmd/nodeup/main.go | 2 -- nodeup/pkg/bootstrap/install.go | 3 +-- upup/pkg/fi/nodeup/command.go | 7 +------ 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/cmd/nodeup/main.go b/cmd/nodeup/main.go index e94796727e7f1..e89da898c4478 100644 --- a/cmd/nodeup/main.go +++ b/cmd/nodeup/main.go @@ -101,7 +101,6 @@ func main() { i := bootstrap.Installation{ CacheDir: flagCacheDir, Command: command, - FSRoot: flagRootFS, } i.RunTasksOptions.InitDefaults() i.RunTasksOptions.MaxTaskDuration = 5 * time.Minute @@ -115,7 +114,6 @@ func main() { ConfigLocation: flagConf, Target: target, CacheDir: flagCacheDir, - FSRoot: flagRootFS, } err = cmd.Run(os.Stdout) if err == nil { diff --git a/nodeup/pkg/bootstrap/install.go b/nodeup/pkg/bootstrap/install.go index 675e828537d1e..2e5349bb6fa75 100644 --- a/nodeup/pkg/bootstrap/install.go +++ b/nodeup/pkg/bootstrap/install.go @@ -32,14 +32,13 @@ import ( ) type Installation struct { - FSRoot string CacheDir string RunTasksOptions fi.RunTasksOptions Command []string } func (i *Installation) Run() error { - _, err := distros.FindDistribution(i.FSRoot) + _, err := distros.FindDistribution("/") if err != nil { return fmt.Errorf("error determining OS distribution: %v", err) } diff --git a/upup/pkg/fi/nodeup/command.go b/upup/pkg/fi/nodeup/command.go index b9c5e1b81fa94..43df77a21d2dc 100644 --- a/upup/pkg/fi/nodeup/command.go +++ b/upup/pkg/fi/nodeup/command.go @@ -56,7 +56,6 @@ const MaxTaskDuration = 365 * 24 * time.Hour type NodeUpCommand struct { CacheDir string ConfigLocation string - FSRoot string Target string cluster *api.Cluster config *nodeup.Config @@ -65,10 +64,6 @@ type NodeUpCommand struct { // Run is responsible for perform the nodeup process func (c *NodeUpCommand) Run(out io.Writer) error { - if c.FSRoot == "" { - return fmt.Errorf("FSRoot is required") - } - if c.ConfigLocation != "" { config, err := vfs.Context.ReadFile(c.ConfigLocation) if err != nil { @@ -162,7 +157,7 @@ func (c *NodeUpCommand) Run(out io.Writer) error { return fmt.Errorf("error determining OS architecture: %v", err) } - distribution, err := distros.FindDistribution(c.FSRoot) + distribution, err := distros.FindDistribution("/") if err != nil { return fmt.Errorf("error determining OS distribution: %v", err) } From b913e35da6e7f833194a49b555f3b5ea6f09dca5 Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Thu, 13 Aug 2020 08:37:51 +0300 Subject: [PATCH 5/5] Remove also the flagRootFS flag from NodeUp --- cmd/nodeup/main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/nodeup/main.go b/cmd/nodeup/main.go index e89da898c4478..62b5c6f07886c 100644 --- a/cmd/nodeup/main.go +++ b/cmd/nodeup/main.go @@ -36,7 +36,7 @@ const ( func main() { klog.InitFlags(nil) - var flagConf, flagCacheDir, flagRootFS, gitVersion string + var flagConf, flagCacheDir, gitVersion string var flagRetries int var dryrun, installSystemdUnit bool target := "direct" @@ -47,7 +47,6 @@ func main() { fmt.Printf("nodeup version %s%s\n", kops.Version, gitVersion) flag.StringVar(&flagConf, "conf", "node.yaml", "configuration location") flag.StringVar(&flagCacheDir, "cache", "/var/cache/nodeup", "the location for the local asset cache") - flag.StringVar(&flagRootFS, "rootfs", "/", "the location of the machine root (for running in a container)") flag.IntVar(&flagRetries, "retries", -1, "maximum number of retries on failure: -1 means retry forever") flag.BoolVar(&dryrun, "dryrun", false, "Don't create cloud resources; just show what would be done") flag.StringVar(&target, "target", target, "Target - direct, cloudinit")