Skip to content
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

Closed

Conversation

spatchineelam
Copy link
Contributor

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

log.Debugf("doInstall: empty Dpath")
}
if len(strings.TrimSpace(ss.Name)) > 0 {
downloadUrl += "/" + ss.Name
Copy link
Contributor

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.

Copy link
Contributor

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" {
Copy link
Contributor

Choose a reason for hiding this comment

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

what is 8

Copy link
Contributor

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("")
Copy link
Contributor

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 ?

Copy link
Contributor

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 {
Copy link
Contributor

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 ?

Copy link
Contributor

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) {

Copy link
Contributor

Choose a reason for hiding this comment

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

space ?

Copy link
Contributor

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
Copy link
Contributor

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"},
Copy link
Contributor

Choose a reason for hiding this comment

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

registry-1, hardcoded?

Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

\n

Copy link
Contributor

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)
Copy link
Contributor

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) {
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Will do..

@rvs
Copy link
Contributor

rvs commented Aug 2, 2019

@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

IsContainer bool
// XXX:FIXME - Delete ContainerUrl atribute. rkt run will use
// ContainerImageId instead.
ContainerUrl string
Copy link
Contributor

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.

Copy link
Contributor Author

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

@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

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

@@ -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
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

# Remove any old symlink to /var/lib/rkt
rm -f /var/lib/rkt
ln -s $PERSIST_RKT_DATA_DIR /var/lib/rkt

Copy link
Contributor

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 ?

Copy link
Contributor Author

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

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"

Copy link
Contributor

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 ?

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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"

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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 {
Copy link
Contributor

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

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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

@rvs
Copy link
Contributor

rvs commented Aug 2, 2019

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

Copy link
Contributor

@kalyan-nidumolu kalyan-nidumolu left a 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
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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))
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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) {
Copy link
Contributor

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("")
Copy link
Contributor

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

@@ -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
Copy link
Contributor

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.

@spatchineelam spatchineelam force-pushed the cont_rkt_tip_aug_1st branch 2 times, most recently from 4dc8159 to ea68f74 Compare August 6, 2019 18:09
@spatchineelam
Copy link
Contributor Author

I have squashed the whole lot of commits into 4 total commits, and applied Roman's CircleCI tweak on top.

rvs and others added 3 commits August 9, 2019 09:07
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>
…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
@rvs rvs closed this Aug 9, 2019
milan-zededa pushed a commit to milan-zededa/eve that referenced this pull request Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants