aws-samples/aws-perforce

PerforceServerSetupTemplate.yaml failing at 14_create_symlink

Closed this issue · 5 comments

From the cfn-init.log:

...
2021-02-16 15:07:21,118 [INFO] Command 13_rewrite_config succeeded
2021-02-16 15:07:21,119 [DEBUG] Command 13_rewrite_config output:
2021-02-16 15:07:21,119 [DEBUG] Running command 14_create_symlink
2021-02-16 15:07:21,119 [DEBUG] No test for command 14_create_symlink
2021-02-16 15:07:21,122 [ERROR] Command 14_create_symlink (ln -s /opt/perforce/bin/p4 /hxdepots/sdp/Server/Unix/p4/common/bin/p4) failed
2021-02-16 15:07:21,122 [DEBUG] Command 14_create_symlink output: ln: failed to create symbolic link '/hxdepots/sdp/Server/Unix/p4/common/bin/p4': File exists

2021-02-16 15:07:21,122 [ERROR] Error encountered during build of 04_config_install_sdp: Command 14_create_symlink failed
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
    changes['commands'] = CommandTool().apply(self._config.commands)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
    raise ToolError(u"Command %s failed" % name)
ToolError: Command 14_create_symlink failed
2021-02-16 15:07:21,124 [ERROR] -----------------------BUILD FAILED!------------------------
2021-02-16 15:07:21,124 [ERROR] Unhandled exception during build: Command 14_create_symlink failed
Traceback (most recent call last):
  File "/opt/aws/bin/cfn-init", line 171, in <module>
    worklog.build(metadata, configSets)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 129, in build
    Contractor(metadata).build(configSets, self)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 530, in build
    self.run_config(config, worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
    changes['commands'] = CommandTool().apply(self._config.commands)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
    raise ToolError(u"Command %s failed" % name)
ToolError: Command 14_create_symlink failed
2021-02-16 15:07:21,322 [DEBUG] CloudFormation client initialized with endpoint https://cloudformation.us-east-1.amazonaws.com
2021-02-16 15:07:21,322 [DEBUG] Signaling resource PerforceServerInstance in stack perforce-server-awsnva-01 with unique ID i-0c776817bbc062e50 and status FAILURE

The file at /hxdepots/sdp/Server/Unix/p4/common/bin/p4 is a shell script, whose contents are:

[p4admin@p4-awsnva-01 ~]$ cat /hxdepots/sdp/Server/Unix/p4/common/bin/p4
#!/bin/bash
set -u

# Try to get the correct version of the 'p4' client.
# If we can't be sure we have it, see if a reasonable
# default can be found.

if [[ -n "${SDP_INSTANCE:-}" && -n "${P4HOME:-}" ]]; then
   exec "${P4HOME}/bin/p4_${SDP_INSTANCE}" "$@"
   exit $?
elif [[ -x "/p4/sdp/exes/p4" ]]; then
   exec /p4/sdp/exes/p4 "$@"
   exit $?
else
   echo -e "\\nError: The SDP shell environment is not setup. The correct version of p4 cannot be determined."
   exit 1
fi

Looks like there was a big SDP release recently. I was able to pull the older version by changing

        04_config_install_sdp:
          sources:
            /tmp: "https://swarm.workshop.perforce.com/projects/perforce-software-sdp/download/downloads/sdp.Unix.tgz"

to

        04_config_install_sdp:
          sources:
            /tmp: "https://swarm.workshop.perforce.com/downloads/guest/perforce_software/sdp/downloads/sdp.Unix.tgz?v=14"

@danbrakeley
Thank you for reporting the issue. Yes, as you pointed, the issue comes from a recent big SDP change.
For the temporary workaround, you can avoid the issue to fix the previous version of SDP in the following line.
https://github.com/aws-samples/aws-perforce/blob/master/templates/PerforceServerSetupTemplate.yaml#L305

I am still looking into the permanent measure for that.

I am still trying to solve the actual cause of the problem. SDP versions later than v2020.1 have many big changes, so it takes longer to fix it than I thought. For now, I will make a hot patch that fetches a fixed version from the following URL, which is confirmed package to work properly in the current template.
https://swarm.workshop.perforce.com/downloads/guest/perforce_software/sdp/downloads/sdp.Unix.tgz?v=%2314

I will work on the update in another branch for the permanent measure.

The CloudFormation template in the deployment document is already updated. From the link in the step, the deployment works properly.
https://github.com/aws-samples/aws-perforce/blob/master/README.md