Skip to content

Commit

Permalink
Don't check if artifact exists (#16)
Browse files Browse the repository at this point in the history
1. Skip checking if the FUSE adapter exists
2. Force install of RPM in case it exists
3. Capitalize some logs
4. Add some logs
  • Loading branch information
pavius authored Oct 31, 2018
1 parent c79edb9 commit 82b50a9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
RPM_PATH = "iguazio_yum"
DEB_PATH = "iguazio_deb"
BINARY_NAME = "igz-fuse"
RELEASE_VERSION = "0.5.1"
RELEASE_VERSION = "0.5.2"
DOCKER_HUB_USER = "iguaziodocker"

.PHONY: build
Expand Down
4 changes: 2 additions & 2 deletions hack/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ echo "Installing v3io-fuse package"
echo "$(date) - Installing v3io-fuse package" >> /tmp/init.log

if [ "${HAS_YUM}" == "0" ]; then
echo "$(date) - Installing v3io-fuse package using 'rpm -ivh ${LIBS_DIR}/${PACKAGE_NAME}.rpm'" >> /tmp/init.log
rpm -ivh ${LIBS_DIR}/${PACKAGE_NAME}.rpm &>> /tmp/init.log
echo "$(date) - Installing v3io-fuse package using 'rpm -ivh --force ${LIBS_DIR}/${PACKAGE_NAME}.rpm'" >> /tmp/init.log
rpm -ivh --force ${LIBS_DIR}/${PACKAGE_NAME}.rpm &>> /tmp/init.log
else
echo "$(date) - Installing v3io-fuse package using 'dpkg -i ${LIBS_DIR}/${PACKAGE_NAME}.deb'" >> /tmp/init.log
dpkg -i ${LIBS_DIR}/${PACKAGE_NAME}.deb &>> /tmp/init.log
Expand Down
39 changes: 18 additions & 21 deletions pkg/flex/mounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (m *Mounter) doMount(targetPath string) *Response {
}
mountCmd := exec.Command(m.Config.FusePath, args...)

journal.Debug("calling mount command", "path", mountCmd.Path, "args", mountCmd.Args)
journal.Debug("Calling mount command", "path", mountCmd.Path, "args", mountCmd.Args)
if err := mountCmd.Start(); err != nil {
return Fail(fmt.Sprintf("Could not mount: %s", m.Target), err)
}
Expand All @@ -51,7 +51,7 @@ func (m *Mounter) doMount(targetPath string) *Response {
}

func (m *Mounter) osMount() *Response {
journal.Info("calling osMount command", "target", m.Target)
journal.Info("Calling osMount command", "target", m.Target)
if isStaleMount(m.Target) {
unmountCmd := exec.Command("umount", m.Target)
out, err := unmountCmd.CombinedOutput()
Expand All @@ -74,11 +74,11 @@ func (m *Mounter) Mount() *Response {
}

func (m *Mounter) mountAsLink() *Response {
journal.Info("calling mountAsLink command", "target", m.Target)
journal.Info("Calling mountAsLink command", "target", m.Target)
targetPath := path.Join("/mnt/v3io", m.Spec.Namespace, m.Spec.Container)
response := &Response{}
if !isMountPoint(targetPath) {
journal.Debug("creating folder", "target", targetPath)
journal.Debug("Creating folder", "target", targetPath)
os.MkdirAll(targetPath, 0755)
response = m.doMount(targetPath)
}
Expand All @@ -93,18 +93,18 @@ func (m *Mounter) mountAsLink() *Response {
}

func (m *Mounter) unmountAsLink() *Response {
journal.Info("calling unmountAsLink command", "target", m.Target)
journal.Info("Calling unmountAsLink command", "target", m.Target)
if err := os.Remove(m.Target); err != nil {
return Fail("unable to remove link", err)
}
return Success("link removed")
}

func (m *Mounter) osUmount() *Response {
journal.Info("calling osUmount command", "target", m.Target)
journal.Info("Calling osUmount command", "target", m.Target)
if isMountPoint(m.Target) {
cmd := exec.Command("umount", m.Target)
journal.Debug("calling umount command", "path", cmd.Path, "args", cmd.Args)
journal.Debug("Calling umount command", "path", cmd.Path, "args", cmd.Args)
if err := cmd.Start(); err != nil {
return Fail("could not unmount", err)
}
Expand Down Expand Up @@ -133,7 +133,7 @@ func NewMounter(target, options string) (*Mounter, error) {
return nil, err
}
}
journal.Debug("reading config")
journal.Debug("Reading config")
config, err := ReadConfig()
if err != nil {
return nil, err
Expand Down Expand Up @@ -164,23 +164,20 @@ func Unmount(target string) *Response {
}

func Init() *Response {
journal.Info("calling init command")
journal.Info("Initializing")
config, err := ReadConfig()
if err != nil {
return Fail("Initialization script failed to read config", err)
}
_, staterr := os.Stat(config.FusePath)
if staterr != nil {
if os.IsNotExist(staterr) {
location := path.Dir(os.Args[0])
command := exec.Command("/bin/bash", path.Join(location, "install.sh"))
journal.Debug("calling install command", "path", command.Path, "args", command.Args)
if err := command.Run(); err != nil {
return Fail("Initialization script failed", err)
}
} else {
return Fail("Initialization script failed to get fuse status", staterr)
}

journal.Debug("Preparing to run install", config.FusePath)

location := path.Dir(os.Args[0])
command := exec.Command("/bin/bash", path.Join(location, "install.sh"))

journal.Debug("Calling install command", "path", command.Path, "args", command.Args)
if err := command.Run(); err != nil {
return Fail("Initialization script failed", err)
}

resp := Success("Initialization completed")
Expand Down
8 changes: 5 additions & 3 deletions pkg/flex/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
)

func ReadConfig() (*Config, error) {
journal.Debug("Reading config", "path", v3ioConfig)
content, err := ioutil.ReadFile(v3ioConfig)
if err != nil {
return nil, err
Expand All @@ -34,6 +35,7 @@ func ReadConfig() (*Config, error) {
if err := json.Unmarshal(content, &config); err != nil {
return nil, err
}
journal.Debug("Config read", "config", string(content))
return &config, nil
}

Expand Down Expand Up @@ -92,7 +94,7 @@ func (c *Config) Session(cluster, username, password, plane string) (string, err
return "", err
}
payload := strings.NewReader(fmt.Sprintf(v3ioSessionPayloadTemplate, plane, username, password))
journal.Debug("creating session", "plane", plane, "url", fmt.Sprintf("%s/api/sessions", clusterConfig.ApiUrl))
journal.Debug("Creating session", "plane", plane, "url", fmt.Sprintf("%s/api/sessions", clusterConfig.ApiUrl))
response, err := http.Post(
fmt.Sprintf("%s/api/sessions", clusterConfig.ApiUrl),
"application/json",
Expand All @@ -105,15 +107,15 @@ func (c *Config) Session(cluster, username, password, plane string) (string, err
if err != nil {
return "", err
}
journal.Debug("result from creating session", "status", response.Status, "body", string(bodyBytes))
journal.Debug("Result from creating session", "status", response.Status, "body", string(bodyBytes))
if response.StatusCode != 201 {
return "", fmt.Errorf("error creating session. %d : %s", response.StatusCode, response.Status)
}
responseM := sessionResponse{}
if err := json.Unmarshal(bodyBytes, &responseM); err != nil {
return "", err
}
journal.Info("created session id", responseM.Data.Id)
journal.Info("Created session id", responseM.Data.Id)
return responseM.Data.Id, nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/flex/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ func MakeResponse(status, message string) *Response {
}

func Success(message string) *Response {
journal.Info("Success", "message", message)

return MakeResponse("Success", message)
}

func Fail(message string, err error) *Response {
journal.Warn("Failed", "message", message, "err", err.Error())

if err != nil {
return MakeResponse("Failure", fmt.Sprintf("%s. %s", message, err))
}
Expand Down

0 comments on commit 82b50a9

Please sign in to comment.