Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Improvements and fixes to ship watch #432

Merged
merged 1 commit into from
Aug 21, 2018
Merged

Improvements and fixes to ship watch #432

merged 1 commit into from
Aug 21, 2018

Conversation

dexhorthy
Copy link
Member

@dexhorthy dexhorthy commented Aug 21, 2018

What I Did

Improve and fix some things with ship watch, Resolve #428

$ bin/ship watch --interval 30s
github.com/dexhorthy/sysdigcloud-kubernetes/sysdigcloud has an update available

How I Did it

  • apptype.Inspector no longer moves the cloned assets up from .ship/tmp into "base" or "chart"
  • resolver.ResolveRelease handles moving chart up from .ship/tmp into "base" or "chart"
  • remove defer os.RemoveAll in apptype.Inspector, is in .ship/tmp now, so it will get cleaned up eventually
  • more/better debug logging in ship watch
  • bind viper flags in cli/watch.go so viper.GetDuration("interval") works in watch command
  • added some UI output for ship watch

Other stuff:

  • move watch and update into their own files
  • clean .ship/tmp on startup in case its hanging around

How to verify it

ship init ...; ship watch --interval 30s

Description for the Changelog

Add configurable interval for ship watch via --interval flag

What I Did

How I Did it

How to verify it

Description for the Changelog

Picture of a Boat (not required but encouraged)

@dexhorthy dexhorthy requested a review from laverya August 21, 2018 19:19
@@ -52,107 +37,48 @@ func (s *Ship) stateFileExists(ctx context.Context) bool {
return !noExistingState
}

func (s *Ship) Update(ctx context.Context) error {
debug := level.Debug(log.With(s.Logger, "method", "update"))
func (s *Ship) Init(ctx context.Context) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the diff on this file looks weird because I moved update/watch out of here. I recommend side-by-side

}
}

func (s *Ship) Update(ctx context.Context) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no changes here, just moved

return errors.New(`No current SHA found at ` + s.Viper.GetString("state-file") + `, please run "ship init"`)
}

debug.Log("event", "fetch latest chart")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new stuff starts here

defaultSpec *api.Spec,
) (*api.Release, error) {
debug := log.With(level.Debug(r.Logger), "method", "resolveChart")

metadata, err := r.resolveMetadata(context.Background(), upstream, localPath)
err := util.BackupIfPresent(r.FS, destPath, debug, r.ui)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this backup/rename logic got moved up out of determineApplicationType

@@ -60,6 +60,7 @@ var _ = Describe("ship app", func() {
var testMetadata TestMetadata

BeforeEach(func() {
os.Setenv("NO_OS_EXIT", "1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we store this and restore it after the integration tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we'd need to do that? I don't think it persists into the parent process?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Might be a good thing to check when running with ginkgo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(or I'm being silly, sorry)

What I Did
------------

Improve and fix some things with `ship watch`, Resolve #428

```
$ bin/ship watch --interval 30s
github.com/dexhorthy/sysdigcloud-kubernetes/sysdigcloud has an update available
```

How I Did it
------------

- apptype.Inspector no longer moves the cloned assets up from .ship/tmp into "base" or "k8s"
- resolver.ResolveRelease handles moving chart up from .ship/tmp into "base" or "chart"
- remove defer os.RemoveAll in apptype.Inspector, is in `.ship/tmp` now, so it will get cleaned up eventually
- more/better debug logging in `ship watch`
- bind viper flags in `cli/watch.go` so `viper.GetDuration("interval")` works in watch command
- added some UI output for ship watch

Other stuff:

- move watch and update into their own files
- clean .ship/tmp on startup  in case its hanging around

How to verify it
------------

`ship init ...; ship watch --interval 30s`

Description for the Changelog
------------

Add configurable interval for `ship watch` via `--interval` flag

![](https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/Shipwreck_%289558712326%29.jpg/120px-Shipwreck_%289558712326%29.jpg)
// if there's a Chart.yaml, assume its a chart
isChart, err := r.fs.Exists(path.Join(savePath, "Chart.yaml"))
if err != nil {
return "", "", errors.Wrap(err, "check for Chart.yaml")
}
debug.Log("event", "isChart.check", "isChart", isChart)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be before the check?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think its for writing the result of the check, hence the isChart field

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that makes sense

@dexhorthy dexhorthy merged commit f2f959a into replicatedhq:master Aug 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ship watch command stuck in irregular loop
2 participants