Skip to content

Commit

Permalink
Rebase fixes: go mod tidy, copyright messages
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Sakhnov <[email protected]>
  • Loading branch information
Mikhail Sakhnov authored and twz123 committed Sep 12, 2023
1 parent 8e7063d commit ce2b760
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
7 changes: 3 additions & 4 deletions pkg/component/controller/windowsstackcomponent.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,19 @@ func (n *WindowsStackComponent) handleWindowsNode(ctx context.Context, cfg windo
if err := n.createWindowsStack(n.prevRenderingContext); err != nil {
n.log.Errorf("failed to create windows stack: %v", err)
return fmt.Errorf("failed to create windows stack: %v", err)
} else {
n.log.Infof("successfully created windows stack")
}
n.log.Infof("successfully created windows stack")
return nil
}

func (n *WindowsStackComponent) Reconcile(_ context.Context, cfg *v1beta1.ClusterConfig) error {
if cfg.Spec.Network.Provider != "calico" {
return fmt.Errorf("windows node controller available only for %s", constant.CNIProviderCalico)
return nil
}

existingCNI := existingCNIProvider(n.k0sVars.ManifestsDir)
if existingCNI != "" && existingCNI != constant.CNIProviderCalico {
return fmt.Errorf("windows node controller available only for %s", constant.CNIProviderCalico)
return nil
}
newConfig, err := n.makeRenderingContext(cfg)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/worker/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ type ContainerD struct {
K0sVars *config.CfgVars
Profile *workerconfig.Profile
binaries []string
OCIBundlePath string
confPath string
importsPath string
OCIBundlePath string
}

func NewContainerd(logLevel string, vars *config.CfgVars, profile *workerconfig.Profile) *ContainerD {
Expand Down
20 changes: 18 additions & 2 deletions pkg/node/nodehostname.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2023 k0s 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 node

import (
Expand Down Expand Up @@ -40,14 +56,14 @@ func getHostnameFromAwsMeta(url string) string {
return s
}

func getNodeNameWindows(override string, metadataUrl string) (string, error) {
func getNodeNameWindows(override string, metadataURL string) (string, error) {
// if we have explicit hostnameOverride, we use it as is even on windows
if override != "" {
return nodeutil.GetHostname(override)
}

// we need to check if we have EC2 dns name available
if h := getHostnameFromAwsMeta(metadataUrl); h != "" {
if h := getHostnameFromAwsMeta(metadataURL); h != "" {
return h, nil
}
// otherwise we use the k8s hostname helper
Expand Down
20 changes: 18 additions & 2 deletions pkg/node/nodehostname_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2023 k0s 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 node

import (
Expand Down Expand Up @@ -53,12 +69,12 @@ func TestGetNodename(t *testing.T) {
func startFakeMetadataServer(listenOn string) {
go func() {
http.HandleFunc("/latest/meta-data/local-hostname", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("some-hostname-from-metadata"))
_, _ = w.Write([]byte("some-hostname-from-metadata"))
w.WriteHeader(http.StatusOK)
})
http.HandleFunc("/not-found", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
})
http.ListenAndServe(listenOn, nil)
_ = http.ListenAndServe(listenOn, nil)
}()
}

0 comments on commit ce2b760

Please sign in to comment.