One source says the marriage between Louis VII and Eleanor of Aquitaine was annulled by the Catholic Church on the ground of consanguinity: Eleanor and Louis were too closely related for the church to tolerate. Other sources say they were officially divorced:
When [Henry] was sixteen he was knighted at Carlisle by King David of Scotland, when he was eighteen he succeeded to Normandy and Anjou, when nineteen he married Eleanor of Aquitaine, the divorced wife of Louis VII of France, and secured her inheritance. Source: http://www.newadvent.org/cathen/07220b.htm
The eldest daughter of the William, Duke of Aquitaine, she was married to Louis VII, King of France. During the Second Crusade, her relationship with her husband soured, and in 1152, they officially divorced. Shortly afterward, she married Henry of Anjou, who in two years would become King of England...
Though at one time Louis had adored his wife, after 15 years of marriage he was willing to let her go for the sake of the Capetian royal line. She had not borne him a son and heir, only two daughters. Eleanor, on cue, illuminated her predicament, explaining that her husband’s infrequent visits to her bed accounted for the fruitlessness of their union. In the end, the marriage was annulled on the convenient grounds of consanguinity: Eleanor and Louis were too closely related for the church to tolerate. Following the dissolution of her marriage, Eleanor regained possession of Aquitaine and Poitou.
[Historian Simon] Schama writes, “Barely eight weeks after Eleanor’s divorce in May 1152, Henry stood at the altar beside this considerably older woman...” Source: https://britishheritage.com/eleanor-of-aquitaine/
When Louis VII, King of France, married Eleanor of Aquitaine. because she was heiress to the vast territories of Poitou and the Aquitaine, no one was greatly surprised. There was more surprise when the royal couple sought an annulment in 1152, since the King thereby lost control of the Aquitaine, a territory much larger than medieval France. The mistake, which must have been glaring enough anyway, was exacerbated when just two months later Eleanor married the Count of Anjou, better known to us as Henry II, King of England, and claimant to the French throne. Henry and Eleanor had seven children. Source: http://www.midi-france.info/190202_england.htm
Edit - additional information to provide clarity:
Louis VII married Eleanor of Aquitaine then their marriage was annulled by the Catholic Church on the ground of consanguinity, thereby allowing Eleanor to marry Henry II in May 1152. Since the Church allowed Henry II (who was also the Duke of Normandy and Count of Anjou) to marry Eleanor then their children were legitimate in the eyes of the Church.
Although Henry II had Eleanor imprisoned after a failed revolt (in 1173) her imprisonment ended after the death of Henry II in 1189. She retired to the monastery at Fontevrault in Anjou, where she died in 1204 at the age of 82. There is no suggestion that the children of Henry II and Eleanor were illegitimate, nor did they seek a divorce/annulment.
Henry II (5 March 1133-6 July 1189), King of England (25 October 1154-6 July 1189), Duke of Normandy, Count of Anjou
Richard I, Coeur de Lion, Richard the Lionheart, (8 September 1157 – 6 April 1199) King of England (6 July 1189 – 6 April 1199), Duke of Aquitaine, Duke of Normandy, Count of the Anjou
John (24 December c. 1166 – 18 October 1216) , King of England (6 April 1199 — 18 October 1216), Lord of Ireland, Duke of Normandy and Aquitaine and Count of Anjou
Henry III (1 October 1207 – 16 November 1272), King of England (18 October 1216 - 16 November 1272), Lord of Ireland and Duke of Aquitaine