Skip to content

Commit

Permalink
Remove InstanceGroup from NodeupModelContext
Browse files Browse the repository at this point in the history
  • Loading branch information
johngmyers committed Jun 17, 2020
1 parent a404b54 commit 28795a5
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 62 deletions.
17 changes: 8 additions & 9 deletions nodeup/pkg/model/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ import (

// NodeupModelContext is the context supplied the nodeup tasks
type NodeupModelContext struct {
Architecture architectures.Architecture
Assets *fi.AssetStore
Cluster *kops.Cluster
ConfigBase vfs.Path
Distribution distros.Distribution
InstanceGroup *kops.InstanceGroup
KeyStore fi.CAStore
NodeupConfig *nodeup.Config
SecretStore fi.SecretStore
Architecture architectures.Architecture
Assets *fi.AssetStore
Cluster *kops.Cluster
ConfigBase vfs.Path
Distribution distros.Distribution
KeyStore fi.CAStore
NodeupConfig *nodeup.Config
SecretStore fi.SecretStore

// IsMaster is true if the InstanceGroup has a role of master (populated by Init)
IsMaster bool
Expand Down
4 changes: 0 additions & 4 deletions nodeup/pkg/model/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,6 @@ func (b *KubeletBuilder) buildSystemdService() *nodetasks.Service {

// buildKubeletConfig is responsible for creating the kubelet configuration
func (b *KubeletBuilder) buildKubeletConfig() (*kops.KubeletConfigSpec, error) {
if b.InstanceGroup == nil {
klog.Fatalf("InstanceGroup was not set")
}

kubeletConfigSpec, err := b.buildKubeletConfigSpec()
if err != nil {
return nil, fmt.Errorf("error building kubelet config: %v", err)
Expand Down
13 changes: 5 additions & 8 deletions nodeup/pkg/model/kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ func Test_InstanceGroupKubeletMerge(t *testing.T) {

b := &KubeletBuilder{
&NodeupModelContext{
Cluster: cluster,
InstanceGroup: instanceGroup,
NodeupConfig: nodeup.NewConfig(cluster, instanceGroup),
Cluster: cluster,
NodeupConfig: nodeup.NewConfig(cluster, instanceGroup),
},
}
if err := b.Init(); err != nil {
Expand Down Expand Up @@ -91,9 +90,8 @@ func TestTaintsApplied(t *testing.T) {

b := &KubeletBuilder{
&NodeupModelContext{
Cluster: cluster,
InstanceGroup: ig,
NodeupConfig: nodeup.NewConfig(cluster, ig),
Cluster: cluster,
NodeupConfig: nodeup.NewConfig(cluster, ig),
},
}
if err := b.Init(); err != nil {
Expand Down Expand Up @@ -214,8 +212,7 @@ func BuildNodeupModelContext(basedir string) (*NodeupModelContext, error) {
if len(model.InstanceGroups) == 0 {
// We tolerate this - not all tests need an instance group
} else if len(model.InstanceGroups) == 1 {
nodeUpModelContext.InstanceGroup = model.InstanceGroups[0]
nodeUpModelContext.NodeupConfig = nodeup.NewConfig(model.Cluster, nodeUpModelContext.InstanceGroup)
nodeUpModelContext.NodeupConfig = nodeup.NewConfig(model.Cluster, model.InstanceGroups[0])
} else {
return nil, fmt.Errorf("unexpected number of instance groups in %s, found %d", basedir, len(model.InstanceGroups))
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/apis/nodeup/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ type Config struct {
ConfigBase *string `json:",omitempty"`
// ClusterLocation is the VFS path to the cluster spec (deprecated: prefer ConfigBase)
ClusterLocation *string `json:",omitempty"`
// InstanceGroupName is the name of the instance group
InstanceGroupName string `json:",omitempty"`
// InstanceGroupRole is the instance group role.
InstanceGroupRole kops.InstanceGroupRole
// ClusterName is the name of the cluster
Expand Down
10 changes: 0 additions & 10 deletions pkg/model/bootstrapscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,6 @@ func (b *BootstrapScript) ResourceNodeUp(ig *kops.InstanceGroup, cluster *kops.C
}
return string(content), nil
},

"IGSpec": func() (string, error) {
spec := make(map[string]interface{})

content, err := yaml.Marshal(spec)
if err != nil {
return "", fmt.Errorf("error converting instancegroup spec to yaml for inclusion within bootstrap script: %v", err)
}
return string(content), nil
},
}

awsNodeUpTemplate, err := resources.AWSNodeUpTemplate(ig)
Expand Down
4 changes: 0 additions & 4 deletions pkg/model/resources/nodeup.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ cat > conf/cluster_spec.yaml << '__EOF_CLUSTER_SPEC'
{{ ClusterSpec }}
__EOF_CLUSTER_SPEC
cat > conf/ig_spec.yaml << '__EOF_IG_SPEC'
{{ IGSpec }}
__EOF_IG_SPEC
cat > conf/kube_env.yaml << '__EOF_KUBE_ENV'
{{ KubeEnv }}
__EOF_KUBE_ENV
Expand Down
1 change: 0 additions & 1 deletion upup/pkg/fi/cloudup/apply_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,6 @@ func (c *ApplyClusterCmd) BuildNodeUpConfig(assetBuilder *assets.AssetBuilder, i
}
config.ClusterName = cluster.ObjectMeta.Name
config.ConfigBase = fi.String(configBase.Path())
config.InstanceGroupName = ig.ObjectMeta.Name

useGossip := dns.IsGossipHostname(cluster.Spec.MasterInternalName)
isMaster := role == kops.InstanceGroupRoleMaster
Expand Down
30 changes: 6 additions & 24 deletions upup/pkg/fi/nodeup/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ type NodeUpCommand struct {
Target string
cluster *api.Cluster
config *nodeup.Config
instanceGroup *api.InstanceGroup
}

// Run is responsible for perform the nodeup process
Expand Down Expand Up @@ -145,22 +144,6 @@ func (c *NodeUpCommand) Run(out io.Writer) error {
}
}

if c.config.InstanceGroupName != "" {
instanceGroupLocation := configBase.Join("instancegroup", c.config.InstanceGroupName)

c.instanceGroup = &api.InstanceGroup{}
b, err := instanceGroupLocation.ReadFile()
if err != nil {
return fmt.Errorf("error loading InstanceGroup %q: %v", instanceGroupLocation, err)
}

if err = utils.YamlUnmarshal(b, c.instanceGroup); err != nil {
return fmt.Errorf("error parsing InstanceGroup %q: %v", instanceGroupLocation, err)
}
} else {
klog.Warningf("No instance group defined in nodeup config")
}

err := evaluateSpec(c)
if err != nil {
return err
Expand Down Expand Up @@ -190,13 +173,12 @@ func (c *NodeUpCommand) Run(out io.Writer) error {
klog.Infof("Distro tags: %v", distroTags)

modelContext := &model.NodeupModelContext{
Architecture: architecture,
Assets: assetStore,
Cluster: c.cluster,
ConfigBase: configBase,
Distribution: distribution,
InstanceGroup: c.instanceGroup,
NodeupConfig: c.config,
Architecture: architecture,
Assets: assetStore,
Cluster: c.cluster,
ConfigBase: configBase,
Distribution: distribution,
NodeupConfig: c.config,
}

var secretStore fi.SecretStore
Expand Down

0 comments on commit 28795a5

Please sign in to comment.