On one hand, their revenge was perfectly in accord with the samurai code of honor; on the other, they had murdered a high official.
They killed a high official, but did so within the samurai code of honor.