Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove loader support for nodeup tasks not used in models #9170

Merged
merged 1 commit into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
johngmyers marked this conversation as resolved.
Show resolved Hide resolved
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