Hostagent Installation Failed, 'Unable to lock directory /var/cache/apt/archives'

Problem

  • Hostagent installation failed with the below error.

Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)\nE: Unable to lock directory /var/cache/apt/archives/\n"}
  • pf9ctl logs show below messages

{"level":"debug","ts":"2021-04-24T22:48:42.3694Z","caller":"pmk/node.go:216","msg":"Hostagent download completed successfully"}..{"level":"debug","ts":"2021-04-24T22:48:45.8739Z","caller":"pmk/node.go:247","msg":"Ran command sudo[bash -c /tmp/installer.sh --no-proxy --skip-os-check --ntpd --no-project --controller=1618992570-18611.platform9.io --username=smeredith@capturealpha.com --password=Crytime1234!!]"}.{"level":"debug","ts":"2021-04-24T22:48:45.8739Z","caller":"pmk/node.go:247","msg":"stdout:\nExtracting Platform9 installer\n\nNo TTY available. Skipping all prompts...\nNo TTY available. Skipping all prompts...\nSkipping operating system compatibility questions\nReading package lists...\nBuilding dependency tree...\nReading state information...\nntp is already the newest version (1:4.2.8p10+dfsg-5ubuntu7.3).\nError: Could not install the ntp package\nstderr:E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)\nE: Unable to lock directory /var/cache/apt/archives/\n"}.{"level":"debug","ts":"2021-04-24T22:48:45.874Z","caller":"pmk/node.go:48","msg":"Sending Segment Event: Prep-node : ERROR"}

Environment

  • Platform9 Managed Kubernetes - v4.0 and Higher

Cause

Not able to get lock on /var/cache/apt/archive directory.

Resolution

Make sure there are no apt processes running on the node that is being onboarded and then retry the pf9ctl prep node command.