Skip to content

Commit

Permalink
Merge pull request #26 from rafaelvanoni/rafael-pod2daemon-2
Browse files Browse the repository at this point in the history
Re-enable golangci-lint
  • Loading branch information
caseydavenport authored Sep 5, 2019
2 parents 4ab7eba + d437941 commit 31e26d1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,8 @@ sub-tag-images-%:
###############################################################################
## Perform static checks on the code.
.PHONY: static-checks

# TODO: re-enable these linters !
LINT_ARGS := --disable typecheck,errcheck,ineffassign,gosimple,staticcheck

static-checks:
$(DOCKER_RUN) $(CALICO_BUILD) golangci-lint run --deadline 5m $(LINT_ARGS)
$(DOCKER_RUN) $(CALICO_BUILD) golangci-lint run --deadline 5m

.PHONY: fix
## Fix static checks
Expand Down
1 change: 0 additions & 1 deletion binder/creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func (s *workloadStore) delete(uid string) {
s.mu.Lock()
defer s.mu.Unlock()
delete(s.creds, uid)
return
}

func (s *workloadStore) store(uid string, w workload) {
Expand Down
49 changes: 33 additions & 16 deletions flexvol/flexvoldriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,14 @@ func doMount(destinationDir string, ninputs *creds.Credentials, workloadPath str
err = os.MkdirAll(newDestianationDir, 0777)
if err != nil {
cmd := exec.Command("/bin/unmount", destinationDir)
cmd.Run()
os.RemoveAll(newDir)
e := cmd.Run()
if e != nil {
_ = logWriter.Warning(fmt.Sprintf("failed to unmount %s\n", destinationDir))
}
e = os.RemoveAll(newDir)
if e != nil {
_ = logWriter.Warning(fmt.Sprintf("failed to clear %s\n", newDir))
}
return err
}

Expand All @@ -238,8 +244,14 @@ func doMount(destinationDir string, ninputs *creds.Credentials, workloadPath str
err = cmd.Run()
if err != nil {
cmd = exec.Command("/bin/umount", destinationDir)
cmd.Run()
os.RemoveAll(newDir)
e := cmd.Run()
if e != nil {
_ = logWriter.Warning(fmt.Sprintf("failed to unmount %s\n", destinationDir))
}
e = os.RemoveAll(newDir)
if e != nil {
_ = logWriter.Warning(fmt.Sprintf("failed to clear %s\n", newDir))
}
return err
}

Expand All @@ -262,7 +274,7 @@ func mount(dir, opts string) error {
inp := strings.Join([]string{dir, opts}, "|")

ninputs, workloadPath, s := checkValidMountOpts(opts)
if s == false {
if !s {
return failure("mount", inp, "Incomplete inputs")
}

Expand Down Expand Up @@ -300,12 +312,18 @@ func unmount(dir string) error {
}

// unmount the bind mount
doUnmount(dir + "/nodeagent")
err := doUnmount(dir + "/nodeagent")
if err != nil {
_ = logWriter.Warning(fmt.Sprintf("failed to unmount %s/nodeagent\n", dir))
}
// unmount the tmpfs
doUnmount(dir)
err = doUnmount(dir)
if err != nil {
_ = logWriter.Warning(fmt.Sprintf("failed to unmount %s\n", dir))
}
// delete the directory that was created.
delDir := strings.Join([]string{configuration.NodeAgentWorkloadHomeDir, uid}, "/")
err := os.Remove(delDir)
err = os.Remove(delDir)
if err != nil {
emsgs = append(emsgs, fmt.Sprintf("unmount del failure %s: %s", delDir, err.Error()))
// go head and return ok.
Expand Down Expand Up @@ -365,17 +383,16 @@ func logToSys(caller, inp, opts string) {

opt := strings.Join([]string{caller, inp, opts}, "|")
if configuration.LogLevel == LOG_LEVEL_WARN {
logWriter.Warning(opt)
_ = logWriter.Warning(opt)
} else {
logWriter.Info(opt)
_ = logWriter.Info(opt)
}
}

// addCredentialFile is used to create a credential file when a workload with the flex-volume volume mounted is created.
func addCredentialFile(ninputs *creds.Credentials) error {
//Make the directory and then write the ninputs as json to it.
var err error
err = os.MkdirAll(configuration.NodeAgentCredentialsHomeDir, 0755)
err := os.MkdirAll(configuration.NodeAgentCredentialsHomeDir, 0755)
if err != nil {
return err
}
Expand All @@ -387,7 +404,7 @@ func addCredentialFile(ninputs *creds.Credentials) error {
}

credsFileTmp := strings.Join([]string{configuration.NodeAgentManagementHomeDir, ninputs.UID + ".json"}, "/")
err = ioutil.WriteFile(credsFileTmp, attrs, 0644)
_ = ioutil.WriteFile(credsFileTmp, attrs, 0644)

// Move it to the right location now.
credsFile := strings.Join([]string{configuration.NodeAgentCredentialsHomeDir, ninputs.UID + ".json"}, "/")
Expand All @@ -412,14 +429,14 @@ func initConfiguration() {

bytes, err := ioutil.ReadFile(CONFIG_FILE)
if err != nil {
logWriter.Warning(fmt.Sprintf("Not able to read %s: %s\n", CONFIG_FILE, err.Error()))
_ = logWriter.Warning(fmt.Sprintf("Not able to read %s: %s\n", CONFIG_FILE, err.Error()))
return
}

var config ConfigurationOptions
err = json.Unmarshal(bytes, &config)
if err != nil {
logWriter.Warning(fmt.Sprintf("Not able to parst %s: %s\n", CONFIG_FILE, err.Error()))
_ = logWriter.Warning(fmt.Sprintf("Not able to parst %s: %s\n", CONFIG_FILE, err.Error()))
return
}

Expand Down Expand Up @@ -478,6 +495,6 @@ func main() {
initConfiguration()

if err = rootCmd.Execute(); err != nil {
genericUnsupported("not supported", "", err.Error())
_ = genericUnsupported("not supported", "", err.Error())
}
}

0 comments on commit 31e26d1

Please sign in to comment.