Pacing by the glass and rubbing seems common to Pangasidae species. As long as it doesn't rub bad sores, it is usually tolerable.
If the fish feeds well, the stress level is not too bad but of course this is not ideal.
They are, IDS in particular, very nervous, high strung, flighty, skittish, timid, dart-prone fish that react nervously to too small a tank, to less than good water, to new tank mates, to other changes. I think it probably is their way to wanting to get away from perceived source of stress and/or looking for a way out of the tank. I think they don't rub against non-transparent surfaces (which is why tank walls can be painted or papered over), they don't do it in ponds, which may mean that they perceive the transparent surfaces as if the water body they are in continues beyond these surfaces.
They are a hard fish for an average hobbyist to care for ideally, so usually it is a matter of compromises.