Commit 8dde9408 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Add emulab feature tests for ImageProvenance, for slow roll out.

parent 1ba99d21
...@@ -73,6 +73,7 @@ my $GROUPROOT = "@GROUPSROOT_DIR@"; ...@@ -73,6 +73,7 @@ my $GROUPROOT = "@GROUPSROOT_DIR@";
my $CREATEIMAGE = "$TB/bin/create_image"; my $CREATEIMAGE = "$TB/bin/create_image";
my $NEWIMAGEEZ = "$TB/bin/newimageid_ez"; my $NEWIMAGEEZ = "$TB/bin/newimageid_ez";
my $DOPROVENANCE = @IMAGEPROVENANCE@; my $DOPROVENANCE = @IMAGEPROVENANCE@;
my $doprovenance = 0;
# #
# Untaint the path # Untaint the path
...@@ -96,6 +97,7 @@ use Project; ...@@ -96,6 +97,7 @@ use Project;
use Image; use Image;
use OSinfo; use OSinfo;
use Node; use Node;
use EmulabFeatures;
# Protos # Protos
sub fatal($); sub fatal($);
...@@ -178,6 +180,10 @@ if (! (defined($base_osinfo) && defined($base_image))) { ...@@ -178,6 +180,10 @@ if (! (defined($base_osinfo) && defined($base_image))) {
print "$node_id is running $base_osinfo,$base_image\n" print "$node_id is running $base_osinfo,$base_image\n"
if ($debug); if ($debug);
# Feature override.
$doprovenance =
EmulabFeatures->FeatureEnabled("ImageProvenance", $this_user, $project);
# #
# The simple case is that the descriptor already exists. So it is just # The simple case is that the descriptor already exists. So it is just
# a simple snapshot to the image file. # a simple snapshot to the image file.
...@@ -209,7 +215,7 @@ if (defined($image)) { ...@@ -209,7 +215,7 @@ if (defined($image)) {
if ($image->Lock()) { if ($image->Lock()) {
fatal("Image is locked, please try again later!\n"); fatal("Image is locked, please try again later!\n");
} }
if ($DOPROVENANCE) { if ($DOPROVENANCE && $doprovenance) {
# #
# This will include unreleased images (in image_versions, but # This will include unreleased images (in image_versions, but
# not the one pointed to by the images table). # not the one pointed to by the images table).
...@@ -307,10 +313,8 @@ if (defined($image)) { ...@@ -307,10 +313,8 @@ if (defined($image)) {
emutil::ExecQuiet("$CREATEIMAGE $opts ". emutil::ExecQuiet("$CREATEIMAGE $opts ".
" $imagename:" . $image->version() . " $node_id"); " $imagename:" . $image->version() . " $node_id");
if ($?) { if ($?) {
if ($DOPROVENANCE) {
$image->DeleteVersion() $image->DeleteVersion()
if ($needdelete); if ($needdelete);
}
print STDERR $output; print STDERR $output;
fatal("Failed to create image"); fatal("Failed to create image");
} }
...@@ -331,7 +335,7 @@ if (!$base_image->ezid()) { ...@@ -331,7 +335,7 @@ if (!$base_image->ezid()) {
# Maybe relax this in the future, but this is a good simplification for # Maybe relax this in the future, but this is a good simplification for
# now. # now.
# #
if ($DOPROVENANCE && !$base_image->released()) { if ($DOPROVENANCE && $doprovenance && !$base_image->released()) {
fatal("Not allowed to derive a new image from unreleased ". fatal("Not allowed to derive a new image from unreleased ".
"base $base_image"); "base $base_image");
} }
...@@ -477,7 +481,7 @@ my $osinfo = OSinfo->Lookup($image->imageid()); ...@@ -477,7 +481,7 @@ my $osinfo = OSinfo->Lookup($image->imageid());
if (!defined($osinfo)) { if (!defined($osinfo)) {
fatal("Cannot lookup newly created osinfo for $image"); fatal("Cannot lookup newly created osinfo for $image");
} }
if ($DOPROVENANCE) { if ($DOPROVENANCE && $doprovenance) {
$image->SetProvenance($base_image); $image->SetProvenance($base_image);
$osinfo->SetProvenance($base_osinfo); $osinfo->SetProvenance($base_osinfo);
} }
......
...@@ -87,6 +87,7 @@ my $BOSSIP = "@BOSSNODE_IP@"; ...@@ -87,6 +87,7 @@ my $BOSSIP = "@BOSSNODE_IP@";
my $CONTROL = "@USERNODE@"; my $CONTROL = "@USERNODE@";
my $NONFS = @NOSHAREDFS@; my $NONFS = @NOSHAREDFS@;
my $DOPROVENANCE= @IMAGEPROVENANCE@; my $DOPROVENANCE= @IMAGEPROVENANCE@;
my $doprovenance= 0;
# #
# Testbed Support libraries # Testbed Support libraries
...@@ -103,6 +104,8 @@ use Image; ...@@ -103,6 +104,8 @@ use Image;
use OSinfo; use OSinfo;
use Logfile; use Logfile;
use WebTask; use WebTask;
use Project;
use EmulabFeatures;
# #
# Turn off line buffering on output # Turn off line buffering on output
...@@ -363,6 +366,15 @@ else { ...@@ -363,6 +366,15 @@ else {
} }
} }
} }
# Need this for feature test below.
my $project = Project->Lookup($image->pid());
if (!defined($project)) {
die("*** $0:\n".
" Could not lookup project for $image\n");
}
# Feature override.
$doprovenance =
EmulabFeatures->FeatureEnabled("ImageProvenance", $this_user, $project);
# #
# Make sure that the directory exists and is writeable for the user. # Make sure that the directory exists and is writeable for the user.
...@@ -428,7 +440,7 @@ if ($image->Lock()) { ...@@ -428,7 +440,7 @@ if ($image->Lock()) {
} }
$needunlock = 1; $needunlock = 1;
if ($DOPROVENANCE && $image->ready()) { if ($DOPROVENANCE && $doprovenance && $image->ready()) {
$image->Unlock(); $image->Unlock();
die("*** $0:\n". die("*** $0:\n".
" $image ready flag is set, this is inconsistent!\n"); " $image ready flag is set, this is inconsistent!\n");
...@@ -912,7 +924,7 @@ if (defined($webtask)) { ...@@ -912,7 +924,7 @@ if (defined($webtask)) {
# released. # released.
# #
$image->MarkReady(); $image->MarkReady();
if (! ($isglobal && $pid eq TBOPSPID())) { if (! ($isglobal && $pid eq TBOPSPID()) || !$doprovenance) {
if ($image->Release()) { if ($image->Release()) {
$image->Unlock(); $image->Unlock();
exit(1); exit(1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment