App icon indicating copy to clipboard operation
App copied to clipboard

Tweak camera flash control to make it more obvious

Open twilight2294 opened this issue 11 months ago • 1 comments

Explanation of Change

Fixed Issues

$ https://github.com/Expensify/App/issues/53422 PROPOSAL: https://github.com/Expensify/App/issues/53422#issuecomment-2514308782

Tests

Test only for small screen platform (Cannot test on devices with no flash present):

  • Verify that when flash is on, a thunder icon is shown
Screenshot 2024-12-04 at 6 43 02 PM
  • Verify that when flash is off, a thunder icon with diagonal slash appears
Screenshot 2024-12-04 at 6 43 14 PM
  • [x] Verify that no errors appear in the JS console

Offline tests

Same as tests

QA Steps

Same as tests

  • [x] Verify that no errors appear in the JS console

PR Author Checklist

  • [x] I linked the correct issue in the ### Fixed Issues section above
  • [x] I wrote clear testing steps that cover the changes made in this PR
    • [x] I added steps for local testing in the Tests section
    • [x] I added steps for the expected offline behavior in the Offline steps section
    • [x] I added steps for Staging and/or Production testing in the QA steps section
    • [x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • [x] I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • [x] I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • [x] I included screenshots or videos for tests on all platforms
  • [x] I ran the tests on all platforms & verified they passed on:
    • [x] Android: Native
    • [x] Android: mWeb Chrome
    • [x] iOS: Native
    • [x] iOS: mWeb Safari
    • [x] MacOS: Chrome / Safari
    • [x] MacOS: Desktop
  • [x] I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • [x] I followed proper code patterns (see Reviewing the code)
    • [x] I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • [x] I verified that comments were added to code that is not self explanatory
    • [x] I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • [x] I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • [x] If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • [x] I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • [x] I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • [x] I verified the JSDocs style guidelines (in STYLE.md) were followed
  • [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • [x] I followed the guidelines as stated in the Review Guidelines
  • [x] I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • [x] I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • [x] I verified that if a function's arguments changed that all usages have also been updated correctly
  • [x] If any new file was added I verified that:
    • [x] The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • [x] If a new CSS style is added I verified that:
    • [x] A similar style doesn't already exist
    • [x] The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • [x] If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • [x] If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • [x] If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • [x] If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • [x] If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • [x] I verified that all the inputs inside a form are aligned with each other.
    • [x] I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • [x] If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • [x] I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • [x] If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

twilight2294 avatar Dec 04 '24 13:12 twilight2294

Here's it in the next run, deleting the lock file and able to upgrade full:

image

antonioribeiro avatar Feb 03 '19 14:02 antonioribeiro

I just got the same error. I tried to install Ansible remotely and got that error.

AHassanSOS avatar Feb 25 '19 17:02 AHassanSOS

I have the same error. I've seen this error before and just killing ec2 instance helped me fix that, but with ansible-playbook i can't do that.

Dejan992 avatar Mar 07 '19 19:03 Dejan992

I found that this happens when I set different hostnames for the same "ip"

in hosts: [mygroup] node1 ansible_ssh_host=10.10.10.10 node2 ansible_ssh_host=10.10.10.10


  • hosts: tasks:
    • apt upgrade: full

ludydoo avatar Jun 20 '19 16:06 ludydoo

Just a hunch: update_cache: true runs apt update, and the task fails on the upgrade. So my guess is the module does not check for lock after update when update_cache is true.

eff917 avatar Sep 13 '19 08:09 eff917

The bug seems related to using update_cache: true like @eff917 said.

I had to run sudo mv /var/lib/dpkg/lock /var/lib/dpkg/lock.bak to remove the lock, then Ansible proceeded successfully and apt-get also worked again on the server. Of course, you could also use: sudo rm /var/lib/dpkg/lock.

I had success with this, but still TBD whether this solves it consistently:

- name: Update APT Cache
  apt:
    update_cache: yes
    force_apt_get: yes

- name: Remove apt lock file
  file:
    state: absent
    path: "/var/lib/dpkg/lock"

- name: Upgrade all packages to the latest version
  apt:
    name: "*"
    state: latest
    force_apt_get: yes

On Ubuntu 16. Ansible 2.8.5.

jasongitmail avatar Nov 08 '19 23:11 jasongitmail

You could try

- name: Wait for sudo
  become: yes
  shell:  while sudo fuser /var/lib/dpkg/lock >/dev/null 2>&1; do sleep 5; done;

JoshuaEdwards1991 avatar Nov 15 '19 09:11 JoshuaEdwards1991

@JoshuaEdwards1991 our playbooks are full with different lockfile waits (dpkg.lock, dpkg-frontend.lock, etc.) this problem is inside the apt task, when update is true, it doesn't check locks halfway through the task. The current solution is to split the single task into apt-update, wait-for lockfile, apt-upgrade...

eff917 avatar Nov 21 '19 20:11 eff917

Just ran into this issue today: This is broken

- name: Update apt Cache
    apt: 
      update_cache: yes
      name: "{{ apt_packages }}"

Looking at comments above, this is a viable workaround for us:

  • Breaking the task into three pieces (apt cache, wait for lock, install)
  • Adding force_apt_get:yes
  • become:true on the host level.
- name: Update apt Cache
    apt: 
      update_cache: yes
      force_apt_get: yes
  - name: Wait for APT Lock
    shell:  while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do sleep 5; done;
  - name: Install Apt Packages
    apt:
      name: "{{ apt_packages }}"
      state: present
      force_apt_get: yes

juneeighteen avatar Apr 28 '20 18:04 juneeighteen

I am blocked by this, all my builds on fresh instances with apt module are failing.

bcampoli avatar May 14 '20 21:05 bcampoli

@bcampoli I found out, further to our issue, that it's only happening when we build on AWS instances. Our Docker instances don't have the same issue. I hate that I did this, but we added a pause statement before the APT code above. Even waiting for the lock using while fuser didn't work for us. Two minutes later, I can run all the code and see no issues.

- name: Wait 2 minutes for APT to complete on AWS instances
    pause:
      minutes: 2

juneeighteen avatar May 14 '20 21:05 juneeighteen

We had a similar issue with Ansible package installs randomly and non-deterministically failing on Ubuntu 18.04 running on EC2 instances. We tried explicitly uninstalling the unattended-upgrades packages prior to Ansible being run, but that didn't seem to help.

Ended up adding the following workaround which improved things quite a lot:

- name: install packages
  apt:
    name:
      - ...
      - ...
  # There has been an intermittent issue with this task where it would fail and print the error:
  # 
  #     Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process
  #     using it?
  #
  # The reason for this is unclear. It's not from unattended-upgrades as that has already been
  # uninstalled when creating the base image. The workaround for now is to simply retry this task
  # several times in the event that it fails, with a small delay between each attempt.
  register: result
  until: result is not failed
  retries: 5
  delay: 5

A proper fix would be great.

richard-viney avatar Jun 27 '20 13:06 richard-viney

    - name: Upgrade all apt packages
      become: true
      become_method: sudo
      apt:
        name: "*"
        state: latest

I used this command and it worked on GCE. Hope this helps.

zsxing99 avatar Aug 03 '20 18:08 zsxing99

Hi everyone! This is very annoying issue with Ubuntu. Playbooks which use apt simply very fragile. The problem with unnatended upgrades in ubuntu. See details here https://itsfoss.com/could-not-get-lock-error/ Initial my idea was to turn it off upgrades. But then I need to manage uppgrades when to do that. So I did not like the idea of turning it off. It seems to me that it is better to kill the current upgrade session then completely to turn it off.

I also was thinking to add sudo killall apt apt-get before executing any apt operations, but also do not like it. Another option is to put retry. What I have noticed in many cases after 5-10 minutes play book works one upgrade is completed. So I will give it a try to a retry

Ideally, if Canonical could provide ability to stop upgrades on request in a proper manner. I'd like to have a command some like StopUpgradesFor 42 and it stops upgrades for 42 minutes and then in 42 minutes it starts upgrades again if nobody called StopUpgradesFor again.

Alex2357 avatar Sep 11 '20 23:09 Alex2357

Here is what I ended up coming up with that seems to handle all of the edge cases. Some of this is borrowed from others in this issue, some from other attempts to solve this problem I found in my travels:

- name: Disable periodic updates
  block:
    - name: Set all periodic update options to 0
      replace:
        path: /etc/apt/apt.conf.d/10periodic
        regexp: "1"
        replace: "0"
    - name: Set all auto update options to 0
      replace:
        path: /etc/apt/apt.conf.d/20auto-upgrades
        regexp: "1"
        replace: "0"
    - name: Disable unattended upgrades
      lineinfile:
        path: /etc/apt/apt.conf.d/10periodic
        regexp: "^APT::Periodic::Unattended-Upgrade"
        line: 'APT::Periodic::Unattended-Upgrade "0";'
        create: yes
    - name: Stop apt-daily.* systemd services
      service:
        name: "{{ item }}"
        state: stopped
      with_items:
        - unattended-upgrades
        - apt-daily
        - apt-daily.timer
        - apt-daily-upgrade
        - apt-daily-upgrade.timer
    - name: Disable apt-daily.* systemd services
      systemd:
        name: "{{service}}"
        enabled: no
        masked: yes
      with_items:
        - apt-daily.service
        - apt-daily.timer
        - apt-daily-upgrade.service
        - apt-daily-upgrade.timer
      loop_control:
        loop_var: service
    - name: Uninstall unattended upgrades
      apt:
        name: unattended-upgrades
        state: absent
    - name: Prevent unattended upgrades from being installed
      dpkg_selections:
        name: unattended-upgrades
        selection: hold

tonycpsu avatar Sep 12 '20 00:09 tonycpsu

@tonycpsu how do you solve upgrades then if you have disabled?

My problem is that I use ansible to configure ubuntu machines at home. All works fine except this annoying issue. I do not wanna turn it off. I also have problems with Virtualbox VMs, I also run playbooks against them. What happens is that I start VM based on some old snapshot and then it starts updating. So you need to wait a lot of time to make this happen.

Alex2357 avatar Sep 12 '20 01:09 Alex2357

Same issue here as described by author. Using the following in my playbook to run against a barebon ubuntu 18.04:

  tasks:

    - name: Step 1 - Update Ubuntu package list
      apt:
        update_cache: yes

    - name: Step 2 - Update all packages to the latest version
      apt:
        upgrade: dist

It crashes at "Step 2..." with the following error: FAILED! => {"changed": false, "msg": "'/usr/bin/apt-get dist-upgrade ' failed: E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n", "rc": 100, "stdout": "", "stdout_lines": []} If we wait for a couple minutes then retry the command again it works fine...

Something worth noting, Ubuntu seems to have these scheduled activities which trigger on first boot: sudo systemctl list-timers waiting for it to complete, then including the wait for lock and lock-frontend seems to be a nice workaround.

tonyawad88 avatar Sep 15 '20 17:09 tonyawad88

Just to be sure, check if there is a cloud-init running on your instance, for me, there was a cloud-init set which was locking the update manager for any other operation.

jayantkaushalapp avatar Sep 25 '20 13:09 jayantkaushalapp

@antonioribeiro: Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information.

Here are the items we could not find in your description:

  • component name

Please set the description of this issue with an appropriate template from: https://github.com/ansible/ansible/tree/devel/.github/ISSUE_TEMPLATE

click here for bot help

ansibot avatar Oct 11 '20 13:10 ansibot

Dear maintainer, I believe you should keep your bot on a tighter leash 😆

antonioribeiro avatar Oct 11 '20 15:10 antonioribeiro

I thought rather than deleting the /var/lib/dpkg/lock-frontend lock, I would do OS reboot and it has solved the problem temporally, until we get a proper solution.

- name: Reboot host and wait for it to restart
  reboot:
    msg: "Reboot initiated by Ansible"
    connect_timeout: 10
    reboot_timeout: 300
    pre_reboot_delay: 0
    post_reboot_delay: 60
    test_command: whoami
  become: true

krishanhettihewa avatar Oct 28 '20 04:10 krishanhettihewa

Hello. I've just created a documentation PR which should help you with this issue. Basically, you're being caught in a race condition, usually sparked by an internal process performing updates (e.g. unattended-updates) or another thread elsewhere locking the dpkg processes.

The PR I've raised is #73079 but in essence, it reads like this:

# A common issue, particularly during early boot or at specific clock times
# is that apt will be locked by another process, perhaps trying to autoupdate
# or just a race condition on a thread. This work-around (which can also be
# applied to any of the above statements) ensures that if there is a lock file
# engaged, which is trapped by the `msg` value, triggers a repeat until the
# lock file is released.
- name: Install packages only when the apt process isn't locked
  apt:
    name: foo
    state: present
  register: apt_action
  retries: 100
  until: apt_action is success or ('Failed to lock apt for exclusive operation' not in apt_action.msg and '/var/lib/dpkg/lock' not in apt_action.msg)

Update your lines which look like apt: upgrade=full (or, frankly, any apt* module) to have something alike this:

- apt:
    upgrade: full
  register: apt_action
  retries: 100
  until: apt_action is success or ('Failed to lock apt for exclusive operation' not in apt_action.msg and '/var/lib/dpkg/lock' not in apt_action.msg)

Hope this helps!

JonTheNiceGuy avatar Dec 30 '20 00:12 JonTheNiceGuy

Thank you @JonTheNiceGuy !

juneeighteen avatar Dec 30 '20 10:12 juneeighteen

Also hitting this. Thanks all for your solutions, unfortunately, nothing worked in my case (ansible 2.8, Ubuntu 20.04). Sometimes a reboot works, sometimes I need to set become_user: root, sometimes become: yes is enough. The behaviour is shaky, a proper solution would be nice.

trompx avatar Mar 23 '21 12:03 trompx

Quoting @trompx

Thanks all for your solutions, unfortunately, nothing worked in my case (ansible 2.8, Ubuntu 20.04).

Even the "retries"/"until" method linked above? Hmm.

Sometimes a reboot works, sometimes I need to set become_user: root, sometimes become: yes is enough.

Ultimately this issue occurs because another apt process is running, or because you don't have permission to run the apt commands as the user you're running the playbook actions as (either via sudo ansible-playbook, or using a become: yes stanza of some description). Running your playbook with -vvvv may give you more of a clue on what's happening.

The behaviour is shaky, a proper solution would be nice.

From the sounds of things, your issue may be down to several factors. Each one may need a different tweak. The retries/until loop will help a lot, but you also need to work out what's happening with your permissions, and be aware that many of these issues are occurring due to processes which are happening in the background.

Good luck!

JonTheNiceGuy avatar Mar 23 '21 18:03 JonTheNiceGuy

@trompx Have you tried running

/usr/bin/cloud-init status --wait

before accessing apt? This seemed to solve the problem for me with provisioning VMs with Ansible on AWS.

richard-viney avatar Mar 23 '21 22:03 richard-viney

Hi Team,

We are using ansible for this task. this issue is for UBUNTU20

fatal: [default]: FAILED! => {"changed": false, "msg": "'/usr/bin/apt-get upgrade --with-new-pkgs ' failed: E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 22272 (dpkg)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n", "rc": 100, "stdout": "", "stdout_lines": []}

Please suggest some code to fix this issue.

ravulakiran avatar Mar 24 '21 07:03 ravulakiran

@ravulakiran

Please suggest some code to fix this issue.

Have you looked higher up in this thread? Have you tried any of the suggestions? In particular, for example, this comment: https://github.com/ansible/ansible/issues/51663#issuecomment-752286191

JonTheNiceGuy avatar Mar 25 '21 07:03 JonTheNiceGuy

TASK [Install packages only when the apt process isn't locked] ***************** fatal: [default]: FAILED! => {"attempts": 1, "changed": false, "msg": "No package matching 'foo' is available"}

ravulakiran avatar Mar 29 '21 05:03 ravulakiran

TASK [Install packages only when the apt process isn't locked] ***************** fatal: [default]: FAILED! => {"attempts": 1, "changed": false, "msg": "No package matching 'foo' is available"}

The message there is clear - "No package matching 'foo' is available" - You need to specify a particular package name that you want to be installed, such as, for example, hello.

JonTheNiceGuy avatar Mar 29 '21 10:03 JonTheNiceGuy