Skip to content

Commit

Permalink
updated to syncthing 1.6.1 (#912)
Browse files Browse the repository at this point in the history
* updated to syncthing 1.6.1

Signed-off-by: Ramiro Berrelleza <rberrelleza@gmail.com>
  • Loading branch information
rberrelleza committed Jun 12, 2020
1 parent fbd1932 commit 3294c61
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 43 deletions.
2 changes: 1 addition & 1 deletion cmd/up.go
Expand Up @@ -780,6 +780,7 @@ func (up *UpContext) synchronizeFiles() error {
}

go up.Sy.Monitor(up.Context, up.Disconnect)
log.Infof("restarting syncthing to update sync mode to sendreceive")
return up.Sy.Restart(up.Context)
}

Expand Down Expand Up @@ -807,7 +808,6 @@ func (up *UpContext) cleanCommand() {
log.Infof("failed to clean session: %s", err)
}

log.Infof("watches: %s", out.String())
if utils.IsWatchesConfigurationTooLow(out.String()) {
log.Yellow("\nThe value of /proc/sys/fs/inotify/max_user_watches in your cluster nodes is too low.")
log.Yellow("This can affect Okteto's file synchronization performance.")
Expand Down
2 changes: 1 addition & 1 deletion images/bin/Dockerfile
@@ -1,6 +1,6 @@
# syntax = docker/dockerfile:experimental

FROM syncthing/syncthing:1.5.0 AS syncthing
FROM syncthing/syncthing:1.6.1 AS syncthing
FROM okteto/remote:0.2.5 AS remote
FROM okteto/supervisor:0.1.0 AS supervisor
FROM okteto/clean:0.1.0 AS clean
Expand Down
2 changes: 1 addition & 1 deletion main.go
Expand Up @@ -43,7 +43,7 @@ func init() {
func(e error) {

// Error when there's no service on the other side: an error occurred forwarding 8080 -> 8080: error forwarding port 8080 to pod df05e7e1c85d6b256df779c0b2deb417eb53a299c8581fc0945264301d8fa4b3, uid : exit status 1: 2020/03/16 02:11:09 socat[42490] E connect(5, AF=2 127.0.0.1:8080, 16): Connection refused\n
log.Debugf("unhandled error: %s", e)
log.Debugf("port-forward: %s", e)
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/k8s/deployments/crud.go
Expand Up @@ -310,7 +310,7 @@ func deleteUserAnnotations(annotations map[string]string, tr *model.Translation)

//Destroy destroys a k8s service
func Destroy(dev *model.Dev, c *kubernetes.Clientset) error {
log.Infof("deleting deployment '%s'...", dev.Name)
log.Infof("deleting deployment '%s'", dev.Name)
dClient := c.AppsV1().Deployments(dev.Namespace)
err := dClient.Delete(dev.Name, &metav1.DeleteOptions{GracePeriodSeconds: &devTerminationGracePeriodSeconds})
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions pkg/k8s/deployments/translate.go
Expand Up @@ -37,12 +37,10 @@ const (
oktetoBinName = "okteto-bin"

//syncthing
oktetoBinImageTag = "okteto/bin:1.1.18"
oktetoBinImageTag = "okteto/bin:1.1.19"
oktetoSyncSecretVolume = "okteto-sync-secret" // skipcq GSC-G101 not a secret
oktetoDevSecretVolume = "okteto-dev-secret" // skipcq GSC-G101 not a secret
oktetoSecretTemplate = "okteto-%s"

maxRetriesUpdateRevision = 150
)

var (
Expand Down
8 changes: 6 additions & 2 deletions pkg/k8s/pods/pod.go
Expand Up @@ -126,7 +126,11 @@ func GetDevPod(ctx context.Context, dev *model.Dev, c *kubernetes.Clientset, wai

rs, err := replicasets.GetReplicaSetByDeployment(dev, d, c)
if rs == nil {
log.Infof("failed to get replicaset with revision %v: %s ", d.Annotations[deploymentRevisionAnnotation], err)
if err == nil {
log.Infof("didn't find replicaset with revision %v", d.Annotations[deploymentRevisionAnnotation])
} else {
log.Infof("failed to get replicaset with revision %v: %s ", d.Annotations[deploymentRevisionAnnotation], err)
}
return nil, err
}

Expand Down Expand Up @@ -198,7 +202,7 @@ func MonitorDevPod(ctx context.Context, dev *model.Dev, pod *apiv1.Pod, c *kuber
if strings.Contains(e.Message, "pod has unbound immediate PersistentVolumeClaims") {
continue
}

return nil, fmt.Errorf(e.Message)
case "FailedAttachVolume", "FailedMount":
reporter <- fmt.Sprintf("%s: retrying", e.Message)
Expand Down
4 changes: 3 additions & 1 deletion pkg/k8s/secrets/configXML.go
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/okteto/okteto/pkg/syncthing"
)

const configXML = `<configuration version="29">
const configXML = `<configuration version="30">
<folder id="okteto-{{ .Dev.Name }}" label="{{ .Dev.Name }}" path="{{ .Dev.MountPath }}" type="sendreceive" rescanIntervalS="300" fsWatcherEnabled="true" fsWatcherDelayS="1" ignorePerms="false" autoNormalize="true">
<filesystemType>basic</filesystemType>
<device id="ABKAVQF-RUO4CYO-FSC2VIP-VRX4QDA-TQQRN2J-MRDXJUC-FXNWP6N-S6ZSAAR" introducedBy=""></device>
Expand Down Expand Up @@ -48,13 +48,15 @@ const configXML = `<configuration version="29">
<autoAcceptFolders>false</autoAcceptFolders>
<maxSendKbps>0</maxSendKbps>
<maxRecvKbps>0</maxRecvKbps>
<maxRequestKiB>0</maxRequestKiB>
</device>
<device id="ATOPHFJ-VPVLDFY-QVZDCF2-OQQ7IOW-OG4DIXF-OA7RWU3-ZYA4S22-SI4XVAU" name="remote" compression="metadata" introducer="false" skipIntroductionRemovals="false" introducedBy="">
<address>dynamic</address>
<paused>false</paused>
<autoAcceptFolders>false</autoAcceptFolders>
<maxSendKbps>0</maxSendKbps>
<maxRecvKbps>0</maxRecvKbps>
<maxRequestKiB>0</maxRequestKiB>
</device>
<gui enabled="true" tls="false" debugging="false">
<address>{{ .RemoteGUIAddress }}</address>
Expand Down
8 changes: 4 additions & 4 deletions pkg/k8s/services/crud.go
Expand Up @@ -35,14 +35,14 @@ func CreateDev(dev *model.Dev, c *kubernetes.Clientset) error {
sClient := c.CoreV1().Services(dev.Namespace)

if old.Name == "" {
log.Infof("creating service '%s'...", s.Name)
log.Infof("creating service '%s'", s.Name)
_, err = sClient.Create(s)
if err != nil {
return fmt.Errorf("error creating kubernetes service: %s", err)
}
log.Infof("created service '%s'.", s.Name)
log.Infof("created service '%s'", s.Name)
} else {
log.Infof("updating service '%s'...", s.Name)
log.Infof("updating service '%s'", s.Name)
old.Spec.Ports = s.Spec.Ports
_, err = sClient.Update(old)
if err != nil {
Expand All @@ -55,7 +55,7 @@ func CreateDev(dev *model.Dev, c *kubernetes.Clientset) error {

//DestroyDev destroys the default service for a dev environment
func DestroyDev(dev *model.Dev, c *kubernetes.Clientset) error {
log.Infof("deleting service '%s'...", dev.Name)
log.Infof("deleting service '%s'", dev.Name)
sClient := c.CoreV1().Services(dev.Namespace)
err := sClient.Delete(dev.Name, &metav1.DeleteOptions{})
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/k8s/volumes/crud.go
Expand Up @@ -41,7 +41,7 @@ func Create(ctx context.Context, dev *model.Dev, c *kubernetes.Clientset) error
if k8Volume.Name != "" {
return checkPVCValues(k8Volume, dev)
}
log.Infof("creating volume claim '%s'...", pvc.Name)
log.Infof("creating volume claim '%s'", pvc.Name)
_, err = vClient.Create(pvc)
if err != nil {
return fmt.Errorf("error creating kubernetes volume claim: %s", err)
Expand Down Expand Up @@ -84,7 +84,7 @@ func checkPVCValues(pvc *apiv1.PersistentVolumeClaim, dev *model.Dev) error {
//Destroy destroys the volume claim for a given dev environment
func Destroy(ctx context.Context, dev *model.Dev, c *kubernetes.Clientset) error {
vClient := c.CoreV1().PersistentVolumeClaims(dev.Namespace)
log.Infof("destroying volume claim '%s'...", dev.GetVolumeName())
log.Infof("destroying volume claim '%s'", dev.GetVolumeName())

ticker := time.NewTicker(1 * time.Second)
to := 3 * config.GetTimeout() // 90 seconds
Expand All @@ -110,7 +110,7 @@ func Destroy(ctx context.Context, dev *model.Dev, c *kubernetes.Clientset) error
}

if i%10 == 5 {
log.Infof("waiting for volume claim '%s' to be destroyed...", dev.GetVolumeName())
log.Infof("waiting for volume claim '%s' to be destroyed", dev.GetVolumeName())
}

select {
Expand Down
11 changes: 3 additions & 8 deletions pkg/syncthing/api.go
Expand Up @@ -21,8 +21,6 @@ import (
"net/http"
"path"
"time"

"github.com/okteto/okteto/pkg/log"
)

type addAPIKeyTransport struct {
Expand Down Expand Up @@ -69,15 +67,13 @@ func (s *Syncthing) APICall(ctx context.Context, url, method string, code int, p

resp, err := s.Client.Do(req)
if err != nil {
log.Infof("fail to call syncthing API at %s: %s", url, err)
return nil, fmt.Errorf("failed to call syncthing API: %w", err)
return nil, fmt.Errorf("failed to call syncthing [%s]: %w", url, err)
}

defer resp.Body.Close()

if resp.StatusCode != code {
log.Infof("unexpected response from syncthing API %s %d: %s", req.URL.String(), resp.StatusCode, string(body))
return nil, fmt.Errorf("unexpected response from syncthing API %s %d: %s", req.URL.String(), resp.StatusCode, string(body))
return nil, fmt.Errorf("unexpected response from syncthing [%s | %d]: %s", req.URL.String(), resp.StatusCode, string(body))
}

if !readBody {
Expand All @@ -86,8 +82,7 @@ func (s *Syncthing) APICall(ctx context.Context, url, method string, code int, p

body, err = ioutil.ReadAll(resp.Body)
if err != nil {
log.Infof("failed to read response from syncthing API at %s: %s", url, err)
return nil, fmt.Errorf("failed to read response from syncthing API")
return nil, fmt.Errorf("failed to read response from syncthing [%s]: %w", url, err)
}

return body, nil
Expand Down
6 changes: 4 additions & 2 deletions pkg/syncthing/configXML.go
Expand Up @@ -13,7 +13,7 @@

package syncthing

const configXML = `<configuration version="29">
const configXML = `<configuration version="30">
<folder id="okteto-{{ .Dev.Name }}" label="{{ .Dev.Name }}" path="{{ .Source }}" type="{{ .Type }}" rescanIntervalS="300" fsWatcherEnabled="true" fsWatcherDelayS="1" ignorePerms="false" autoNormalize="true">
<filesystemType>basic</filesystemType>
<device id="ABKAVQF-RUO4CYO-FSC2VIP-VRX4QDA-TQQRN2J-MRDXJUC-FXNWP6N-S6ZSAAR" introducedBy=""></device>
Expand Down Expand Up @@ -41,13 +41,15 @@ const configXML = `<configuration version="29">
<autoAcceptFolders>false</autoAcceptFolders>
<maxSendKbps>0</maxSendKbps>
<maxRecvKbps>0</maxRecvKbps>
<maxRequestKiB>0</maxRequestKiB>
</device>
<device id="{{.RemoteDeviceID}}" name="remote" compression="metadata" introducer="false" skipIntroductionRemovals="false" introducedBy="">
<address>{{.RemoteAddress}}</address>
<paused>false</paused>
<autoAcceptFolders>false</autoAcceptFolders>
<maxSendKbps>0</maxSendKbps>
<maxRecvKbps>0</maxRecvKbps>
<maxRequestKiB>0</maxRequestKiB>
</device>
<gui enabled="true" tls="false" debugging="false">
<address>{{.GUIAddress}}</address>
Expand All @@ -58,7 +60,7 @@ const configXML = `<configuration version="29">
</gui>
<ldap></ldap>
<options>
<listenAddress>{{.ListenAddress}}</listenAddress>
<listenAddress>tcp://{{.ListenAddress}}</listenAddress>
<globalAnnounceServer>default</globalAnnounceServer>
<globalAnnounceEnabled>false</globalAnnounceEnabled>
<localAnnounceEnabled>false</localAnnounceEnabled>
Expand Down
15 changes: 8 additions & 7 deletions pkg/syncthing/install.go
Expand Up @@ -29,15 +29,17 @@ import (
"github.com/okteto/okteto/pkg/model"
)

const syncthingVersion = "1.6.1"

var (
downloadURLs = map[string]string{
"linux": "https://github.com/syncthing/syncthing/releases/download/v1.5.0/syncthing-linux-amd64-v1.5.0.tar.gz",
"arm64": "https://github.com/syncthing/syncthing/releases/download/v1.5.0/syncthing-linux-arm64-v1.5.0.tar.gz",
"darwin": "https://github.com/syncthing/syncthing/releases/download/v1.5.0/syncthing-macos-amd64-v1.5.0.tar.gz",
"windows": "https://github.com/syncthing/syncthing/releases/download/v1.5.0/syncthing-windows-amd64-v1.5.0.zip",
"linux": fmt.Sprintf("https://github.com/syncthing/syncthing/releases/download/v%[1]s/syncthing-linux-amd64-v%[1]s.tar.gz", syncthingVersion),
"arm64": fmt.Sprintf("https://github.com/syncthing/syncthing/releases/download/v%[1]s/syncthing-linux-arm64-v%[1]s.tar.gz", syncthingVersion),
"darwin": fmt.Sprintf("https://github.com/syncthing/syncthing/releases/download/v%[1]s/syncthing-macos-amd64-v%[1]s.zip", syncthingVersion),
"windows": fmt.Sprintf("https://github.com/syncthing/syncthing/releases/download/v%[1]s/syncthing-windows-amd64-v%[1]s.zip", syncthingVersion),
}

minimumVersion = semver.MustParse("1.5.0")
minimumVersion = semver.MustParse(syncthingVersion)
versionRegex = regexp.MustCompile(`syncthing v(\d+\.\d+\.\d+) .*`)
)

Expand Down Expand Up @@ -73,7 +75,6 @@ func Install(p getter.ProgressTracker) error {
return fmt.Errorf("failed to download syncthing from %s: %s", client.Src, err)
}

log.Infof("downloaded syncthing from %s to %s", client.Src, dir)
i := getInstallPath()
b := getBinaryPathInDownload(dir, downloadURL)

Expand All @@ -96,7 +97,7 @@ func Install(p getter.ProgressTracker) error {
return fmt.Errorf("failed to write %s: %s", i, err)
}

log.Infof("downloaded syncthing %s to %s", versionRegex, i)
log.Infof("downloaded syncthing %s to %s", syncthingVersion, i)
return nil
}

Expand Down
17 changes: 8 additions & 9 deletions pkg/syncthing/syncthing.go
Expand Up @@ -287,18 +287,18 @@ func (s *Syncthing) Run(ctx context.Context) error {

//WaitForPing waits for synthing to be ready
func (s *Syncthing) WaitForPing(ctx context.Context, local bool) error {
ticker := time.NewTicker(100 * time.Millisecond)
ticker := time.NewTicker(300 * time.Millisecond)
to := config.GetTimeout() // 30 seconds
timeout := time.Now().Add(to)

log.Infof("waiting for syncthing local=%t to be ready...", local)
log.Infof("waiting for syncthing local=%t to be ready", local)
for i := 0; ; i++ {
_, err := s.APICall(ctx, "rest/system/ping", "GET", 200, nil, local, nil, false)
if err == nil {
return nil
}

log.Debugf("error calling 'rest/system/ping' syncthing local=%t API: %s", local, err)
log.Debugf("syncthing local=%t is not ready yet: %s", local, err)

if time.Now().After(timeout) {
return fmt.Errorf("syncthing local=%t not responding after 15s", local)
Expand All @@ -316,7 +316,7 @@ func (s *Syncthing) WaitForPing(ctx context.Context, local bool) error {

//SendStignoreFile sends .stignore from local to remote
func (s *Syncthing) SendStignoreFile(ctx context.Context, dev *model.Dev) {
log.Infof("sending '.stignore' file to the remote syncthing...")
log.Infof("sending '.stignore' file to the remote syncthing")
params := getFolderParameter(dev)
ignores := &Ignores{}
body, err := s.APICall(ctx, "rest/db/ignores", "GET", 200, params, true, nil, true)
Expand Down Expand Up @@ -352,7 +352,7 @@ func (s *Syncthing) SendStignoreFile(ctx context.Context, dev *model.Dev) {

//ResetDatabase resets the syncthing database
func (s *Syncthing) ResetDatabase(ctx context.Context, dev *model.Dev, local bool) error {
log.Infof("reseting syncthing database local=%t...", local)
log.Infof("reseting syncthing database local=%t", local)
params := getFolderParameter(dev)
_, err := s.APICall(ctx, "rest/system/reset", "POST", 200, params, local, nil, false)
if err != nil {
Expand All @@ -364,7 +364,7 @@ func (s *Syncthing) ResetDatabase(ctx context.Context, dev *model.Dev, local boo

//Overwrite overwrites local changes to the remote syncthing
func (s *Syncthing) Overwrite(ctx context.Context, dev *model.Dev) error {
log.Infof("overriding local changes to the remote syncthing...")
log.Infof("overriding local changes to the remote syncthing")
params := getFolderParameter(dev)
_, err := s.APICall(ctx, "rest/db/override", "POST", 200, params, true, nil, false)
if err != nil {
Expand All @@ -379,7 +379,7 @@ func (s *Syncthing) WaitForScanning(ctx context.Context, dev *model.Dev, local b
ticker := time.NewTicker(100 * time.Millisecond)
params := getFolderParameter(dev)
status := &Status{}
log.Infof("waiting for initial scan to complete local=%t...", local)
log.Infof("waiting for initial scan to complete local=%t", local)

to := config.GetTimeout() * 10 // 5 minutes
timeout := time.Now().Add(to)
Expand Down Expand Up @@ -424,7 +424,7 @@ func (s *Syncthing) WaitForScanning(ctx context.Context, dev *model.Dev, local b
func (s *Syncthing) WaitForCompletion(ctx context.Context, dev *model.Dev, reporter chan float64) error {
defer close(reporter)
ticker := time.NewTicker(500 * time.Millisecond)
log.Infof("waiting for synchronization to complete...")
log.Infof("waiting for synchronization to complete")
retries := 0
for {
select {
Expand Down Expand Up @@ -569,7 +569,6 @@ func (s *Syncthing) GetFolderErrors(ctx context.Context, dev *model.Dev, local b

// Restart restarts the syncthing process
func (s *Syncthing) Restart(ctx context.Context) error {
log.Infof("restarting syncthing...")
_, err := s.APICall(ctx, "rest/system/restart", "POST", 200, nil, true, nil, false)
return err
}
Expand Down

0 comments on commit 3294c61

Please sign in to comment.