Skip to content

Commit 02d0656

Browse files
jschwinger233CMGS
authored andcommitted
ensure features compatible with old version
1 parent 108be32 commit 02d0656

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

cluster/calcium/send.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ func (c *Calcium) Send(ctx context.Context, opts *types.SendOptions) (chan *type
4949
}
5050

5151
func (c *Calcium) doSendFileToWorkload(ctx context.Context, engine engine.API, ID string, file types.LinuxFile) error {
52-
log.Infof(ctx, "[doSendFileToWorkload] Send file to %s:%s", ID)
52+
log.Infof(ctx, "[doSendFileToWorkload] Send file to %s:%s", ID, file.Filename)
5353
return errors.WithStack(engine.VirtualizationCopyTo(ctx, ID, file.Filename, file.Clone().Content, file.UID, file.GID, file.Mode))
5454
}

engine/docker/tarfile.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ func tempTarFile(path string, data []byte, uid, gid int, mode int64) (string, er
3939
hdr := &tar.Header{
4040
Name: filename,
4141
Size: int64(len(data)),
42-
Mode: int64(mode),
43-
Uid: int(uid),
44-
Gid: int(gid),
42+
Mode: mode,
43+
Uid: uid,
44+
Gid: gid,
4545
}
4646
if err := tw.WriteHeader(hdr); err != nil {
4747
return name, err

rpc/rpc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,8 @@ func (v *Vibranium) Copy(opts *pb.CopyOptions, stream pb.CoreRPC_CopyServer) err
471471
defer tw.Close()
472472
header := &tar.Header{
473473
Name: filepath.Base(m.Filename),
474-
Uid: int(m.UID),
475-
Gid: int(m.GID),
474+
Uid: m.UID,
475+
Gid: m.GID,
476476
Mode: m.Mode,
477477
Size: int64(len(m.Content)),
478478
}

rpc/transform.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,17 @@ func toCoreDeployOptions(d *pb.DeployOptions) (*types.DeployOptions, error) {
291291
var err error
292292
files := []types.LinuxFile{}
293293
for filename, bs := range d.Data {
294-
files = append(files, types.LinuxFile{
294+
file := types.LinuxFile{
295295
Content: bs,
296296
Filename: filename,
297297
UID: int(d.Owners[filename].GetUid()),
298298
GID: int(d.Owners[filename].GetGid()),
299299
Mode: d.Modes[filename].GetMode(),
300-
})
300+
}
301+
if file.Mode == 0 && file.UID == 0 && file.GID == 0 {
302+
file.Mode = 0755
303+
}
304+
files = append(files, file)
301305
}
302306

303307
vbsLimit, err := types.NewVolumeBindings(d.ResourceOpts.VolumesLimit)

types/options.go

+6
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ func (o *SendOptions) Validate() error {
116116
if len(o.Files) == 0 {
117117
return errors.WithStack(ErrNoFilesToSend)
118118
}
119+
for i, file := range o.Files {
120+
if file.UID == 0 && file.GID == 0 && file.Mode == 0 {
121+
// we see it as requiring "default perm"
122+
o.Files[i].Mode = 0755
123+
}
124+
}
119125
return nil
120126
}
121127

0 commit comments

Comments
 (0)