BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Key123
Fluorite | Level 6

I was following the below code to create Deployment Directories before I migrate metadata from old to new but getting error from SASEG , it sasy App Context not found, attached the complete logfile from SASEG, can you review and suggest if I need to make any changes in the configuration t?.

 

ERROR: A single context named SASGrid not found.

 

Please note We have renamed SASApp to SASGrid while deploying

 

technical-support-code/usage/administration/sas-metadata-server/create_metadata_deployment_directori...

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
gwootton
SAS Super FREQ

Here are the updates to the code that should be pushed to Github this evening, providing more detail based on the value of the return code and only performing the validation of the context on the first run.

/******************************************************************************/
/* This program will add a list deployment directories to Metadata for a      */
/* defined context.                                                           */
/* Date: 14JUN2019                                                            */
/******************************************************************************/

/* History: */
/* 04NOV2024	Added enhanced return code checking, removed redundant lookups of context */
/*				when providing multiple deployment directories.*/

/* Copyright © 2023, SAS Institute Inc., Cary, NC, USA.  All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

 /* Define connection to Metadata. */
options
	metaserver="meta.demo.sas.com"
	metaport=8561
	metauser="sasadm@saspw"
	metapass="password"
	metarepository=Foundation
	metaprotocol=BRIDGE;

/* Define the context to attach the deployment directories. */
%let appcontext = SASApp;

/* Create a dataset with each deployment directory name and path. */
data depdirs;
	length Name Path $ 255;
	input Name Path;
	datalines;
	DeploymentDir1 /tmp/depdir1
	DeploymentDir2 /tmp/depdir2
	;;
run;
/* End edit. */

data _null_;

	/* Initialize variables. */
	length type id appuri diruri $ 255; 
	call missing (of _character_);

	/* Define query for context. */
	appobj = "omsobj:ServerContext?@Name='&appcontext'";

	/* Only for the first iteration, perform validation of the supplied context. */
	if _n_ eq 1 then do;

		/* Check for the existence of the context. */
		rc=metadata_resolve(appobj,type,id);

		/* Throw errors based on the return code if not equal to 1. */
		if rc eq -1 then do;
				put "ERROR: Failed to connect to the Metadata Server using the supplied connection options. " rc=;
				stop;
			end;
		else if rc eq 0 then do;
				put "ERROR: Found no application servers named &appcontext in the Metadata Server. " rc=;
				stop;
			end;
		else if rc gt 1 then do;
				put "ERROR: Found multiple contexts named &appcontext in the Metadata Server. " rc=;
				stop;
			end;
	end;

	/* Read in the data set of deployment directories. */
	set depdirs;

	/* For each one, create the directory object as a child of the context defined above. */
	rc=metadata_newobj("Directory",diruri,Name,"Foundation",appobj,"DataPackages");
	
	/* Only move forward if we successfully created the object. */
	if rc eq 0 then do;
		/* Add the attribute defining the path. */
		rc=metadata_setattr(diruri,"DirectoryName",Path);

		/* Add some required attributes. */
		rc=metadata_setattr(diruri,"UsageVersion","0");
		rc=metadata_setattr(diruri,"IsRelative","0");
	end;
	else do;
		put "ERROR: Failed to create directory object. " rc=;
		stop;
	end;

run;

 

--
Greg Wootton | Principal Systems Technical Support Engineer

View solution in original post

4 REPLIES 4
Patrick
Opal | Level 21

The error message is clear: SASGrid doesn't exist in the environment where you're running the code OR you are using a metadata user that doesn't have read access to it.

 

If you believe that SASGrid does exist and your metadata user has sufficient privileges to "see" it then I suggest you create a SAS metadata query that lists all SAS app servers defined in metadata and run it the same way than your initial script. This will tell you with certainty what exists and is accessible (and I'm pretty sure it won't list SASGrid).

 

But before spending this time: Have you already tried and executed your script searching for SASApp? (just run your code with everything after the step that throws the current error removed).

 

And just as a remark not related to your current challenge:

Not sure why the sample code you've got needs to query for existence of the application server for every single row in your driver table. I'd modify the code like below so it only queries it once.

data _null_;
  /* Initialize variables. */
  length type id appuri diruri $ 255;

  /* Define query for context. */
  appobj = "omsobj:ServerContext?@Name='&appcontext'";

  /* Check for the existence of the context. */
  rc=metadata_resolve(appobj,type,id);

  /* If the context doesn't exist, throw an error and end the program. */
  if rc ne 1 then
    do;
      put "ERROR: A single context named &appcontext not found.";
      stop;
    end;

  do until(last);
    /* Read in the data set of deployment directories. */
    set depdirs end=last;

    /* For each one, create the directory object as a child of the context defined above. */
    rc=metadata_newobj("Directory",diruri,Name,"Foundation",appobj,"DataPackages");

    /* Add the attribute defining the path. */
    rc=metadata_setattr(diruri,"DirectoryName",Path);

    /* Add some required attributes. */
    rc=metadata_setattr(diruri,"UsageVersion","0");
    rc=metadata_setattr(diruri,"IsRelative","0");
    call missing (diruri);
  end;
run;
JuanS_OCS
Azurite | Level 17
Hi there,

I am not sure if that code can be changed as Patrick suggested. Is it part of your EG project? From my point of view it seems like a code created a long ago by @gwontoon, and made standard for EG operations. But I might be wrong.

This being said and put aside, I would check for the metadata permissions of your user/service account to read metadata of the SAS Application server and its underlying SAS servers (eg Logical SAS Workspace Server), in the SAS metadata.

Be really careful with explicit vs inherited vs ACT provided permissions and their priorities.

When all of this is okay I have seen cases where the faulty issue could be physical permissions on the logs folder, saswork or sasuser. Or the log on as batch job on windows.

In some very rare cases, but always in grid setups I have seen issues on the configuration of the Object Spawner, where the High Availability/failover custom configurations lead to missing changes and forgetting to change the name of the Application Server.

I suggest to make these checks, carefully, and in order as presented.
gwootton
SAS Super FREQ

@JuanS_OCS You are correct that this is code I wrote long ago.
@Patrick You are correct that this code unnecessarily performs this check multiple times. I'll see about getting the code updated with your proposed changes.

Given we are attempting to connect as the unrestricted user sasadm@saspw, I would doubt this failure to be a permissions issue, I suspect the failure has something to do with our connection to metadata. My error checking here is pretty basic, just confirming the return code from metadata_resolve returns a 1. The metadata_resolve function will return 0...n for the number of objects that match the query, but might also return a negative value if, for example, we fail to connect to metadata. I could probably make this more robust so I'll look into adjusting that too.

 

I'd probably start by running this in a new EG session:

data _null_;
  length type id $ 50;
  call missing(of _character_);
  obj="omsobj:ServerContext?@Name='SASGrid'";
  rc=metadata_resolve(obj,type,id);
  put rc=;
run;

Then add your options statement for your metadata connection, and run it again:

options
  metaserver="meta.example.com"
  metaport=8561
  metauser="sasadm@saspw"
  metapass="examplepassword"
  metarepository=Foundation
  metaprotocol=BRIDGE
;

data _null_;
  length type id $ 50;
  call missing(of _character_);
  obj="omsobj:ServerContext?@Name='SASGrid'";
  rc=metadata_resolve(obj,type,id);
  put rc=;
run;

The value of the return code output as rc=value should tell us the problem:

n - The number of objects that match the query

0 - No objects match the query

-1 - Unable to connect to the metadata server

 

Source: METADATA_RESOLVE Function

https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrmeta/n1lfiylg4nenwyn1oe66yco3sgly.htm

--
Greg Wootton | Principal Systems Technical Support Engineer
gwootton
SAS Super FREQ

Here are the updates to the code that should be pushed to Github this evening, providing more detail based on the value of the return code and only performing the validation of the context on the first run.

/******************************************************************************/
/* This program will add a list deployment directories to Metadata for a      */
/* defined context.                                                           */
/* Date: 14JUN2019                                                            */
/******************************************************************************/

/* History: */
/* 04NOV2024	Added enhanced return code checking, removed redundant lookups of context */
/*				when providing multiple deployment directories.*/

/* Copyright © 2023, SAS Institute Inc., Cary, NC, USA.  All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

 /* Define connection to Metadata. */
options
	metaserver="meta.demo.sas.com"
	metaport=8561
	metauser="sasadm@saspw"
	metapass="password"
	metarepository=Foundation
	metaprotocol=BRIDGE;

/* Define the context to attach the deployment directories. */
%let appcontext = SASApp;

/* Create a dataset with each deployment directory name and path. */
data depdirs;
	length Name Path $ 255;
	input Name Path;
	datalines;
	DeploymentDir1 /tmp/depdir1
	DeploymentDir2 /tmp/depdir2
	;;
run;
/* End edit. */

data _null_;

	/* Initialize variables. */
	length type id appuri diruri $ 255; 
	call missing (of _character_);

	/* Define query for context. */
	appobj = "omsobj:ServerContext?@Name='&appcontext'";

	/* Only for the first iteration, perform validation of the supplied context. */
	if _n_ eq 1 then do;

		/* Check for the existence of the context. */
		rc=metadata_resolve(appobj,type,id);

		/* Throw errors based on the return code if not equal to 1. */
		if rc eq -1 then do;
				put "ERROR: Failed to connect to the Metadata Server using the supplied connection options. " rc=;
				stop;
			end;
		else if rc eq 0 then do;
				put "ERROR: Found no application servers named &appcontext in the Metadata Server. " rc=;
				stop;
			end;
		else if rc gt 1 then do;
				put "ERROR: Found multiple contexts named &appcontext in the Metadata Server. " rc=;
				stop;
			end;
	end;

	/* Read in the data set of deployment directories. */
	set depdirs;

	/* For each one, create the directory object as a child of the context defined above. */
	rc=metadata_newobj("Directory",diruri,Name,"Foundation",appobj,"DataPackages");
	
	/* Only move forward if we successfully created the object. */
	if rc eq 0 then do;
		/* Add the attribute defining the path. */
		rc=metadata_setattr(diruri,"DirectoryName",Path);

		/* Add some required attributes. */
		rc=metadata_setattr(diruri,"UsageVersion","0");
		rc=metadata_setattr(diruri,"IsRelative","0");
	end;
	else do;
		put "ERROR: Failed to create directory object. " rc=;
		stop;
	end;

run;

 

--
Greg Wootton | Principal Systems Technical Support Engineer

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2511 views
  • 1 like
  • 4 in conversation