New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cont rkt tip aug 1st #168
Cont rkt tip aug 1st #168
Conversation
log.Debugf("doInstall: empty Dpath") | ||
} | ||
if len(strings.TrimSpace(ss.Name)) > 0 { | ||
downloadUrl += "/" + ss.Name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
golang path library does this for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah.. ok.. Will use that.
} | ||
log.Infof("doInstall: downloadUrl: %s", downloadUrl) | ||
|
||
if ss.Format == "8" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is 8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8 is format container. This really should be enum instead of a string. Was thinking of making that change separately.
if err != nil { | ||
return err | ||
location := "" | ||
err := errors.New("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see this style of err, initliazation. Is empty string nil error ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not actually being used. I just need it declared. I think the right way is to declare it as
var err errors.Error
err = nil
) | ||
|
||
type RktCredentials struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting, why does downloader know its container credentials, why cannot we use common user/name password location, does there different sturcture for SFTP ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For other types, we are directly passing it to the command. For rkt, we need to put that into a json file and pass the file. Hence doing it this way.
} | ||
|
||
func rktCreateAuthFile(config *types.DownloaderConfig) (string, error) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove.
} | ||
|
||
// XXX:FIXME - Why should this directory be created again | ||
// when it was created in the first place in device-steps.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, why should it be ?
rktAuth := types.RktAuthInfo{ | ||
RktKind: "dockerAuth", | ||
RktVersion: "v1", | ||
Registries: []string{"registry-1.docker.io"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
registry-1, hardcoded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be fixed. Need a way to translate URL into Registry name.. Will start a thread on this.
status.Size = 0 | ||
status.LastErr = fmt.Sprintf("%v", err) | ||
status.LastErrTime = time.Now() | ||
status.RetryCount += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status.State doesn't change here with download failed. How many time RetryCount is going to go up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now there is no retry..
Currently, there is no DOWNLOAD_ERROR state. status.State is looked at only if there is no error.
@@ -1190,6 +1357,13 @@ func handleSyncOp(ctx *downloaderContext, key string, | |||
log.Fatalf("handleSyncOp: No ObjType for %s\n", | |||
status.Safename) | |||
} | |||
|
|||
log.Debugf("handleSyncOp: config: %+v", config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\n
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it implicitly adds a \n ( log.Debugf )
@@ -1190,6 +1357,13 @@ func handleSyncOp(ctx *downloaderContext, key string, | |||
log.Fatalf("handleSyncOp: No ObjType for %s\n", | |||
status.Safename) | |||
} | |||
|
|||
log.Debugf("handleSyncOp: config: %+v", config) | |||
log.Debugf("handleSyncOp: IsContainer: %v", config.IsContainer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\n
return | ||
} | ||
publishVerifyImageStatus(ctx, &status) | ||
if !verifyObjectSha(ctx, config, &status) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to run go fmt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do..
@spatchineelam @kalyan-nidumolu as part of this review you both should start going over Yetus feedback https://1561-182198941-gh.circle-artifacts.com/0/tmp/yetus-out/diff-patch-revive.txt I'll provide more details later today |
pkg/pillar/types/zedmanagertypes.go
Outdated
IsContainer bool | ||
// XXX:FIXME - Delete ContainerUrl atribute. rkt run will use | ||
// ContainerImageId instead. | ||
ContainerUrl string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked through the patch and it seems that ContainerUrl and URL is fairly trivial to remove now. Lets not keep this XXX:FIXME and do it before we merge the patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in latest commit
pkg/pillar/types/domainmgrtypes.go
Outdated
@@ -103,6 +108,10 @@ type DomainStatus struct { | |||
LastErrTime time.Time | |||
BootFailed bool | |||
AdaptersFailed bool | |||
IsContainer bool // Is this Domain for a Container? | |||
ContainerImageId string // SHA-512 of rkt comtainer image | |||
URL string // rkt uses this URL to launch the container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked through the patch and it seems that ContainerUrl and URL is fairly trivial to remove now. Lets not keep this XXX:FIXME and do it before we merge the patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in latest commit
pkg/pillar/types/domainmgrtypes.go
Outdated
@@ -25,6 +26,10 @@ type DomainConfig struct { | |||
VifList []VifInfo | |||
IoAdapterList []IoAdapter | |||
CloudInitUserData string // base64-encoded | |||
// Container related info | |||
IsContainer bool // Is this Domain for a Container? | |||
URL string // rkt uses this URL to launch the container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked through the patch and it seems that ContainerUrl and URL is fairly trivial to remove now. Lets not keep this XXX:FIXME and do it before we merge the patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove ContainerUrl from DomainMgr types. We need that only between zedmanager and downloadmgr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in latest commit
pkg/pillar/scripts/device-steps.sh
Outdated
# Remove any old symlink to /var/lib/rkt | ||
rm -f /var/lib/rkt | ||
ln -s $PERSIST_RKT_DATA_DIR /var/lib/rkt | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we decided to remove this part @spatchineelam ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in latest commit
pkg/pillar/scripts/device-steps.sh
Outdated
DIRS="$CONFIGDIR $CONFIGDIR/DevicePortConfig" | ||
DIRS="$DIRS $TMPDIR $TMPDIR/DeviceNetworkConfig/ $TMPDIR/AssignableAdapters" | ||
DIRS="$DIRS $PERSISTDIR $PERSIST_RKT_DATA_DIR $PERSIST_RKT_CONF_LOCAL_DIR $PERSIST_RKT_CONF_LOCAL_AUTH_DIR" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on your research isn't it supposed to be moved to a different part of device-steps.sh @spatchineelam ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in latest commit
@@ -1860,6 +1877,87 @@ func handleDelete(ctx *domainContext, key string, status *types.DomainStatus) { | |||
status.UUIDandVersion, status.DisplayName) | |||
} | |||
|
|||
// Wrapper for domain creation thru xlCreate or rktRun | |||
func wrapDomainCreate(status *types.DomainStatus) (int, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't a more natural name for this function simply be domainCreate? I mean containers ARE domains in our implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in latest commit
} | ||
|
||
// Launch app/container thru rkt | ||
// XXX:FIXME - check whether dom is launched in pause state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just committed a change into stage1 implementation that allows you to pass extra arguments to xl create. Lets fix this FIXME right now by passing STAGE1_XL_OPTS="-p"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in latest commit
@@ -2022,6 +2120,56 @@ func xlUnpause(domainName string, domainId int) error { | |||
return nil | |||
} | |||
|
|||
// Wrapper for domain shutdown thru xlShutdown or rktStop | |||
func wrapDomainShutdown(status types.DomainStatus, force bool) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't a more natural name for this function simply be domainShutdown? I mean containers ARE domains in our implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in latest commit
// Use rkt tool | ||
log.Infof("Using rkt tool ... PodUUID - %s\n", status.PodUUID) | ||
err = rktStop(status.PodUUID, force) | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest you unconditionally follow with xlShutdown after rktStop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in latest commit
@@ -2049,6 +2197,56 @@ func xlShutdown(domainName string, domainId int, force bool) error { | |||
return nil | |||
} | |||
|
|||
// Wrapper for domain Destroy thru xlDestroy or rktRm | |||
func wrapDomainDestroy(status types.DomainStatus) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't a more natural name for this function simply be domainDestroy? I mean containers ARE domains in our implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in latest commit
One last thing @spatchineelam and @kalyan-nidumolu -- please make sure to rebase on the latest EVE master before taking care of feedback @zedvijay and I provided. You'll need to be based off of https://github.com/lf-edge/eve/pull/170/files at least |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments below.l
var location string | ||
if status.IsContainer { | ||
// location := "/persist/rkt/cas/blob/sha512/" + "FIRST TWO CHARS IN SHA" + status.ContainerImageId | ||
location = persistRktDataDir + "/cas/blob/sha512/" + string(status.ContainerImageId[:2]) + "/" + status.ContainerImageId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use golang path library: https://golang.org/pkg/path/#Join
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in latest commit
// location := "/persist/rkt/cas/blob/sha512/" + "FIRST TWO CHARS IN SHA" + status.ContainerImageId | ||
location = persistRktDataDir + "/cas/blob/sha512/" + string(status.ContainerImageId[:2]) + "/" + status.ContainerImageId | ||
} else { | ||
locationDir := verifiedDirname + "/" + dc.ImageSha256 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use golang path library
uuidData, err := ioutil.ReadFile("/persist/rkt/uuid_file") | ||
if err != nil { | ||
log.Errorf("Open /persist/rkt/uuid_file failed : %s\n", err) | ||
return 0, errors.New(fmt.Sprintf("open /persist/rkt/uuid_file failed: %s\n", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of this error, should re remove the container we launched? Otherwise, it is left dangling??
status.PodUUID = strings.TrimSpace(string(uuidData)) | ||
log.Infof("PodUUID = %s\n", status.PodUUID) | ||
|
||
// Temporary hack to obatin the domain id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we refactor this piece into a separate function and call from here?
getDomainIdForContainer()
or something like that? Keeps it more modular.
status.DomainName, status.DomainId) | ||
err = xlDestroy(status.DomainName, status.DomainId) | ||
// wait for 3 seconds | ||
time.Sleep(3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 3 seconds good enough?? Please make this a descriptive constant instead of a magic number (3) ..
status.Size = 0 | ||
status.LastErr = fmt.Sprintf("%v", err) | ||
status.LastErrTime = time.Now() | ||
status.RetryCount += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now there is no retry..
Currently, there is no DOWNLOAD_ERROR state. status.State is looked at only if there is no error.
@@ -1190,6 +1357,13 @@ func handleSyncOp(ctx *downloaderContext, key string, | |||
log.Fatalf("handleSyncOp: No ObjType for %s\n", | |||
status.Safename) | |||
} | |||
|
|||
log.Debugf("handleSyncOp: config: %+v", config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it implicitly adds a \n ( log.Debugf )
return | ||
} | ||
publishVerifyImageStatus(ctx, &status) | ||
if !verifyObjectSha(ctx, config, &status) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do..
if err != nil { | ||
return err | ||
location := "" | ||
err := errors.New("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not actually being used. I just need it declared. I think the right way is to declare it as
var err errors.Error
err = nil
pkg/pillar/types/domainmgrtypes.go
Outdated
@@ -25,6 +26,10 @@ type DomainConfig struct { | |||
VifList []VifInfo | |||
IoAdapterList []IoAdapter | |||
CloudInitUserData string // base64-encoded | |||
// Container related info | |||
IsContainer bool // Is this Domain for a Container? | |||
URL string // rkt uses this URL to launch the container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove ContainerUrl from DomainMgr types. We need that only between zedmanager and downloadmgr.
4dc8159
to
ea68f74
Compare
I have squashed the whole lot of commits into 4 total commits, and applied Roman's CircleCI tweak on top. |
d4406d5
to
c45113d
Compare
Signed-off-by: Roman Shaposhnik <rvs@zededa.com>
First cut to publish Container ImageID in AppInstanceStatus Signed-off-by: Sankar Patchineelam <sankar@zededa.com>
First cut of changes for Domain Manager to support containers Domain manager changes to use external xl.cfg for stage1 xen config Taking care of Yetus warnings Signed-off-by: Sankar Patchineelam <sankar@zededa.com>
c45113d
to
973e4a5
Compare
…nges for Domain Manager to support containers Domain manager changes to use external xl.cfg for stage1 xen config Taking care of Yetus warnings
…nges for Domain Manager to support containers Domain manager changes to use external xl.cfg for stage1 xen config Taking care of Yetus warnings
…nges for Domain Manager to support containers Domain manager changes to use external xl.cfg for stage1 xen config Taking care of Yetus warnings
…nges for Domain Manager to support containers Domain manager changes to use external xl.cfg for stage1 xen config Taking care of Yetus warnings
pull the latest eve 3/30
Squashed commits into two commits based on the owner.
Softlink /persist/rkt to /var/lib/rkt
Use Add rkt data directory global option --dir=<> for all rkt commands
And rebased the patches on Top of master