WASHINGTON (AP) — President Donald Trump has soured on Homeland Security Secretary Kirstjen Nielsen and she is expected to leave her job, perhaps as soon as this week, according to two people with knowledge of the issue.

Trump has blamed Nielsen for not doing more to address what he has called a crisis at the U.S.-Mexico border, the sources said. Curbing immigration is Trump's signature issue — and one he returns to as a way to rally his most loyal supporters.

But anyone who takes over at Homeland Security is likely to run up against the same problems that Nielsen faced. The administration has already tried to clamp down at the border but those efforts have been largely thwarted or watered down due to legal challenges.

Nielsen had hoped to complete one year in the job and leave in December, but it appeared unlikely she would last that long, said two sources. Both people who had knowledge of the debate spoke to the AP on condition of anonymity because they were not authorized to speak publicly.

Trump was widely expected to shake up his Cabinet after the midterm elections and rumors are swirling about the status of a number of department heads. He also told allies that he never fully trusted Nielsen, whom he associated with President George W. Bush, a longtime foe. And he told those close to him that he felt, at times, that her loyalty was more toward her longtime mentor, White House chief of staff John Kelly, than to the president. Kelly's status is also unclear, one of the people said.

Questions about Nielsen's job security are not new. Earlier this year, she pushed back on a New York Times report that she drafted a resignation letter but did not submit it, after Trump scolded her at a Cabinet meeting. And Trump has been known to suggest he wants to fire someone and then not do it. Former Attorney General Jeff Sessions was thought to be on the outs for months before he actually was pushed out.

Nielsen has led the sprawling post-9/11 federal agency since December. She had been chief of staff to Kelly when he was Trump's first Homeland Security secretary. A homeland security spokesman would not comment on whether she was leaving.

"The secretary is honored to lead the men and women of DHS and is committed to implementing the president's security-focused agenda to protect Americans from all threats and will continue to do so," spokesman Tyler Houlton said.

Nielsen pushed Trump's immigration policies including funding for his border wall and defended the administration's practice of separating children from parents, telling a Senate committee that removing children from parents facing criminal charges happens "in the United States every day." But she was also instrumental in stopping the separations.

She also moved to abandon longstanding regulations that dictate how long children are allowed to be held in immigration detention, and requested bed space from the U.S. military for some 12,000 people in an effort to detain all families who cross the border. Right now there is space for about 3,000 families and they are at capacity.

She got into heated discussions with Trump and White House aides several times over immigration, as she sought to explain the complicated legal challenges behind immigration law and push for a more diplomatic approach.

It's unclear who would replace her. The job requires Senate confirmation and there is no deputy secretary. Under Secretary for Management Claire Grady would be the acting head if Nielsen left.