Skip to content

Commit

Permalink
Merge pull request #9170 from johngmyers/cleanup-nodetasks
Browse files Browse the repository at this point in the history
Remove loader support for nodeup tasks not used in models
  • Loading branch information
k8s-ci-robot authored May 27, 2020
2 parents 92f8e22 + 4e68ba9 commit fc48d06
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 233 deletions.
6 changes: 0 additions & 6 deletions upup/pkg/fi/nodeup/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ func (l *Loader) Build(baseDir vfs.Path) (map[string]fi.Task, error) {
DefaultHandler: ignoreHandler,
Contexts: map[string]loader.Handler{
"files": ignoreHandler,
"disks": ignoreHandler,
"packages": ignoreHandler,
"services": ignoreHandler,
"users": ignoreHandler,
},
Tags: l.tags,
}
Expand All @@ -115,10 +112,7 @@ func (l *Loader) Build(baseDir vfs.Path) (map[string]fi.Task, error) {
DefaultHandler: l.handleFile,
Contexts: map[string]loader.Handler{
"files": l.handleFile,
"disks": l.newTaskHandler("disk/", nodetasks.NewMountDiskTask),
"packages": l.newTaskHandler("package/", nodetasks.NewPackage),
"services": l.newTaskHandler("service/", nodetasks.NewService),
"users": l.newTaskHandler("user/", nodetasks.NewUserTask),
},
Tags: l.tags,
}
Expand Down
3 changes: 0 additions & 3 deletions upup/pkg/fi/nodeup/nodetasks/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ go_library(
"file.go",
"group.go",
"load_image.go",
"mount_disk.go",
"package.go",
"service.go",
"update_packages.go",
Expand All @@ -29,8 +28,6 @@ go_library(
"//util/pkg/hashing:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/utils/exec:go_default_library",
"//vendor/k8s.io/utils/mount:go_default_library",
],
)

Expand Down
10 changes: 6 additions & 4 deletions upup/pkg/fi/nodeup/nodetasks/archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ func TestArchiveDependencies(t *testing.T) {
child fi.Task
}{
{
parent: &MountDiskTask{
Mountpoint: "/",
parent: &File{
Path: "/var",
Type: FileType_Directory,
},
child: &Archive{
TargetDir: "/var/something",
Expand All @@ -39,8 +40,9 @@ func TestArchiveDependencies(t *testing.T) {
parent: &Archive{
TargetDir: "/var/something",
},
child: &MountDiskTask{
Mountpoint: "/var/something/subdir",
child: &File{
Path: "/var/something/subdir",
Type: FileType_Directory,
},
},
}
Expand Down
10 changes: 0 additions & 10 deletions upup/pkg/fi/nodeup/nodetasks/bindmount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,6 @@ func TestBindMountDependencies(t *testing.T) {
parent fi.Task
child fi.Task
}{
{
parent: &MountDiskTask{
Mountpoint: "/",
},
child: &BindMount{
Source: containerizedMounterHome,
Mountpoint: containerizedMounterHome,
Options: []string{"exec"},
},
},
{
parent: &File{
Path: containerizedMounterHome,
Expand Down
9 changes: 0 additions & 9 deletions upup/pkg/fi/nodeup/nodetasks/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,6 @@ func (e *File) GetDependencies(tasks map[string]fi.Task) []fi.Task {
}
}

// Depend on disk mounts
// For simplicity, we just depend on _all_ disk mounts
// We could check the mountpath, but that feels excessive...
for _, v := range tasks {
if _, ok := v.(*MountDiskTask); ok {
deps = append(deps, v)
}
}

// Requires parent directories to be created
deps = append(deps, findCreatesDirParents(e.Path, tasks)...)

Expand Down
171 changes: 0 additions & 171 deletions upup/pkg/fi/nodeup/nodetasks/mount_disk.go

This file was deleted.

19 changes: 1 addition & 18 deletions upup/pkg/fi/nodeup/nodetasks/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package nodetasks

import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
Expand Down Expand Up @@ -71,7 +70,7 @@ func (p *Service) GetDependencies(tasks map[string]fi.Task) []fi.Task {
// launching a custom Kubernetes build), they all depend on
// the "docker.service" Service task.
switch v.(type) {
case *File, *Package, *UpdatePackages, *UserTask, *GroupTask, *MountDiskTask, *Chattr, *BindMount, *Archive:
case *File, *Package, *UpdatePackages, *UserTask, *GroupTask, *Chattr, *BindMount, *Archive:
deps = append(deps, v)
case *Service, *LoadImageTask:
// ignore
Expand All @@ -87,22 +86,6 @@ func (s *Service) String() string {
return fmt.Sprintf("Service: %s", s.Name)
}

func NewService(name string, contents string, meta string) (fi.Task, error) {
s := &Service{Name: name}
s.Definition = fi.String(contents)

if meta != "" {
err := json.Unmarshal([]byte(meta), s)
if err != nil {
return nil, fmt.Errorf("error parsing json for service %q: %v", name, err)
}
}

s.InitDefaults()

return s, nil
}

func (s *Service) InitDefaults() *Service {
// Default some values to true: Running, SmartRestart, ManageState
if s.Running == nil {
Expand Down
12 changes: 0 additions & 12 deletions upup/pkg/fi/nodeup/nodetasks/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"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/utils"
)

// UserTask is responsible for creating a user, by calling useradd
Expand Down Expand Up @@ -54,17 +53,6 @@ func (f *UserTask) SetName(name string) {
klog.Fatalf("SetName not supported for User task")
}

func NewUserTask(name string, contents string, meta string) (fi.Task, error) {
s := &UserTask{Name: name}

err := utils.YamlUnmarshal([]byte(contents), s)
if err != nil {
return nil, fmt.Errorf("error parsing json for service %q: %v", name, err)
}

return s, nil
}

func (e *UserTask) Find(c *fi.Context) (*UserTask, error) {
info, err := fi.LookupUser(e.Name)
if err != nil {
Expand Down

0 comments on commit fc48d06

Please sign in to comment.