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

Adding environment checks to pawsey lua for handling errors #220

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions scripts/templates/pawseyenv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@

]]--

--[[
-- There has been issues where the module just fails on first assert and it is unclear
-- from the error message what that issue is. Thus the module also checks for the
-- definition of HOME, USER, PAWSEY_PROJECT etc.
--]]

local function check_envs()
local envvars = {"HOME", "USER", "PAWSEY_PROJECT"}
for ind,var in ipairs(envvars) do
local env = os.getenv(var)
if env == nil or env == "" then
nid = os.getenv("HOSTNAME")
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens if HOSTNAME itself is not set? -- as unlikely as HOME/USER I reckon.

maybe you could substitute with a Lua command that executes the hostname command

io.stderr:write("Issue with environment variable used to set module paths:" .. var .. "not set.\n")
io.stderr:write("This could be a result of issues with authentication and LDAP.\n")
io.stderr:write("This occurred on " .. nid .. " node\n")
return
end
end
end


-- check that environment is okay
check_envs()

-- Service variables for this module
--
--
Expand Down